index.txt 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 is controlled by the :setting:`USE_I18N` setting. However, it
  41. involves internationalization and localization. The name of the setting is
  42. an unfortunate result of Django's history.
  43. Here are some other terms that will help us to handle a common language:
  44. .. glossary::
  45. locale name
  46. A locale name, either a language specification of the form ``ll`` or a
  47. combined language and country specification of the form ``ll_CC``.
  48. Examples: ``it``, ``de_AT``, ``es``, ``pt_BR``, ``sr_Latn``. The language
  49. part is always in lowercase. The country part is in titlecase if it has
  50. more than 2 characters, otherwise it's in uppercase. The separator is an
  51. underscore.
  52. language code
  53. Represents the name of a language. Browsers send the names of the
  54. languages they accept in the ``Accept-Language`` HTTP header using this
  55. format. Examples: ``it``, ``de-at``, ``es``, ``pt-br``. Language codes
  56. are generally represented in lowercase, but the HTTP ``Accept-Language``
  57. header is case-insensitive. The separator is a dash.
  58. message file
  59. A message file is a plain-text file, representing a single language,
  60. that contains all available :term:`translation strings
  61. <translation string>` and how they should be represented in the given
  62. language. Message files have a ``.po`` file extension.
  63. translation string
  64. A literal that can be translated.
  65. format file
  66. A format file is a Python module that defines the data formats for a given
  67. locale.