comparison doc/i18n.txt @ 887:148c17f49111

More doc improvements.
author cmlenz
date Mon, 19 Apr 2010 08:28:47 +0000
parents 9bd255289d75
children 18dee397f8e1
comparison
equal deleted inserted replaced
886:9bd255289d75 887:148c17f49111
135 <p> 135 <p>
136 Please visit <a href="${site.url}">${site.name}</a> for help. 136 Please visit <a href="${site.url}">${site.name}</a> for help.
137 </p> 137 </p>
138 138
139 Without further annotation, the translation filter would treat this sentence 139 Without further annotation, the translation filter would treat this sentence
140 as two separate messages (“Please click” and “here”), and the translator would 140 as two separate messages (“Please visit” and “for help”), and the translator
141 have no control over the position of the link in the sentence. 141 would have no control over the position of the link in the sentence.
142 142
143 However, when you use the Genshi internationalization directives, you simply 143 However, when you use the Genshi internationalization directives, you simply
144 add an ``i18n:msg`` attribute to the enclosing ``<p>`` element: 144 add an ``i18n:msg`` attribute to the enclosing ``<p>`` element:
145 145
146 .. code-block:: genshi 146 .. code-block:: genshi
183 <p> 183 <p>
184 Um Hilfe zu erhalten, besuchen Sie bitte 184 Um Hilfe zu erhalten, besuchen Sie bitte
185 <a href="http://example.com/">Example</a> 185 <a href="http://example.com/">Example</a>
186 </p> 186 </p>
187 187
188 Please note that messages may contain multiple tags, and they may also be 188 Messages may contain multiple tags, and they may also be nested. For example:
189 nested. For example:
190 189
191 .. code-block:: genshi 190 .. code-block:: genshi
192 191
193 <p i18n:msg="name"> 192 <p i18n:msg="name">
194 <i>Please</i> visit <b>the site <a href="${site.url}">${site.name}</a></b> 193 <i>Please</i> visit <b>the site <a href="${site.url}">${site.name}</a></b>
232 translator understand in what context the message will be used: 231 translator understand in what context the message will be used:
233 232
234 .. code-block:: genshi 233 .. code-block:: genshi
235 234
236 <p i18n:msg="name" i18n:comment="Link to the relevant support site"> 235 <p i18n:msg="name" i18n:comment="Link to the relevant support site">
237 Please visit <a href="${site.url}">${site.name}</a> help. 236 Please visit <a href="${site.url}">${site.name}</a> for help.
238 </p> 237 </p>
239 238
240 This comment will be extracted together with the message itself, and will 239 This comment will be extracted together with the message itself, and will
241 commonly be placed along the message in the message catalog, so that it is 240 commonly be placed along the message in the message catalog, so that it is
242 easily visible to the person doing the translation. 241 easily visible to the person doing the translation.
246 245
247 246
248 ------------- 247 -------------
249 Pluralization 248 Pluralization
250 ------------- 249 -------------
250
251 Translatable strings that vary based on some number of objects, such as “You
252 have 1 new message” or “You have 3 new messages”, present their own challenge,
253 in particular when you consider that different languages have different rules
254 for pluralization. For example, while English and most western languages have
255 two plural forms (one for ``n=1`` and one for ``n<>1``), Welsh has five
256 different plural forms, while Hungarian only has one.
257
258 The ``gettext`` framework has long supported this via the ``ngettext()``
259 family of functions. You specify two default messages, one singular and one
260 plural, and the number of items. The translations however may contain any
261 number of plural forms for the message, depending on how many are commonly
262 used in the language. ``ngettext`` will choose the correct plural form of the
263 translated message based on the specified number of items.
264
265 Genshi provides a variant of the ``i18n:msg`` directive described above that
266 allows choosing the proper plural form based on some variable.
251 267
252 ``i18n:choose``, ``i18n:singular``, ``i18n:plural`` 268 ``i18n:choose``, ``i18n:singular``, ``i18n:plural``
253 --------------------------------------------------- 269 ---------------------------------------------------
254 270
255 TODO 271 TODO
Copyright (C) 2012-2017 Edgewall Software