The real release 0.46 :-)
[awl.git] / docs / api / awl / Translation / _Translation.php.html
blob8bcbc8a4c9d174e8e2899cc6f210405f80270e1f
1 <?xml version="1.0" encoding="iso-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <!-- template designed by Marco Von Ballmoos -->
6 <title>Docs for page Translation.php</title>
7 <link rel="stylesheet" href="../../media/stylesheet.css" />
8 <script src="../../media/lib/classTree.js"></script>
9 <script language="javascript" type="text/javascript">
10 var imgPlus = new Image();
11 var imgMinus = new Image();
12 imgPlus.src = "../../media/images/plus.png";
13 imgMinus.src = "../../media/images/minus.png";
15 function showNode(Node){
16 switch(navigator.family){
17 case 'nn4':
18 // Nav 4.x code fork...
19 var oTable = document.layers["span" + Node];
20 var oImg = document.layers["img" + Node];
21 break;
22 case 'ie4':
23 // IE 4/5 code fork...
24 var oTable = document.all["span" + Node];
25 var oImg = document.all["img" + Node];
26 break;
27 case 'gecko':
28 // Standards Compliant code fork...
29 var oTable = document.getElementById("span" + Node);
30 var oImg = document.getElementById("img" + Node);
31 break;
33 oImg.src = imgMinus.src;
34 oTable.style.display = "block";
37 function hideNode(Node){
38 switch(navigator.family){
39 case 'nn4':
40 // Nav 4.x code fork...
41 var oTable = document.layers["span" + Node];
42 var oImg = document.layers["img" + Node];
43 break;
44 case 'ie4':
45 // IE 4/5 code fork...
46 var oTable = document.all["span" + Node];
47 var oImg = document.all["img" + Node];
48 break;
49 case 'gecko':
50 // Standards Compliant code fork...
51 var oTable = document.getElementById("span" + Node);
52 var oImg = document.getElementById("img" + Node);
53 break;
55 oImg.src = imgPlus.src;
56 oTable.style.display = "none";
59 function nodeIsVisible(Node){
60 switch(navigator.family){
61 case 'nn4':
62 // Nav 4.x code fork...
63 var oTable = document.layers["span" + Node];
64 break;
65 case 'ie4':
66 // IE 4/5 code fork...
67 var oTable = document.all["span" + Node];
68 break;
69 case 'gecko':
70 // Standards Compliant code fork...
71 var oTable = document.getElementById("span" + Node);
72 break;
74 return (oTable && oTable.style.display == "block");
77 function toggleNodeVisibility(Node){
78 if (nodeIsVisible(Node)){
79 hideNode(Node);
80 }else{
81 showNode(Node);
84 </script>
85 </head>
86 <body>
87 <div class="page-body">
88 <h2 class="file-name"><img src="../../media/images/Page_logo.png" alt="File" style="vertical-align: middle">/Translation.php</h2>
90 <a name="sec-description"></a>
91 <div class="info-box">
92 <div class="info-box-title">Description</div>
93 <div class="nav-bar">
94 <span class="disabled">Description</span> |
95 <a href="#sec-functions">Functions</a>
96 </div>
97 <div class="info-box-body">
98 <!-- ========== Info from phpDoc block ========= -->
99 <p class="short-description">Functions involved in translating with gettext</p>
100 <ul class="tags">
101 <li><span class="field">author:</span> Andrew McMillan &lt;<a href="mailto:andrew@mcmillan.net.nz">andrew@mcmillan.net.nz</a>&gt;</li>
102 <li><span class="field">copyright:</span> Catalyst IT Ltd</li>
103 <li><span class="field">license:</span> <a href="http://gnu.org/copyleft/gpl.html">GNU GPL v2 or later</a></li>
104 </ul>
106 </div>
107 </div>
113 <a name="sec-functions"></a>
114 <div class="info-box">
115 <div class="info-box-title">Functions</div>
116 <div class="nav-bar">
117 <a href="#sec-description">Description</a> |
118 <span class="disabled">Functions</span>
119 </div>
120 <div class="info-box-body">
121 <a name="functionawl_set_locale" id="functionawl_set_locale"><!-- --></a>
122 <div class="evenrow">
124 <div>
125 <img src="../../media/images/Function.png" />
126 <span class="method-title">awl_set_locale</span> (line <span class="line-number">99</span>)
127 </div>
129 <!-- ========== Info from phpDoc block ========= -->
130 <p class="short-description">Set the translation to the user's locale. At this stage all we do is call the gettext function.</p>
131 <div class="method-signature">
132 <span class="method-result">void</span>
133 <span class="method-name">
134 awl_set_locale
135 </span>
136 (<span class="var-type"></span>&nbsp;<span class="var-name">$locale</span>)
137 </div>
139 <ul class="parameters">
140 <li>
141 <span class="var-type"></span>
142 <span class="var-name">$locale</span> </li>
143 </ul>
146 </div>
147 <a name="functioni18n" id="functioni18n"><!-- --></a>
148 <div class="oddrow">
150 <div>
151 <img src="../../media/images/Function.png" />
152 <span class="method-title">i18n</span> (line <span class="line-number">54</span>)
153 </div>
155 <!-- ========== Info from phpDoc block ========= -->
156 <p class="short-description">Mark a string as being internationalized. This is a semaphore method; it does nothing but it allows us to easily identify strings that require translation. Generally this is used to mark strings that will be stored in the database (like descriptions of permissions).</p>
157 <p class="description"><p>AWL uses GNU gettext for internationalization (i18n) and localization (l10n) of text presented to the user. Gettext needs to know about all places involving strings, that must be translated. Mark any place, where localization at runtime shall take place by using the function translate().</p><p>In the help I have used 'xlate' rather than 'translate' and 'x18n' rather than 'i18n' so that the tools skip this particular file for translation :-)</p><p>E.g. instead of: print 'TEST to be displayed in different languages'; use: print xlate('TEST to be displayed in different languages'); and you are all set for pure literals. The translation teams will receive that literal string as a job to translate and will translate it (when the message is clear enough). At runtime the message is then localized when printed. The input string can contain a hint to assist translators: print xlate('TT &lt;!-- abbreviation for Translation Test --&gt;'); The hint portion of the string will not be printed.</p><p>But consider this case: $message_to_be_localized = 'TEST to be displayed in different languages'; print xlate($message_to_be_localized);</p><p>The translate() function is called in the right place for runtime handling, but there is no message at gettext preprocessing time to be given to the translation teams, just a variable name. Translation of the variable name would break the code! So all places potentially feeding this variable have to be marked to be given to translation teams, but not translated at runtime!</p><p>This method resolves all such cases. Simply mark the candidates: $message_to_be_localized = x18n('TEST to be displayed in different languages'); print xlate($message_to_be_localized);</p></p>
158 <ul class="tags">
159 <li><span class="field">return:</span> the same value</li>
160 </ul>
161 <div class="method-signature">
162 <span class="method-result">string</span>
163 <span class="method-name">
164 i18n
165 </span>
166 (<span class="var-type">string</span>&nbsp;<span class="var-name">$value</span>)
167 </div>
169 <ul class="parameters">
170 <li>
171 <span class="var-type">string</span>
172 <span class="var-name">$value</span><span class="var-description">: the value</span> </li>
173 </ul>
176 </div>
177 <a name="functioninit_gettext" id="functioninit_gettext"><!-- --></a>
178 <div class="evenrow">
180 <div>
181 <img src="../../media/images/Function.png" />
182 <span class="method-title">init_gettext</span> (line <span class="line-number">84</span>)
183 </div>
185 <!-- ========== Info from phpDoc block ========= -->
186 <p class="short-description">Initialise our use of Gettext</p>
187 <div class="method-signature">
188 <span class="method-result">void</span>
189 <span class="method-name">
190 init_gettext
191 </span>
192 (<span class="var-type"></span>&nbsp;<span class="var-name">$domain</span>, <span class="var-type"></span>&nbsp;<span class="var-name">$location</span>)
193 </div>
195 <ul class="parameters">
196 <li>
197 <span class="var-type"></span>
198 <span class="var-name">$domain</span> </li>
199 <li>
200 <span class="var-type"></span>
201 <span class="var-name">$location</span> </li>
202 </ul>
205 </div>
206 <a name="functiontranslate" id="functiontranslate"><!-- --></a>
207 <div class="oddrow">
209 <div>
210 <img src="../../media/images/Function.png" />
211 <span class="method-title">translate</span> (line <span class="line-number">65</span>)
212 </div>
214 <!-- ========== Info from phpDoc block ========= -->
215 <p class="short-description">Convert a string in English to whatever this user's locale is</p>
216 <div class="method-signature">
217 <span class="method-result">void</span>
218 <span class="method-name">
219 translate
220 </span>
221 (<span class="var-type"></span>&nbsp;<span class="var-name">$en</span>)
222 </div>
224 <ul class="parameters">
225 <li>
226 <span class="var-type"></span>
227 <span class="var-name">$en</span> </li>
228 </ul>
231 </div>
232 </div>
233 </div>
235 <p class="notes" id="credit">
236 Documentation generated on Tue, 28 Dec 2010 02:01:37 +1300 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.3</a>
237 </p>
238 </div></body>
239 </html>