index.txt 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. =====================================
  2. Internationalization and localization
  3. =====================================
  4. .. toctree::
  5. :hidden:
  6. :maxdepth: 1
  7. translation
  8. formatting
  9. timezones
  10. Overview
  11. ========
  12. The goal of internationalization and localization is to allow a single web
  13. application to offer its content in languages and formats tailored to the
  14. audience.
  15. Django has full support for :doc:`translation of text
  16. </topics/i18n/translation>`, :doc:`formatting of dates, times and numbers
  17. </topics/i18n/formatting>`, and :doc:`time zones </topics/i18n/timezones>`.
  18. Essentially, Django does two things:
  19. * It allows developers and template authors to specify which parts of their apps
  20. should be translated or formatted for local languages and cultures.
  21. * It uses these hooks to localize web apps for particular users according to
  22. their preferences.
  23. Translation depends on the target language, and formatting usually depends on
  24. the target country. This information is provided by browsers in the
  25. ``Accept-Language`` header. However, the time zone isn't readily available.
  26. Definitions
  27. ===========
  28. The words "internationalization" and "localization" often cause confusion;
  29. here's a simplified definition:
  30. .. glossary::
  31. internationalization
  32. Preparing the software for localization. Usually done by developers.
  33. localization
  34. Writing the translations and local formats. Usually done by translators.
  35. More details can be found in the `W3C Web Internationalization FAQ`_, the `Wikipedia article`_ or the `GNU gettext documentation`_.
  36. .. _W3C Web Internationalization FAQ: https://www.w3.org/International/questions/qa-i18n
  37. .. _GNU gettext documentation: https://www.gnu.org/software/gettext/manual/gettext.html#Concepts
  38. .. _Wikipedia article: https://en.wikipedia.org/wiki/Internationalization_and_localization
  39. .. warning::
  40. Translation and formatting are controlled by :setting:`USE_I18N` and
  41. :setting:`USE_L10N` settings respectively. However, both features involve
  42. internationalization and localization. The names of the settings are an
  43. unfortunate result of Django's history.
  44. Here are some other terms that will help us to handle a common language:
  45. .. glossary::
  46. locale name
  47. A locale name, either a language specification of the form ``ll`` or a
  48. combined language and country specification of the form ``ll_CC``.
  49. Examples: ``it``, ``de_AT``, ``es``, ``pt_BR``, ``sr_Latn``. The language
  50. part is always in lowercase. The country part is in titlecase if it has
  51. more than 2 characters, otherwise it's in uppercase. The separator is an
  52. underscore.
  53. language code
  54. Represents the name of a language. Browsers send the names of the
  55. languages they accept in the ``Accept-Language`` HTTP header using this
  56. format. Examples: ``it``, ``de-at``, ``es``, ``pt-br``. Language codes
  57. are generally represented in lowercase, but the HTTP ``Accept-Language``
  58. header is case-insensitive. The separator is a dash.
  59. message file
  60. A message file is a plain-text file, representing a single language,
  61. that contains all available :term:`translation strings
  62. <translation string>` and how they should be represented in the given
  63. language. Message files have a ``.po`` file extension.
  64. translation string
  65. A literal that can be translated.
  66. format file
  67. A format file is a Python module that defines the data formats for a given
  68. locale.