importing_translations.rst 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. .. _doc_importing_translations:
  2. Importing translations
  3. ======================
  4. Games and internationalization
  5. ------------------------------
  6. The world is full of different markets and cultures and, to maximize
  7. profits™, nowadays games are released in several languages. To solve
  8. this, internationalized text must be supported in any modern game
  9. engine.
  10. In regular desktop or mobile applications, internationalized text is
  11. usually located in resource files (or .po files for GNU stuff). Games,
  12. however, can use several orders of magnitude more text than
  13. applications, so they must support efficient methods for dealing with
  14. loads of multilingual text.
  15. There are two approaches to generate multilingual language games and
  16. applications. Both are based on a key:value system. The first is to use
  17. one of the languages as the key (usually English), the second is to use a
  18. specific identifier. The first approach is probably easier for
  19. development if a game is released first in English, later in other
  20. languages, but a complete nightmare if working with many languages at
  21. the same time.
  22. In general, games use the second approach and a unique ID is used for
  23. each string. This allows you to revise the text while it is being
  24. translated to other languages. The unique ID can be a number, a string,
  25. or a string with a number (it's just a unique string anyway).
  26. .. note:: If you need a more powerful file format, Godot also supports
  27. loading translations written in the gettext ``.po`` format. See
  28. :ref:`doc_localization_using_gettext` for details.
  29. Translation format
  30. ------------------
  31. To complete the picture and allow efficient support for translations,
  32. Godot has a special importer that can read CSV files. All spreadsheet
  33. editors (be it Libreoffice, Microsoft Office, Google Docs, etc.) can
  34. export to this format, so the only requirement is that the files have
  35. a special arrangement. The CSV files must be saved in UTF-8 encoding
  36. and be formatted as follows:
  37. +--------+----------+----------+----------+
  38. | | <lang1> | <lang2> | <langN> |
  39. +========+==========+==========+==========+
  40. | KEY1 | string | string | string |
  41. +--------+----------+----------+----------+
  42. | KEY2 | string | string | string |
  43. +--------+----------+----------+----------+
  44. | KEYN | string | string | string |
  45. +--------+----------+----------+----------+
  46. The "lang" tags must represent a language, which must be one of the :ref:`valid
  47. locales <doc_locales>` supported by the engine. The "KEY" tags must be
  48. unique and represent a string universally (they are usually in
  49. uppercase, to differentiate from other strings). Here's an example:
  50. +---------+------------------+----------------+--------------+
  51. | id | en | es | ja |
  52. +=========+==================+================+==============+
  53. | GREET | Hello, friend! | Hola, Amigo! | こんにちは |
  54. +---------+------------------+----------------+--------------+
  55. | ASK | How are you? | Cómo está? | 元気ですか |
  56. +---------+------------------+----------------+--------------+
  57. | BYE | Good Bye | Adiós | さようなら |
  58. +---------+------------------+----------------+--------------+
  59. CSV importer
  60. ------------
  61. Godot will treat CSV files as translations by default. It will import them
  62. and generate one or more compressed translation resource files next to it.
  63. Importing will also add the translation to the list of
  64. translations to load when the game runs, specified in project.godot (or the
  65. project settings). Godot allows loading and removing translations at
  66. runtime as well.