pseudolocalization.rst 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. .. _doc_pseudolocalization:
  2. Pseudolocalization
  3. ==================
  4. Introduction
  5. ------------
  6. When creating a game, the process of localization usually starts when development
  7. has finished. This means that translations aren't available during development
  8. for testing whether the project is internationalized properly.
  9. Godot offers pseudolocalization as a way to test how robust the project is
  10. when it comes to locale changes. Pseudolocalization simulates changes that
  11. might take place during localization. This way, any issues regarding
  12. internationalization can be recognized early on during development.
  13. .. seealso::
  14. You can see how pseudolocalization works in action using the
  15. `Pseudolocalizaton demo project <https://github.com/godotengine/godot-demo-projects/tree/master/gui/pseudolocalization>`__.
  16. Enabling and configuring pseudolocalization
  17. -------------------------------------------
  18. Enabling pseudolocalization and the configurations related to it is as simple as
  19. toggling a checkbox in the project settings. These settings can be found in
  20. **Project → Project Settings → General → Internationalization → Pseudolocalization**
  21. after enabling the **Advanced** toggle in the project settings dialog:
  22. .. image:: img/pseudolocalization_settings.webp
  23. Pseudolocalization can also be :ref:`toggled at runtime from a script <doc_pseudolocalization_runtime>`.
  24. Pseudolocalization configurations
  25. ---------------------------------
  26. Pseudolocalization in Godot can be set up according to the specific use case of the
  27. project. Here are the pseudolocalization properties that can be configured through
  28. project settings:
  29. - ``replace_with_accents``: Replaces all characters in the string with their accented
  30. variants. *"The quick brown fox jumped over the lazy dog"* will be converted to
  31. *"Ŧh̀é q́üíćḱ ḅŕôŵή f́ôx́ ǰüm̀ṕéd́ ôṽéŕ ŧh̀é łáźý d́ôǵ"* when this setting is enabled.
  32. This can be used to spot untranslated strings that won't have accents,
  33. but is also useful to check for missing glyphs in the font(s) used by the project.
  34. - ``double_vowels``: Doubles all the vowels in the string. It is a good approximation
  35. to simulate expansion of text during localization.
  36. This can be used to check for text that would overflow its container
  37. (such as buttons).
  38. - ``fake_bidi``: Fake bidirectional text (simulates right-to-left text). This is useful to
  39. simulate right-to-left writing systems to check for potential layout issues that would occur in languages using right-to-left scripts.
  40. - ``override``: Replaces all the characters in the string with an asterisk (``*``). This is useful for
  41. quickly finding text that isn't being localized.
  42. - ``expansion_ratio``: Can be used in cases where doubling the vowels isn't a sufficient
  43. approximation. This setting pads the string with underscores (``_``) and expands it by the given ratio.
  44. An expansion ratio of ``0.3`` is sufficient for most practical cases; it will increase
  45. the length of the string by 30%.
  46. - ``prefix`` and ``suffix``: These properties can be used to specify a prefix and suffix to wrap
  47. the text in.
  48. - ``skip_placeholders``: Skips placeholders for string formatting like ``%s`` and ``%f``.
  49. This is useful to identify places where more arguments are required for the formatted
  50. string to display correctly.
  51. All of these properties can be toggled as needed according to the project's use case.
  52. .. _doc_pseudolocalization_runtime:
  53. Configuring pseudolocalization at runtime
  54. -----------------------------------------
  55. Pseudolocalization can be toggled at runtime using the
  56. :ref:`pseudolocalization_enabled<class_TranslationServer_property_pseudolocalization_enabled>` property
  57. in TranslationServer.
  58. However, if runtime configuration of pseudolocalization properties is required,
  59. they can be directly configured using
  60. :ref:`ProjectSettings.set_setting(property, value) <class_ProjectSettings_method_set_setting>`
  61. and then calling
  62. :ref:`TranslationServer.reload_pseudolocalization() <class_TranslationServer_method_reload_pseudolocalization>`
  63. which reparses the pseudolocalization properties and reloads the pseudolocalization.
  64. The following code snippet shall turn on ``replace_with_accents`` and ``double_vowels`` properties
  65. and then call ``reload_pseudolocalization()`` for the changes to get reflected::
  66. ProjectSettings.set_setting("internationalization/pseudolocalization/replace_with_accents", true)
  67. ProjectSettings.set_setting("internationalization/pseudolocalization/double_vowels", true)
  68. TranslationServer.reload_pseudolocalization()