-
Notifications
You must be signed in to change notification settings - Fork 326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add localization override support using custom params #4038
Add localization override support using custom params #4038
Conversation
Using custom params should not be necessary, tweakdefs should be able to override these by setting A widget will need to load the tweakdef values into these two properties, then calling the language API to reload the names. Currently the language widget will reload these when changing languages, it may need to be changed to be able to reload these on demand. For proper modding support, mods can supply their own translation files, and load them by calling |
I think has to be customparams, tweakdefs run in a different lua environment and on a different |
Hey, thanks for the quick reply. I did notice overriding does not work using translatedHumanName. I was discussing the load order in the modding discussion channel. That inspired me to make this change. By loading translations via "Spring.I18N" it required the translations to be distributed to the other players. I found this to be a bit of a nuisance when you can customize nearly everything except unit name in a multiplayer lobby. |
Changed to use a dedicated widget, originally written by @S3KCentrifugal, to support tweakdefs being able to set unit names with custom params. This currently doesn't support changing language, as it only runs once on initialize for whatever the current language happens to be. |
Added support for changing language, but for reasons I have yet to discover, it works for the description but not the name. When I add the following tweakders: VW5pdERlZnNbJ2FybWNvbSddLmN1c3RvbXBhcmFtcy5pMThuX2VuX2h1bWFubmFtZSA9ICJUZXN0IE5hbWUiDQpVbml0RGVmc1snYXJtY29tJ10uY3VzdG9tcGFyYW1zLmkxOG5fZW5fdG9vbHRpcCA9ICJUZXN0IERlc2NyaXB0aW9uIg0KVW5pdERlZnNbJ2FybWNvbSddLmN1c3RvbXBhcmFtcy5pMThuX2ZyX2h1bWFubmFtZSA9ICJMZSBUZXN0IE5vbSINClVuaXREZWZzWydhcm1jb20nXS5jdXN0b21wYXJhbXMuaTE4bl9mcl90b29sdGlwID0gIkxlIFRlc3QgRGVzY3JpcHRpb24i Which is: UnitDefs['armcom'].customparams.i18n_en_humanname = "Test Name"
UnitDefs['armcom'].customparams.i18n_en_tooltip = "Test Description"
UnitDefs['armcom'].customparams.i18n_fr_humanname = "Le Test Nom"
UnitDefs['armcom'].customparams.i18n_fr_tooltip = "Le Test Description" In English it works for both, but when I change to French it works for description but not name. |
Does this affect all GUIs that present names or just some? Could it be a bug in individual widgets not refreshing the UI properly? |
Figured it out, it has to do with the |
Perhaps anything that uses customparam-supplied name should default to english anyway? Nobody writing tweakdefs is going to provide chinese names |
#4038 moved I18N initialization from setupdefs.lua into purely widget space. This broke grid menu, as it was caching its I18N entries outside of callins, so was running before the gui_language widget, even though it is on a higher layer.
#4038 moved running the I18N initialization code for defs from setupdefs.lua into purely widget space. This broke any widgets trying to look up these I18N entries outside of callins, as the code would run before gui_language had a chance to run, despite it being on a lower layer.
Adding support to override localization strings via TweakUnits/TweakDefs.
This is what custom units look like when missing from translations...
This is what custom units look like when using custom param localization...
The use case for this is overriding translated human names and tooltips names via TweakUnits or TweakDefs. In my case I am working on an Evolution mod where eco is removed from the game and many different types of units can evolve(Instead of just commander) and they end up with really ugly names that include the unit namespace.
This proposed change may make the scavenger language code redundant since all the translations can be set via TweakDefs. The same thing may be true for including Evolving commander translations the I8N translations folder. Although there may still be a use case to package translations with the game for mods. I will defer to the mod authors on that.
Here is a sample Tweak Units to test the change...
{ armllt = { customparams = { i18n_en_humanname = "Test Name LLT", i18n_en_tooltip = "Test Tooltip LLT", }, }, }
I've also attached a sample TweakDefs you can use for testing evolving units with custom names.
EvolvesTweakDef2.txt