Skip to content
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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

S3KCentrifugal
Copy link

Adding support to override localization strings via TweakUnits/TweakDefs.

This is what custom units look like when missing from translations...
SampleWithoutCodeChange

This is what custom units look like when using custom param localization...
SampleWithCodeChange

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

@WatchTheFort WatchTheFort marked this pull request as draft December 19, 2024 00:39
@WatchTheFort
Copy link
Member

Using custom params should not be necessary, tweakdefs should be able to override these by setting translatedHumanName and translatedTooltip directly. Currently that doesn't happen because tweakdefs are loaded before this widget runs, so the values end up getting overwritten.

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 Spring.I18N.loadFile. Entries in them will overwrite base game entries.

@sprunk
Copy link
Collaborator

sprunk commented Dec 19, 2024

Using custom params should not be necessary, tweakdefs should be able to override these by setting translatedHumanName and translatedTooltip directly. Currently that doesn't happen because tweakdefs are loaded before this widget runs, so the values end up getting overwritten.

I think has to be customparams, tweakdefs run in a different lua environment and on a different UnitDefs table (they are just named the same, see beyond-all-reason/spring#1039). The first UnitDefs table is passed through engine and the only non-engine-native thing that survives intact is customparams.

@S3KCentrifugal
Copy link
Author

S3KCentrifugal commented Dec 19, 2024

Using custom params should not be necessary, tweakdefs should be able to override these by setting translatedHumanName and translatedTooltip directly. Currently that doesn't happen because tweakdefs are loaded before this widget runs, so the values end up getting overwritten.

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 Spring.I18N.loadFile. Entries in them will overwrite base game entries.

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.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants