internationalizing_games.rst 3.7 KB

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