importing_translations.rst 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. Translators also usually prefer to work with spreadsheets.
  27. Translation format
  28. ------------------
  29. To complete the picture and allow efficient support for translations,
  30. Godot has a special importer that can read CSV files. All spreadsheet
  31. editors (be it Libreoffice, Microsoft Office, Google Docs, etc.) can
  32. export to this format, so the only requirement is that the files have
  33. a special arrangement. The CSV files must be saved in UTF-8 encoding
  34. and be formatted as follows:
  35. +--------+----------+----------+----------+
  36. | | <lang1> | <lang2> | <langN> |
  37. +========+==========+==========+==========+
  38. | KEY1 | string | string | string |
  39. +--------+----------+----------+----------+
  40. | KEY2 | string | string | string |
  41. +--------+----------+----------+----------+
  42. | KEYN | string | string | string |
  43. +--------+----------+----------+----------+
  44. The "lang" tags must represent a language, which must be one of the :ref:`valid
  45. locales <doc_locales>` supported by the engine. The "KEY" tags must be
  46. unique and represent a string universally (they are usually in
  47. uppercase, to differentiate from other strings). Here's an example:
  48. +---------+------------------+----------------+--------------+
  49. | id | en | es | ja |
  50. +=========+==================+================+==============+
  51. | GREET | Hello, friend! | Hola, Amigo! | こんにちは |
  52. +---------+------------------+----------------+--------------+
  53. | ASK | How are you? | Cómo está? | 元気ですか |
  54. +---------+------------------+----------------+--------------+
  55. | BYE | Good Bye | Adiós | さようなら |
  56. +---------+------------------+----------------+--------------+
  57. Import dialog
  58. -------------
  59. The import dialog takes a CSV file in the previously described format
  60. and generates several compressed translation resource files inside the
  61. project.
  62. Selecting a CSV file autodetects the languages from the first row and
  63. determines which column represents which language. It is possible to
  64. change this manually, by selecting the language for each column.
  65. .. image:: /img/trans.png
  66. The import dialog also can add the translation to the list of
  67. translations to load when the game runs, specified in engine.cfg (or the
  68. project properties). Godot allows loading and removing translations at
  69. runtime as well.