space-commits / SPT-Realism-Mod-Client

Client-side BepInEx patches for SPTRM: https://hub.sp-tarkov.com/files/file/606-spt-realism-mod/#versions
Other
52 stars 13 forks source link

[Enhancement] [Question] Adding a construction for translation into other languages #53

Closed MolunSIB closed 6 months ago

MolunSIB commented 7 months ago

[Enhancement] [Question]

Should we expect such a feature to appear? Let's say the "locales" directory with a file listing all string names of parametrs, say in json format, which, conditionally, is en.json, cz.json, ru.json etc.

I have already partially translated for myself, but I have to compare files with the update, because it is impossible to remember where and when I changed the translation.

And so it would be possible to gradually make the translation. There is no necessary translation for the parameter yet - it is used from the en version.

space-commits commented 7 months ago

If someone is willing to write it in a sensible maintainable way and make a PR I'd be willing to add translations

MolunSIB commented 7 months ago

image For example, in this screenshot, you can see that you can pass this string as a variable. Therefore, you can try to use the JSON construction to generate the translation. I would help in writing this, but unfortunately I don't know much about UNITY. But I know that, say, in the settings of sptlauncher there are indications of the language code. This can be used to determine the desired translation. Next, load the JSON file with the text, write it into a variable in the dictionary, and then use the keys to insert the desired line.

For example:

{
"en": 
         {
                  "canttakepills":"Can't Take Pills, Mouth Is Blocked By Faceshield/NVGs/Mask. Toggle Off Faceshield/NVG Or Remove Mask/Headgear"
         },
"ru":
         {
                  "canttakepills": "Невозможно принять таблетки, рот заблокирован защитным стеклом/ПНВ/маской. Поднимите защитное стекло/ПНВ или снять маску/головной убор"
         }
}

Perhaps I didn't quite understand you.

 json = ImportJsonLikeDict(); // Shown from above
 Lang = ImportLangFromSPTSettings(); // str "en"
 if (Plugin.GearBlocksHeal.Value && medType.Contains("pills") && (mouthBlocked || fsIsON || nvgIsOn))
                    {
                        NotificationManagerClass.DisplayWarningNotification(jsonLangText[Lang]["canttakepills"], EFT.Communications.ENotificationDurationType.Long);
                        return false;
                    }
MolunSIB commented 7 months ago

It’s just that later it will be much more labor-intensive to translate to a similar design; perhaps there are more ideal ones on the Internet than what I proposed.

space-commits commented 6 months ago

I understand in principle how to implement translations, but I unfortunately do not have the free time to implement and maintain such a system. It'd need to be done for the client, server and config GUI. If someone is willing to fork these projects, make the required changes, and PR them, then I can have a look and implement translations.