importing_translations.rst 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 multi-language text.
  15. There are two approaches to generate multi language games and
  16. applications. Both are based on a key:value system. The first is to use
  17. one of the languages as 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 to revise the text while it's being translated
  24. to others. the unique ID can be a number, a string, or a string with a
  25. number (it's just a unique string anyway).
  26. Translators also, most of the time prefer to work with spreadsheets
  27. (either as a Microsoft Excel file or a shared Google Spreadsheet).
  28. Translation format
  29. ------------------
  30. To complete the picture and allow efficient support for translations,
  31. Godot has a special importer that can read .csv files. Both Microsoft
  32. Excel and Google Spreadsheet can export to this format, so the only
  33. requirement is that the files have a special format. The csv files must
  34. be saved in utf-8 encoding and the format is 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, it must be one of the `valid
  45. locales <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 esta? | 元気ですか |
  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 that 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 to load and remove translations at
  69. runtime, too.