Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Made small edits to docs/i18n.txt

git-svn-id: http://code.djangoproject.com/svn/django/trunk@1090 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit e859854d0aa88508cd83f63145c0667434683e6f 1 parent 0588183
Adrian Holovaty authored November 05, 2005

Showing 1 changed file with 27 additions and 15 deletions. Show diff stats Hide diff stats

  1. 42  docs/i18n.txt
42  docs/i18n.txt
@@ -3,12 +3,7 @@ Internationalization
3 3
 ====================
4 4
 
5 5
 Django has full support for internationalization of text in code and templates.
6  
-Here's an overview of how translation works in Django.
7  
-
8  
-.. admonition:: Behind the scenes
9  
-
10  
-    Django's translation machinery uses the standard ``gettext`` module that
11  
-    comes with Python.
  6
+Here's how it works.
12 7
 
13 8
 Overview
14 9
 ========
@@ -40,6 +35,12 @@ How to internationalize your app: in three steps
40 35
        support.
41 36
     3. Activate the locale middleware in your Django settings.
42 37
 
  38
+
  39
+.. admonition:: Behind the scenes
  40
+
  41
+    Django's translation machinery uses the standard ``gettext`` module that
  42
+    comes with Python.
  43
+
43 44
 How to specify translation strings
44 45
 ==================================
45 46
 
@@ -87,6 +88,11 @@ Translation works on variables. Again, here's an identical example::
87 88
         output = _(sentence)
88 89
         return HttpResponse(output)
89 90
 
  91
+(The caveat with using variables or computed values, as in the previous two
  92
+examples, is that Django's translation-string-detecting utility,
  93
+``make-messages.py``, won't be able to find these strings. More on
  94
+``make-messages`` later.)
  95
+
90 96
 The strings you pass to ``_()`` or ``gettext()`` can take placeholders,
91 97
 specified with Python's standard named-string interpolation syntax. Example::
92 98
 
@@ -108,7 +114,7 @@ Marking strings as no-op
108 114
 ~~~~~~~~~~~~~~~~~~~~~~~~
109 115
 
110 116
 Use the function ``django.utils.translation.gettext_noop()`` to mark a string
111  
-as a translate string without translating it. The string is later translated
  117
+as a translation string without translating it. The string is later translated
112 118
 from a variable.
113 119
 
114 120
 Use this if you have constant strings that should be stored in the source
@@ -135,14 +141,14 @@ not the actual translation. The translation itself will be done when the string
135 141
 is used in a string context, such as template rendering on the Django admin site.
136 142
 
137 143
 If you don't like the verbose name ``gettext_lazy``, you can just alias it as
138  
-``_``, like so::
  144
+``_`` (underscore), like so::
139 145
 
140 146
     from django.utils.translation import gettext_lazy as _
141 147
 
142 148
     class MyThing(meta.Model):
143 149
         name = meta.CharField(help_text=_('This is the help text'))
144 150
 
145  
-Always use lazy translations in Django models. And it's a good idea to add
  151
+Always use lazy translations in `Django models`_. And it's a good idea to add
146 152
 translations for the field names and table names, too. This means writing
147 153
 explicit ``verbose_name`` and ``verbose_name_plural`` options in the ``META``
148 154
 class, though::
@@ -155,6 +161,8 @@ class, though::
155 161
             verbose_name = _('my thing')
156 162
             verbose_name_plural = _('mythings')
157 163
 
  164
+.. _Django models: http://www.djangoproject.com/documentation/model_api/
  165
+
158 166
 Pluralization
159 167
 ~~~~~~~~~~~~~
160 168
 
@@ -175,7 +183,7 @@ translation languages as the ``count`` variable).
175 183
 In template code
176 184
 ----------------
177 185
 
178  
-Using translations in Django templates uses two template tags and a slightly
  186
+Using translations in `Django templates`_ uses two template tags and a slightly
179 187
 different syntax than in Python code. To give your template access to these
180 188
 tags, put ``{% load i18n %}`` toward the top of your template.
181 189
 
@@ -240,6 +248,8 @@ translation string. Example::
240 248
 In this case, both the tag and the filter will see the already-translated
241 249
 string, so they don't need to be aware of translations.
242 250
 
  251
+.. _Django templates: http://www.djangoproject.com/documentation/templates_python/
  252
+
243 253
 How to create language files
244 254
 ============================
245 255
 
@@ -262,10 +272,10 @@ To create or update a message file, run this command::
262 272
     bin/make-messages.py -l de
263 273
 
264 274
 ...where ``de`` is the language code for the message file you want to create.
265  
-(The language code, in this case, is in locale format. So, for example, it's
266  
-``pt_BR`` for Brazilian and ``de_AT`` for Austrian German.)
  275
+The language code, in this case, is in locale format. For example, it's
  276
+``pt_BR`` for Brazilian and ``de_AT`` for Austrian German.
267 277
 
268  
-The script should be run from one of three places::
  278
+The script should be run from one of three places:
269 279
 
270 280
     * The root ``django`` directory (not a Subversion checkout, but the one
271 281
       that is linked-to via ``$PYTHONPATH`` or is located somewhere on that
@@ -325,10 +335,12 @@ otherwise, they'll be tacked together without whitespace!
325 335
     When creating a ``.po`` file with your favorite text editor, first edit
326 336
     the charset line (search for ``"CHARSET"``) and set it to the charset
327 337
     you'll be using to edit the content. Generally, utf-8 should work for most
328  
-    languages, but ``gettext`` can handle any charset you throw at it.
  338
+    languages, but ``gettext`` should handle any charset you throw at it.
329 339
 
330 340
 To reexamine all source code and templates for new translation strings and
331  
-update all message files for **all** languages, run ``make-messages.py -a``.
  341
+update all message files for **all** languages, run this::
  342
+
  343
+    make-messages.py -a
332 344
 
333 345
 Compiling message files
334 346
 -----------------------

0 notes on commit e859854

Please sign in to comment.
Something went wrong with that request. Please try again.