internationalizing_games.rst 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. .. _doc_internationalizing_games:
  2. Internationalizing games
  3. ========================
  4. Introduction
  5. ------------
  6. Sería excelente que el mundo hablara solo un idioma (It would be great if the
  7. world spoke only one language). Unfortunately for
  8. us developers, that is not the case. While indie or niche games usually
  9. do not need localization, games targeting a more massive market
  10. often require localization. Godot offers many tools to make this process
  11. more straightforward, so this tutorial is more like a collection of
  12. tips and tricks.
  13. Localization is usually done by specific studios hired for the job and,
  14. despite the huge amount of software and file formats available for this,
  15. the most common way to do localization to this day is still with
  16. spreadsheets. The process of creating the spreadsheets and importing
  17. them is already covered in the :ref:`doc_importing_translations` tutorial,
  18. so this one could be seen more like a follow-up to that one.
  19. .. note:: We will be using the official demo as an example; you can
  20. `download it from the Asset Library <https://godotengine.org/asset-library/asset/134>`_.
  21. Configuring the imported translation
  22. ------------------------------------
  23. Translations can get updated and re-imported when they change, but
  24. they still have to be added to the project. This is done in
  25. **Project → Project Settings → Localization**:
  26. .. image:: img/localization_dialog.png
  27. The above dialog is used to add or remove translations project-wide.
  28. Localizing resources
  29. --------------------
  30. It is also possible to instruct Godot to use alternate versions of
  31. assets (resources) depending on the current language. The **Remaps** tab
  32. can be used for this:
  33. .. image:: img/localization_remaps.png
  34. Select the resource to be remapped, then add some alternatives for each
  35. locale.
  36. Converting keys to text
  37. -----------------------
  38. Some controls, such as :ref:`Button <class_Button>` and :ref:`Label <class_Label>`,
  39. will automatically fetch a translation if their text matches a translation key.
  40. For example, if a label's text is "MAIN_SCREEN_GREETING1" and that key exists
  41. in the current translation, then the text will automatically be translated.
  42. In code, the :ref:`Object.tr() <class_Object_method_tr>`
  43. function can be used. This will just look up the text in the
  44. translations and convert it if found:
  45. ::
  46. level.set_text(tr("LEVEL_5_NAME"))
  47. status.set_text(tr("GAME_STATUS_" + str(status_index)))
  48. Making controls resizable
  49. --------------------------
  50. The same text in different languages can vary greatly in length. For
  51. this, make sure to read the tutorial on :ref:`doc_size_and_anchors`, as
  52. dynamically adjusting control sizes may help.
  53. :ref:`Container <class_Container>` can be useful, as well as the text wrapping
  54. options available in :ref:`Label <class_Label>`.
  55. TranslationServer
  56. -----------------
  57. Godot has a server handling low-level translation management
  58. called the :ref:`TranslationServer <class_TranslationServer>`.
  59. Translations can be added or removed during run-time;
  60. the current language can also be changed at run-time.
  61. Command line
  62. ------------
  63. Language can be tested when running Godot from the command line.
  64. For example, to test a game in French, the following argument can be
  65. supplied:
  66. ::
  67. godot --language fr
  68. Translating the project name
  69. ----------------------------
  70. The project name becomes the app name when exporting to different
  71. operating systems and platforms. To specify the project name in more
  72. than one language, create a new setting ``application/name`` in the **Project
  73. Settings** and append the locale identifier to it.
  74. For instance, for Spanish, this would be ``application/name_es``:
  75. .. image:: img/localized_name.png
  76. If you are unsure about the language code to use, refer to the
  77. :ref:`list of locale codes <doc_locales>`.