internationalizing_games.rst 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 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_importing_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. > 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>`,
  36. etc. 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 :ref:`Object.tr() <class_Object_tr>`
  44. function can be used. This will just look-up the text into the
  45. translations and convert it if found:
  46. ::
  47. level.set_text(tr("LEVEL_5_NAME"))
  48. status.set_text(tr("GAME_STATUS_" + str(status_index)))
  49. Making controls resizeable
  50. --------------------------
  51. The same text in different languages can vary greatly in length. For
  52. this, make sure to read the tutorial on :ref:`doc_size_and_anchors`, as having
  53. dynamically adjusted control sizes may help.
  54. :ref:`Container <class_Container>` can be very useful, as well as the multiple options in
  55. :ref:`Label <class_Label>` for text wrapping.
  56. TranslationServer
  57. -----------------
  58. Godot has a server for handling the low level translation management
  59. called the :ref:`TranslationServer <class_TranslationServer>`.
  60. Translations can be added or removed during run-time, and the current
  61. language be changed too.
  62. Command line
  63. ------------
  64. Language can be tested when running Godot from command line. For
  65. example, to test a game in french, the following arguments can be
  66. supplied:
  67. ::
  68. c:\MyGame> godot -lang fr
  69. Translating the project name
  70. ----------------------------
  71. The project name becomes the app name when exporting to different
  72. operating systems and platforms. To specify the project name in more
  73. than one language, create a new setting application/name in the project
  74. settings dialog and append the locale identifier to it. For example:
  75. .. image:: /img/localized_name.png
  76. As always, If you don't know the code of a language or zone, :ref:`check the
  77. list <doc_locales>`.