godotengine / godot-docs

Godot Engine official documentation
https://docs.godotengine.org
Other
3.78k stars 3.07k forks source link

Better explanation for translation contexts / multiple translation files #9661

Open stephanbogner opened 1 month ago

stephanbogner commented 1 month ago

Your Godot version:

Godot v4.2.2.stable - macOS 14.5.0 - Vulkan (Forward+) - integrated Apple M2 Pro - Apple M2 Pro (10 Threads)

Issue description:

  1. I have two CSV-files to separate work cleanly:

characters.csv:

key,en,de
hero,"Spider Man", "Spinnenmann"

translations.csv:

key,en,de
hero,"Hero","Held"
  1. From reading the docs I had expected that the context refers to different CSV-files, but that doesn't seem to be the case
  2. Expectation:
    • tr("hero", "characters") = Spider Man
    • tr("hero", "translations") = Hero
  3. Reality: Both return Spider Man
  4. So my question is: What is meant by "context"? Are multiple translation files even supported?
  5. PS: It also took me quite a while to get that you have to add the translations manually (even though that's stated in the docs) because they were generated automatically

URL to the documentation page (if already existing):

AThousandShips commented 1 month ago

This is how the contexts are handled https://docs.godotengine.org/en/latest/tutorials/i18n/localization_using_gettext.html#manual-creation

It is not based on multiple files, this should be made more clear as it's not explicitly stated

stephanbogner commented 1 month ago

Ah! So that means contexts doesn‘t apply to CSV?

AThousandShips commented 1 month ago

Doesn't seem like it supports it, instead you should use gettext (as hinted in the import page), should maybe be more clearly indicated elsewhere like it is with plurals in the first page

stephanbogner commented 1 month ago

Thanks for the explanations @AThousandShips. If I find the time and once I understand localization in Godot better I'll try to make a PR regarding this. I now also tried gettext, but it's overkill for our project, so I'll dive deeper in the CSV aspect :)