IO5 / KspConstellations

MIT License
1 stars 3 forks source link

Localization support #6

Open zhangyuesai opened 2 weeks ago

zhangyuesai commented 2 weeks ago

Hi! I've always wanted to play with some in-depth satellite missions. Thank you for this contract pack!

I'm planning to provide a Chinese translation for the contracts, and it would be a lot easier (not just for me, for other potential languages, too) if you could add localization support. I can do that myself; but it involves a little refractoring and I don't want to mess up your code (eg. maybe you have a preferred naming convention).

Would it be convenient for you to add localization support?

IO5 commented 1 week ago

Hi, sorry for the late reply.

Well, localization is something I wanted to add, but not before there was any interest in a translation (clearly that's the case now 😄). After looking into it though, I'm not sure how well the Contract Configurator supports localization. Skimming through some other contract packs I don't see any of them to be localized despite the CC being localized itself.

Do you have any examples on how to go about it?

zhangyuesai commented 1 week ago

I made a localization demo in my fork, with Agents, Groups and two contracts (LKOSatellite and MKOSatellite) localized.

Localization support of contract packs should be no different than localization support of other community mods:

  1. In each file in the contract pack (agents, groups, contracts, etc.), substitute each string that needs to be translated with a variable starting with #.
  2. Create a subdirectory GameData/Localization, and a file GameData/Localization/en-us.cfg.
  3. In en-us.cfg, define all variables with their original English text.
  4. Now translators can use en-us.cfg as a template to create their <language.cfg>, where their translation are added (eg. zh-cn.cfg for Chinese.)
  5. If you're making changes to the contract pack, you only need to add/update variables in your files and add/update their definition in en-us.cfg. Any variable not defined in other <language.cfg> will fallback to English, so you don't need to worry about maintaining other languages.