internationalizing_a_game.rst 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. .. _doc_internationalizing_a_game:
  2. Internationalization
  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 very 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_import_translations` tutorial, so this
  17. one could be seen more like a follow up to that one.
  18. Configuring the Imported Translation
  19. ------------------------------------
  20. The translations can get updated and re-imported when they change, but
  21. they still have to be added to the project. This is done in Scene
  22. [STRIKEOUT:> Project Settings]> Localization:
  23. .. image:: /img/localization_dialog.png
  24. This dialog allows to add or remove translations project-wide.
  25. Localizing Resources
  26. --------------------
  27. It is also possible to instruct Godot to open alternative versions of
  28. assets (resources) depending on the current language. For this the
  29. "Remaps" tab exists:
  30. .. image:: /img/localization_remaps.png
  31. Select the resource to be remapped, and the alternatives for each
  32. locale.
  33. Converting Keys to Text
  34. -----------------------
  35. Some controls such as :ref:`Button <class_Button>`, :ref:`Label <class_Label>`, etc.
  36. will automatically fetch a translation each time they are set a key
  37. instead of a text. For example, if a label is assigned
  38. "MAIN\_SCREEN\_GREETING1" and a key to different languages exists in the
  39. translations, this will be automatically converted. This process is done
  40. upon load though, so if the project in question has a dialog that allows
  41. changing the language in the settings, the scenes (or at least the
  42. settings scene) will have to be re-loaded for new text to have effect.
  43. For code, the
  44. :ref:`Object.tr() <class_Object_tr>`
  45. function can be used. This will just look-up the text into the
  46. translations and convert it if found:
  47. ::
  48. level.set_text(tr("LEVEL_5_NAME"))
  49. status.set_text(tr("GAME_STATUS_"+str(status_index)))
  50. Making Controls Resizeable
  51. --------------------------
  52. The same text in different languages can vary greatly in length. For
  53. this, make sure to read the tutorial on :ref:`doc_size_and_anchors`, as having
  54. dynamically adjusted control sizes may help.
  55. :ref:`Containers <class_Containers>`
  56. can be very useful, as well as the multiple options in
  57. :ref:`Label <class_Label>` for
  58. text wrapping.
  59. TranslationServer
  60. -----------------
  61. Godot has a server for handling the low level translation management
  62. called the
  63. :ref:`TranslationServer <class_TranslationServer>`.
  64. Translations can be added or removed during run-time, and the current
  65. language be changed too.
  66. Command Line
  67. ------------
  68. Language can be tested when running Godot from command line. For
  69. example, to test a game in french, the following arguments can be
  70. supplied:
  71. .. raw:: html
  72. </pre>
  73. c:\\\\MyGame> godot -lang fr
  74. .. raw:: html
  75. </pre>
  76. Translating the Project Name
  77. ----------------------------
  78. The project name becomes the app name when exporting to different
  79. operating systems and platforms. To specify the project name in more
  80. than one language. In the project settings dialog, create a new setting
  81. application/name and append it the locale identifier. For example:
  82. .. image:: /img/localized_name.png
  83. As always, If you don't know the code of a language or zone, `check the
  84. list <https://github.com/okamstudio/godot/wiki/locales>`__.