summaryrefslogtreecommitdiff
path: root/rt/docs/design_docs/string-extraction-guide.txt
blob: 757a2701493a800a8b897094902c6c2cd5cd5513 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# $File: //depot/RT/rt-devel/docs/design_docs/string-extraction-guide.txt $ $Author: ivan $
# $Revision: 1.1.1.2 $ $Change: 1431 $ $DateTime: 2002/10/15 17:24:45 $

Run 'p4 edit lib/RT/I18N/zh_tw.pm' and 'perl l10n.pl' to add new
extractions to the zh_tw.pm.

Edit lib/RT/I18N/zh_tw.pm for chinese counterparts.

Attached is a copy of the freshly rewritten string extraction style guide.
Please point out anything that's unclear or underspecified.   I
localized a number of the core modules in RT 2.1.3 (Starting with 
Queue_Overlay.pm). I only touched a couple of the web templates in the 
Elements/ directory of the web ui.

RT String extraction styleguide:

Web templates:

Templates should use the /l filtering component to call the localisation
framework

The string 		Foo!

Should become		<&|/l&>Foo!</&>

All newlines should be removed from localized strings, to make it easy to 
grep the codebase for strings to be localized

The string 		Foo
			Bar
			Baz
			
Should become		<&|/l&>Foo Bar Baz</&>


Variable subsititutions should be moved to Locale::MakeText format

The string		Hello, <%$name %>

should become		<&|/l, $name &>Hello, [_1]</&>	


Multiple variables work just like single variables
 
The string		You found <%$num%> tickets in queue <%$queue%>

should become		<&|/l, $num, $queue &>You found [_1] tickets in queue [_2]</&>

When subcomponents are called in the middle of a phrase, they need to be escaped
too:

The string		 <input type="submit" value="New ticket in">&nbsp<& /Elements/SelectNewTicketQueue&>

should become		<&|/l, $m->scomp('/Elements/SelectNewTicketQueue')&><input type="submit" value="New ticket in">&nbsp;[_1]</&>



There are places inside the web ui where strings are defined, which need to be
localised. it is important to note here that each localized string is split out
onto its own line, but never split across two lines and two localized strings
are never included on the same line. It is also important to note
that this will genereate code which will not work in RT 2.1.3. I need
to add a bit of framework to make it work in 2.1.4


The string	<& /Elements/TitleBoxStart, width=> "40%", titleright => "RT $RT::VERSION for ". RT->Config->Get('rtname'), title => 'Login' &>

should become 	<& /Elements/TitleBoxStart, 
			width=> "40%",
			titleright => loc("RT [_1] for [_2]",$RT::VERSION, RT->Config->Get('rtname')),
			title => loc('Login'),
	      	&>
	

			



Within RT's core code, every module has a localization handle available through the 'loc' method:

The code 	return ( $id, "Queue created" );

should become 	return ( $id, $self->loc("Queue created") );	

When returning or localizing a single string, the "extra" set of parenthesis () should be omitted.

The code  	return ("Subject changed to ". $self->Data );

should become	 return $self->loc( "Subject changed to [_1]", $self->Data );


It is important not to localize  the names of rights or statuses within RT's core, as there is logic that depends on them as string identifiers.  The proper place to localize these values is when they're presented for display in the web or commandline interfaces.





-- 
http://www.bestpractical.com/products/rt  -- Trouble Ticketing. Free.