cataclysmbnteam / Cataclysm-BN

Cataclysm: Bright Nights, A fork/variant of Cataclysm:DDA by CleverRaven.
https://docs.cataclysmbn.org
Other
704 stars 273 forks source link

Prioritize active mod translation files over base game language file? #1142

Open vorpal-void opened 3 years ago

vorpal-void commented 3 years ago

Is your feature request related to a problem? Please describe.

Mod translations issue, pretty minor in my case but who knows?

For example I'll take psychiclysm: there we have starting profession called "Awakened", but at the same time base game localization files have profession with exact same name, which refers to obsoleted mod more_classes_scenarios. While using psychiclysm with compiled translation files it still uses original translation from base game .po file (ru_RU in that case) and here we have little stupid situation: either psychiclysm ignores provided translation in it's own compiled file, or after de-obsoleting more_classes_scenarios we will end up with two professions named exactly the same but having different description on them. "SCEN_ONLY" for said profession does nothing but prevent them both to be shown near each other.

Describe the solution you'd like

The one in the tittle seems like something would work, although it'll break things more than it fix? I don't know; same mod for example - right now it takes monster names from it's strings and they are translated automatically since they are already in base game translation, but with implemented suggestion translators will need to translate ALL the strings all the time (not a big deal), and keep them synchronized between translated mods (real deal since tracking context is way harder than it seems).

Describe alternatives you've considered

Change the name of said profession in psychiclysm - this will require changing Original Mod profession name, and that's would be somewhat good since entire situation will be valid even without any translation involved, but see additional context below. And this is just an example - who knows where else would we stuck upon same issue outside of character creation screen? Perhaps some other solution would fit here - I'm not very good with game code to grasp all possible alternatives. Separating mod strings from main language .po files would help too I guess, but I'm not even sure if that possible.

Additional context

ru_RU "Awakened" in context of psychiclysm would be "Пробуждённый" as in "woke up to the cosmos", and more_classes_scenarios have "Разбуженный" as "woke up because there is noise", BOTH are correct and have different meanings in combination with their descriptions, but Big Main .po have absolute priority in that question it seems. For now cosmos-altered mind expander will be called the same as someone who just fell out of bed, if only it would be that easy.

Bonus

"SCEN_ONLY" flag removed for double frustration. изображение

olanti-p commented 3 years ago

ru_RU "Awakened" in context of psychiclysm would be "Пробуждённый" as in "woke up to the cosmos", and more_classes_scenarios have "Разбуженный" as "woke up because there is noise", BOTH are correct and have different meanings in combination with their descriptions

For cases like this, gettext translation system allows specifying translation context.

Example from BN's ru_RU.po (version fe46d089e824818734a77583ec6f54d7d213ff62):

#: data/json/items/melee/spears_and_polearms.json
msgctxt "weapon"
msgid "pike"
msgid_plural "pikes"
msgstr[0] "пика"
msgstr[1] "пики"
msgstr[2] "пик"
msgstr[3] "пики"

#: data/json/monsters/fish.json
msgctxt "fish"
msgid "pike"
msgid_plural "pikes"
msgstr[0] "щука"
msgstr[1] "щуки"
msgstr[2] "щук"
msgstr[3] "щуки"

Same pike means different things in different contexts, and translation context field msgctxt allows to provide correct translations for both cases.

The game has been using gettext (and, since #505, a gettext-compatible system) for a long time, but only relatively recently it received support for specifying translation context for JSON data files (docs, original PR: https://github.com/CleverRaven/Cataclysm-DDA/pull/26402). Some JSON fields are still not supported (this can be considered a bug and requires c++ changes to fix), but many are, for example item and monster names:

{
    "id": "pike",
    "type": "GENERIC",
    "category": "weapons",
    "name": { "ctxt": "weapon", "str": "pike" },
    "description": "This is a medieval weapon consisting of a wood shaft tipped with an iron spearhead.",
    "weight": "2500 g",
    "volume": "3500 ml",
    "price": 40000,
    "price_postapoc": 5000,
    "bashing": 9,
    "cutting": 32,
    "material": [ "iron", "wood" ],
    "symbol": "/",
    "color": "brown",
    "techniques": [ "IMPALE", "WBLOCK_1" ],
    "qualities": [ [ "COOK", 1 ] ],
    "flags": [ "DURABLE_MELEE", "POLEARM", "SPEAR", "REACH_ATTACK", "REACH3", "NONCONDUCTIVE", "SHEATH_SPEAR", "ALWAYS_TWOHAND" ]
  }
{
    "id": "mon_fish_pike",
    "type": "MONSTER",
    "copy-from": "mon_fish_large",
    "name": { "ctxt": "fish", "str": "pike" },
    "aggression": 10,
    "melee_skill": 3,
    "melee_dice_sides": 6,
    "melee_cut": 4,
    "description": "A northern pike.  Pike can be a pretty aggressive fish, careful around those teeth."
  }

That said - unfortunately, profession names and descriptions fall under "JSON fields that don't support translation context" category, although they use it internally to distinguish male and female variants. I've added the support in #1147, once it's merged you should be able to fix the issue by renaming Psychiclysm's profession as

    "name": { "str": "Awakened", "ctxt": "To the cosmos" }

Regarding the "prioritize active mod translation files over base game language file" part: the base game file is prioritized by default because it is assumed that base game's PO is as correct as possible, while mods may accidentally add the same string in their PO files with incorrect translation or incorrect context. Then there is also the issue of same string being correctly, but differently, translated in different mods, and as you've mentioned it'd be a nightmare to keep synchronized.

Splitting base game's PO into several files (UI & core code, base game JSONs, in-repo mods) is definitely something we (mostly translators) want, but it's not very high on the TODO list.