Ticket #11714: 11714-r12454.diff

File 11714-r12454.diff, 4.3 KB (added by Ramiro Morales, 15 years ago)

Patch updated to post i18n docs refactor plus some typos.

  • docs/howto/i18n.txt

    diff --git a/docs/howto/i18n.txt b/docs/howto/i18n.txt
    a b  
    7070``django-admin.py makemessages`` on the project level will only translate
    7171strings that are connected to your explicit project and not strings that are
    7272distributed independently.
     73
     74Using translations outside views and templates
     75==============================================
     76
     77While Django provides a rich set of i18n tools for use in views and templates,
     78it does not restrict the usage to Django-specific code. The Django translation
     79mechanisms can be used to translate arbitrary texts to any language that is
     80supported by Django (as long as an appropriate translation catalog exists, of
     81course). You can load translation catalog, activate it and translate text to
     82language of your choice, but remember to switch back to original language, as
     83activating translation catalog is done in per-thread basis and such change
     84will affect code running in the same thread.
     85
     86For example::
     87
     88    from django.utils import translation
     89    def welcome_translated(language):
     90        cur_language = translation.get_language()
     91        try:
     92            translation.activate(language)
     93            text = translation.ugettext('welcome')
     94        finally:
     95            translation.activate(cur_language)
     96        return text
     97
     98Calling this function with argument 'de' will give you ``"wilkommen"``,
     99regardless of :setting:`LANGUAGE_CODE` and language set by middleware.
     100
     101Function of particular interest are ``django.utils.translation.get_language()``
     102which returns language used in current thread, and
     103``django.utils.translation.activate()`` which activates translation catalog for
     104current thread. Other useful function is
     105``django.utils.translation.check_for_language()`` checks if language is
     106supported by Django.
  • docs/topics/i18n/index.txt

    diff --git a/docs/topics/i18n/index.txt b/docs/topics/i18n/index.txt
    a b  
    1818      to their language preferences.
    1919
    2020The complete process can be seen as divided in three stages. It is also possible
    21 to identify an identical number of roles with very well defined responsabilities
     21to identify an identical number of roles with very well defined responsibilities
    2222associated with each of these tasks (although it's perfectly normal if you
    2323find yourself performing more than one of these roles):
    2424
    25     * For applicacion authors wishing to make sure their Django apps can be
     25    * For application authors wishing to make sure their Django apps can be
    2626      used in different locales: :ref:`topics-i18n-internationalization`.
    2727    * For translators wanting to translate Django apps: :ref:`topics-i18n-localization`.
    2828    * For system administrators/final users setting up internationalized apps or
  • docs/topics/i18n/localization.txt

    diff --git a/docs/topics/i18n/localization.txt b/docs/topics/i18n/localization.txt
    a b  
    237237.. _mirrors: http://ftp.gnome.org/pub/GNOME/MIRRORS
    238238
    239239You may also use ``gettext`` binaries you have obtained elsewhere, so long as
    240 the ``xgettext --version`` command works properly. Some version 0.14.4 binaries
    241 have been found to not support this command. Do not attempt to use Django
     240the ``xgettext --version`` command works properly. Do not attempt to use Django
    242241translation utilities with a ``gettext`` package if the command ``xgettext
    243242--version`` entered at a Windows command prompt causes a popup window saying
    244243"xgettext.exe has generated errors and will be closed by Windows".
     
    248247Format localization
    249248===================
    250249
    251 Django's formatting system is disabled by default. To enable it, it's necessay
     250Django's formatting system is disabled by default. To enable it, it's necessary
    252251to set :setting:`USE_L10N = True <USE_L10N>` in your settings file.
    253252
    254253When using Django's formatting system, dates and numbers on templates will be
     
    271270
    272271To use custom formats, first thing to do, is to specify the path where you'll
    273272place format files. To do that, just set your :setting:`FORMAT_MODULE_PATH`
    274 setting to the the path (in the format ``'foo.bar.baz``) where format files
     273setting to the path (in the format ``'foo.bar.baz``) where format files
    275274will exists.
    276275
    277276Files are not placed directly in this directory, but in a directory named as
Back to Top