diff --git a/doc/JSON_INFO.md b/doc/JSON_INFO.md index 381939dec1b74..fe8f77e4dbcfa 100644 --- a/doc/JSON_INFO.md +++ b/doc/JSON_INFO.md @@ -460,6 +460,21 @@ order of the entries does not matter. Currently, only some JSON values support this syntax (see [here](/doc/TRANSLATING.md#translation) for a list of supported values and more detailed explanation). +The string extractor will extract all encountered strings from JSON for translation. But if some string should not be translated, such as text that is not normally visible to the player (names and descriptions of monster-only effects and spells), then you can write `"NO_I18N"` in the comment for translators: + +```JSON +"name": { + "//~": "NO_I18N", + "str": "Fake Monster-Only Spell" +}, +"description": { + "//~": "NO_I18N", + "str": "Fake Monster-Only Spell Description" +} +``` + +The extractor will skip these two specified strings and only these, extracting the remaining unmarked strings from the same JSON object. + ## Comments JSON has no intrinsic support for comments. However, by convention in CDDA diff --git a/doc/TRANSLATING.md b/doc/TRANSLATING.md index c5dacc4c2fb49..4b98f2e07640d 100644 --- a/doc/TRANSLATING.md +++ b/doc/TRANSLATING.md @@ -312,6 +312,16 @@ you also need to update `extract_json_strings.py` and run `lang/update_pot.sh` to ensure that the strings are correctly extracted for translation, and run the unit test to fix text styling issues reported by the `translation` class. +If a string doesn't need to be translated, you can write `"NO_I18N"` in the +`"//~"` comment, and this string will not be available to translators (see [here](/doc/JSON_INFO.md#translatable-strings)): + +```JSON +"name": { + "//~": "NO_I18N", + "str": "Fake Monster-Only Spell" +} +``` + ### Static string variables Translation functions should not be called when initializing a static variable. diff --git a/lang/string_extractor/write_text.py b/lang/string_extractor/write_text.py index 3d03518e1a638..a0277cc36d803 100644 --- a/lang/string_extractor/write_text.py +++ b/lang/string_extractor/write_text.py @@ -53,7 +53,7 @@ def write_text(json, origin, context="", comment="", else: text_plural = "{}s".format(text) - if not text: + if not text or "NO_I18N" in comments: return format_tag = ""