Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #5495 -- Made some organization / spelling / grammar changes to…

… docs/i18n.txt. Thanks, Axis_of_Entropy

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6294 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit b7e90a0abd59e55f1ba2ef5686bc0fe2da903149 1 parent 7b172de
Adrian Holovaty authored September 15, 2007

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

  1. 136  docs/i18n.txt
136  docs/i18n.txt
@@ -27,21 +27,8 @@ Essentially, Django does two things:
27 27
     * It uses these hooks to translate Web apps for particular users according
28 28
       to their language preferences.
29 29
 
30  
-How to internationalize your app: in three steps
31  
-------------------------------------------------
32  
-
33  
-    1. Embed translation strings in your Python code and templates.
34  
-    2. Get translations for those strings, in whichever languages you want to
35  
-       support.
36  
-    3. Activate the locale middleware in your Django settings.
37  
-
38  
-.. admonition:: Behind the scenes
39  
-
40  
-    Django's translation machinery uses the standard ``gettext`` module that
41  
-    comes with Python.
42  
-
43  
-If you don't need internationalization
44  
-======================================
  30
+If you don't need internationalization in your app
  31
+==================================================
45 32
 
46 33
 Django's internationalization hooks are on by default, and that means there's a
47 34
 bit of i18n-related overhead in certain places of the framework. If you don't
@@ -55,8 +42,21 @@ from your ``TEMPLATE_CONTEXT_PROCESSORS`` setting.
55 42
 
56 43
 .. _documentation for USE_I18N: ../settings/#use-i18n
57 44
 
58  
-How to specify translation strings
59  
-==================================
  45
+If you do need internationalization: three steps
  46
+================================================
  47
+
  48
+    1. Embed translation strings in your Python code and templates.
  49
+    2. Get translations for those strings, in whichever languages you want to
  50
+       support.
  51
+    3. Activate the locale middleware in your Django settings.
  52
+
  53
+.. admonition:: Behind the scenes
  54
+
  55
+    Django's translation machinery uses the standard ``gettext`` module that
  56
+    comes with Python.
  57
+
  58
+1. How to specify translation strings
  59
+=====================================
60 60
 
61 61
 Translation strings specify "This text should be translated." These strings can
62 62
 appear in your Python code and templates. It's your responsibility to mark
@@ -295,7 +295,7 @@ string, so they don't need to be aware of translations.
295 295
 .. _Django templates: ../templates_python/
296 296
 
297 297
 Working with lazy translation objects
298  
-=====================================
  298
+-------------------------------------
299 299
 
300 300
 Using ``ugettext_lazy()`` and ``ungettext_lazy()`` to mark strings in models
301 301
 and utility functions is a common operation. When you're working with these
@@ -305,7 +305,7 @@ convert them to strings, because they should be converted as late as possible
305 305
 couple of helper functions.
306 306
 
307 307
 Joining strings: string_concat()
308  
---------------------------------
  308
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
309 309
 
310 310
 Standard Python string joins (``''.join([...])``) will not work on lists
311 311
 containing lazy translation objects. Instead, you can use
@@ -324,7 +324,7 @@ strings when ``result`` itself is used in a string (usually at template
324 324
 rendering time).
325 325
 
326 326
 The allow_lazy() decorator
327  
---------------------------
  327
+~~~~~~~~~~~~~~~~~~~~~~~~~~
328 328
 
329 329
 Django offers many utility functions (particularly in ``django.utils``) that
330 330
 take a string as their first argument and do something to that string. These
@@ -359,8 +359,8 @@ Using this decorator means you can write your function and assume that the
359 359
 input is a proper string, then add support for lazy translation objects at the
360 360
 end.
361 361
 
362  
-How to create language files
363  
-============================
  362
+2. How to create language files
  363
+===============================
364 364
 
365 365
 Once you've tagged your strings for later translation, you need to write (or
366 366
 obtain) the language translations themselves. Here's how that works.
@@ -393,7 +393,7 @@ To create or update a message file, run this command::
393 393
 
394 394
 ...where ``de`` is the language code for the message file you want to create.
395 395
 The language code, in this case, is in locale format. For example, it's
396  
-``pt_BR`` for Brazilian Portugese and ``de_AT`` for Austrian German.
  396
+``pt_BR`` for Brazilian Portuguese and ``de_AT`` for Austrian German.
397 397
 
398 398
 The script should be run from one of three places:
399 399
 
@@ -490,8 +490,8 @@ That's it. Your translations are ready for use.
490 490
 
491 491
     .. _Submitting and maintaining translations: ../contributing/
492 492
 
493  
-How Django discovers language preference
494  
-========================================
  493
+3. How Django discovers language preference
  494
+===========================================
495 495
 
496 496
 Once you've prepared your translations -- or, if you just want to use the
497 497
 translations that come with Django -- you'll just need to activate translation
@@ -546,7 +546,7 @@ following this algorithm:
546 546
 Notes:
547 547
 
548 548
     * In each of these places, the language preference is expected to be in the
549  
-      standard language format, as a string. For example, Brazilian Portugese
  549
+      standard language format, as a string. For example, Brazilian Portuguese
550 550
       is ``pt-br``.
551 551
     * If a base language is available but the sublanguage specified is not,
552 552
       Django uses the base language. For example, if a user specifies ``de-at``
@@ -629,44 +629,6 @@ in ``request.LANGUAGE_CODE``.
629 629
 .. _session: ../sessions/
630 630
 .. _request object: ../request_response/#httprequest-objects
631 631
 
632  
-The ``set_language`` redirect view
633  
-==================================
634  
-
635  
-As a convenience, Django comes with a view, ``django.views.i18n.set_language``,
636  
-that sets a user's language preference and redirects back to the previous page.
637  
-
638  
-Activate this view by adding the following line to your URLconf::
639  
-
640  
-    (r'^i18n/', include('django.conf.urls.i18n')),
641  
-
642  
-(Note that this example makes the view available at ``/i18n/setlang/``.)
643  
-
644  
-The view expects to be called via the ``POST`` method, with a ``language``
645  
-parameter set in request. If session support is enabled, the view
646  
-saves the language choice in the user's session. Otherwise, it saves the
647  
-language choice in a ``django_language`` cookie.
648  
-
649  
-After setting the language choice, Django redirects the user, following this
650  
-algorithm:
651  
-
652  
-    * Django looks for a ``next`` parameter in ``POST`` request.
653  
-    * If that doesn't exist, or is empty, Django tries the URL in the
654  
-      ``Referer`` header.
655  
-    * If that's empty -- say, if a user's browser suppresses that header --
656  
-      then the user will be redirected to ``/`` (the site root) as a fallback.
657  
-
658  
-Here's example HTML template code::
659  
-
660  
-    <form action="/i18n/setlang/" method="post">
661  
-    <input name="next" type="hidden" value="/next/page/" />
662  
-    <select name="language">
663  
-    {% for lang in LANGUAGES %}
664  
-    <option value="{{ lang.0 }}">{{ lang.1 }}</option>
665  
-    {% endfor %}
666  
-    </select>
667  
-    <input type="submit" value="Go" />
668  
-    </form>
669  
-
670 632
 Using translations in your own projects
671 633
 =======================================
672 634
 
@@ -728,6 +690,44 @@ The easiest way out is to store applications that are not part of the project
728 690
 connected to your explicit project and not strings that are distributed
729 691
 independently.
730 692
 
  693
+The ``set_language`` redirect view
  694
+==================================
  695
+
  696
+As a convenience, Django comes with a view, ``django.views.i18n.set_language``,
  697
+that sets a user's language preference and redirects back to the previous page.
  698
+
  699
+Activate this view by adding the following line to your URLconf::
  700
+
  701
+    (r'^i18n/', include('django.conf.urls.i18n')),
  702
+
  703
+(Note that this example makes the view available at ``/i18n/setlang/``.)
  704
+
  705
+The view expects to be called via the ``POST`` method, with a ``language``
  706
+parameter set in request. If session support is enabled, the view
  707
+saves the language choice in the user's session. Otherwise, it saves the
  708
+language choice in a ``django_language`` cookie.
  709
+
  710
+After setting the language choice, Django redirects the user, following this
  711
+algorithm:
  712
+
  713
+    * Django looks for a ``next`` parameter in ``POST`` request.
  714
+    * If that doesn't exist, or is empty, Django tries the URL in the
  715
+      ``Referrer`` header.
  716
+    * If that's empty -- say, if a user's browser suppresses that header --
  717
+      then the user will be redirected to ``/`` (the site root) as a fallback.
  718
+
  719
+Here's example HTML template code::
  720
+
  721
+    <form action="/i18n/setlang/" method="post">
  722
+    <input name="next" type="hidden" value="/next/page/" />
  723
+    <select name="language">
  724
+    {% for lang in LANGUAGES %}
  725
+    <option value="{{ lang.0 }}">{{ lang.1 }}</option>
  726
+    {% endfor %}
  727
+    </select>
  728
+    <input type="submit" value="Go" />
  729
+    </form>
  730
+
731 731
 Translations and JavaScript
732 732
 ===========================
733 733
 
@@ -827,13 +827,13 @@ This would create or update the translation catalog for JavaScript for German.
827 827
 After updating translation catalogs, just run ``compile-messages.py`` the same
828 828
 way as you do with normal Django translation catalogs.
829 829
 
830  
-Specialities of Django translation
  830
+Specialties of Django translation
831 831
 ==================================
832 832
 
833  
-If you know ``gettext``, you might note these specialities in the way Django
  833
+If you know ``gettext``, you might note these specialties in the way Django
834 834
 does translation:
835 835
 
836  
-    * The string domain is ``django`` or ``djangojs``. The string domain is
  836
+    * The string domain is ``django`` or ``djangojs``. This string domain is
837 837
       used to differentiate between different programs that store their data
838 838
       in a common message-file library (usually ``/usr/share/locale/``). The
839 839
       ``django`` domain is used for python and template translation strings
@@ -841,5 +841,5 @@ does translation:
841 841
       domain is only used for JavaScript translation catalogs to make sure
842 842
       that those are as small as possible.
843 843
     * Django doesn't use ``xgettext`` alone. It uses Python wrappers around
844  
-      ``xgettext`` and ``msgfmt``. That's mostly for convenience.
  844
+      ``xgettext`` and ``msgfmt``. This is mostly for convenience.
845 845
 

0 notes on commit b7e90a0

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