@@ -78,6 +78,9 @@ top-right corner, then specify the path to the output file. This file can be
7878placed anywhere in the project directory, but it's recommended to keep it in a
7979subdirectory such as ``locale ``, as each locale will be defined in its own file.
8080
81+ See :ref: `below <doc_localization_using_gettext_gdscript >` for how to add comments for translators
82+ or exclude some strings from being added to the PO template for GDScript files.
83+
8184You can then move over to
8285:ref: `creating a messages file from a PO template <doc_localization_using_gettext_messages_file >`.
8386
@@ -226,3 +229,39 @@ wish to decompile an MO file into a text-based PO file, you can do so with:
226229
227230 The decompiled file will not include comments or fuzzy strings, as these are
228231never compiled in the MO file in the first place.
232+
233+ .. _doc_localization_using_gettext_gdscript :
234+
235+ Extracting localizable strings from GDScript files
236+ --------------------------------------------------
237+
238+ The built-in `editor plugin <https://github.com/godotengine/godot/blob/master/modules/gdscript/editor/gdscript_translation_parser_plugin.h >`_
239+ recognizes a variety of patterns in source code to extract localizable strings
240+ from GDScript files, including but not limited to the following:
241+
242+ - ``tr() ``, ``tr_n() ``, ``atr() ``, and ``atr_n() `` calls;
243+ - assigning properties ``text ``, ``placeholder_text ``, and ``tooltip_text ``;
244+ - ``add_tab() ``, ``add_item() ``, ``set_tab_title() ``, and other calls;
245+ - ``FileDialog `` filters like ``"*.png ; PNG Images" ``.
246+
247+ .. note ::
248+
249+ The argument or right operand must be a constant string, otherwise the plugin
250+ will not be able to evaluate the expression and will ignore it.
251+
252+ If the plugin extracts unnecessary strings, you can ignore them with the ``NO_TRANSLATE `` comment.
253+ You can also provide additional information for translators using the ``TRANSLATORS: `` comment.
254+ These comments must be placed either on the same line as the recognized pattern or precede it.
255+
256+ ::
257+
258+ $CharacterName.text = "???" # NO_TRANSLATE
259+
260+ # NO_TRANSLATE: Language name.
261+ $TabContainer.set_tab_title(0, "Python")
262+
263+ item.text = "Tool" # TRANSLATORS: Up to 10 characters.
264+
265+ # TRANSLATORS: This is a reference to Lewis Carroll's poem "Jabberwocky",
266+ # make sure to keep this as it is important to the plot.
267+ say(tr("He took his vorpal sword in hand. The end?"))
0 commit comments