localization_using_spreadsheets.rst 4.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. .. _doc_localization_using_spreadsheets:
  2. Localization using spreadsheets
  3. ===============================
  4. Spreadsheets are one of the most common formats for localizing games.
  5. In Godot, spreadsheets are supported through the CSV format. This
  6. guide explains how to work with CSVs.
  7. The CSV files **must** be saved with UTF-8 encoding
  8. without a `byte order mark <https://en.wikipedia.org/wiki/Byte_order_mark>`__.
  9. .. warning::
  10. By default, Microsoft Excel will always save CSV files with ANSI encoding
  11. rather than UTF-8. There is no built-in way to do this, but there are
  12. workarounds as described
  13. `here <https://stackoverflow.com/questions/4221176/excel-to-csv-with-utf8-encoding>`__.
  14. We recommend using `LibreOffice <https://www.libreoffice.org/>`__ or Google Sheets instead.
  15. Formatting
  16. ----------
  17. CSV files must be formatted as follows:
  18. +--------+----------+----------+----------+
  19. | keys | <lang1> | <lang2> | <langN> |
  20. +========+==========+==========+==========+
  21. | KEY1 | string | string | string |
  22. +--------+----------+----------+----------+
  23. | KEY2 | string | string | string |
  24. +--------+----------+----------+----------+
  25. | KEYN | string | string | string |
  26. +--------+----------+----------+----------+
  27. The "lang" tags must represent a language, which must be one of the :ref:`valid
  28. locales <doc_locales>` supported by the engine, or they must start with an underscore (`_`),
  29. which means the related column is served as comment and won't be imported.
  30. The "KEY" tags must be unique and represent a string universally (they are usually in
  31. uppercase, to differentiate from other strings). These keys will be replaced at
  32. runtime by the matching translated string. Note that the case is important,
  33. "KEY1" and "Key1" will be different keys.
  34. The top-left cell is ignored and can be left empty or having any content.
  35. Here's an example:
  36. +-------+-----------------------+------------------------+------------------------------+
  37. | keys | en | es | ja |
  38. +=======+=======================+========================+==============================+
  39. | GREET | Hello, friend! | Hola, amigo! | こんにちは |
  40. +-------+-----------------------+------------------------+------------------------------+
  41. | ASK | How are you? | Cómo está? | 元気ですか |
  42. +-------+-----------------------+------------------------+------------------------------+
  43. | BYE | Goodbye | Adiós | さようなら |
  44. +-------+-----------------------+------------------------+------------------------------+
  45. | QUOTE | "Hello" said the man. | "Hola" dijo el hombre. | 「こんにちは」男は言いました |
  46. +-------+-----------------------+------------------------+------------------------------+
  47. The same example is shown below as a comma-separated plain text file,
  48. which should be the result of editing the above in a spreadsheet.
  49. When editing the plain text version, be sure to enclose with double
  50. quotes any message that contains commas, line breaks or double quotes,
  51. so that commas are not parsed as delimiters, line breaks don't create new
  52. entries and double quotes are not parsed as enclosing characters. Be sure
  53. to escape any double quotes a message may contain by preceding them with
  54. another double quote. Alternatively, you can select another delimiter than
  55. comma in the import options.
  56. .. code-block:: none
  57. keys,en,es,ja
  58. GREET,"Hello, friend!","Hola, amigo!",こんにちは
  59. ASK,How are you?,Cómo está?,元気ですか
  60. BYE,Goodbye,Adiós,さようなら
  61. QUOTE,"""Hello"" said the man.","""Hola"" dijo el hombre.",「こんにちは」男は言いました
  62. CSV importer
  63. ------------
  64. Godot will treat CSV files as translations by default. It will import them
  65. and generate one or more compressed translation resource files next to it.
  66. Importing will also add the translation to the list of
  67. translations to load when the game runs, specified in project.godot (or the
  68. project settings). Godot allows loading and removing translations at
  69. runtime as well.
  70. Select the ``.csv`` file and access the **Import** dock to define import
  71. options. You can toggle the compression of the imported translations, and
  72. select the delimiter to use when parsing the CSV file.
  73. .. image:: img/import_csv.webp
  74. Be sure to click **Reimport** after any change to these options.