Skip to content

Commit

Permalink
Merge pull request #76198 from Uwuewsky/no-i18n
Browse files Browse the repository at this point in the history
Marking strings as untranslatable
  • Loading branch information
Maleclypse authored Sep 25, 2024
2 parents bfe325a + 472b628 commit e1f0bff
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
15 changes: 15 additions & 0 deletions doc/JSON_INFO.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions doc/TRANSLATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lang/string_extractor/write_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down

0 comments on commit e1f0bff

Please sign in to comment.