localization_using_spreadsheets.rst 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. Formatting
  8. ----------
  9. CSV files must be formatted as follows:
  10. +--------+----------+----------+----------+
  11. | keys | <lang1> | <lang2> | <langN> |
  12. +========+==========+==========+==========+
  13. | KEY1 | string | string | string |
  14. +--------+----------+----------+----------+
  15. | KEY2 | string | string | string |
  16. +--------+----------+----------+----------+
  17. | KEYN | string | string | string |
  18. +--------+----------+----------+----------+
  19. The "lang" tags must represent a language, which must be one of the :ref:`valid
  20. locales <doc_locales>` supported by the engine, or they must start with an underscore (`_`),
  21. which means the related column is served as comment and won't be imported.
  22. The "KEY" tags must be unique and represent a string universally (they are usually in
  23. uppercase, to differentiate from other strings). These keys will be replaced at
  24. runtime by the matching translated string. Note that the case is important,
  25. "KEY1" and "Key1" will be different keys.
  26. The top-left cell is ignored and can be left empty or having any content.
  27. Here's an example:
  28. +-------+-----------------------+------------------------+------------------------------+
  29. | keys | en | es | ja |
  30. +=======+=======================+========================+==============================+
  31. | GREET | Hello, friend! | Hola, amigo! | こんにちは |
  32. +-------+-----------------------+------------------------+------------------------------+
  33. | ASK | How are you? | Cómo está? | 元気ですか |
  34. +-------+-----------------------+------------------------+------------------------------+
  35. | BYE | Goodbye | Adiós | さようなら |
  36. +-------+-----------------------+------------------------+------------------------------+
  37. | QUOTE | "Hello" said the man. | "Hola" dijo el hombre. | 「こんにちは」男は言いました |
  38. +-------+-----------------------+------------------------+------------------------------+
  39. The same example is shown below as a comma-separated plain text file,
  40. which should be the result of editing the above in a spreadsheet.
  41. When editing the plain text version, be sure to enclose with double
  42. quotes any message that contains commas, line breaks or double quotes,
  43. so that commas are not parsed as delimiters, line breaks don't create new
  44. entries and double quotes are not parsed as enclosing characters. Be sure
  45. to escape any double quotes a message may contain by preceding them with
  46. another double quote. Alternatively, you can select another delimiter than
  47. comma in the import options.
  48. .. code-block:: none
  49. keys,en,es,ja
  50. GREET,"Hello, friend!","Hola, amigo!",こんにちは
  51. ASK,How are you?,Cómo está?,元気ですか
  52. BYE,Goodbye,Adiós,さようなら
  53. QUOTE,"""Hello"" said the man.","""Hola"" dijo el hombre.",「こんにちは」男は言いました
  54. CSV importer
  55. ------------
  56. Godot will treat CSV files as translations by default. It will import them
  57. and generate one or more compressed translation resource files next to it.
  58. Importing will also add the translation to the list of
  59. translations to load when the game runs, specified in project.godot (or the
  60. project settings). Godot allows loading and removing translations at
  61. runtime as well.
  62. Select the ``.csv`` file and access the **Import** dock to define import
  63. options. You can toggle the compression of the imported translations, and
  64. select the delimiter to use when parsing the CSV file.
  65. .. image:: img/import_csv.webp
  66. Be sure to click **Reimport** after any change to these options.