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 a notice that translation keys must be globally unique #5

Open
fauxnik opened this issue Feb 20, 2024 · 5 comments
Open

Add a notice that translation keys must be globally unique #5

fauxnik opened this issue Feb 20, 2024 · 5 comments

Comments

@fauxnik
Copy link

fauxnik commented Feb 20, 2024

It's not currently clear that translation keys must be globally unique. One could be led to believe by the existence of the sourceId passed to the translations injector that they are somehow namespaced automatically.

@Insprill
Copy link
Member

Is there a reason they aren't namespaced automatically? I think that would be the better solution since creating globally unique keys that don't conflict with any other mods is going to be a never-ending goose chase.

@katycat5e
Copy link
Member

Automatic prefixes introduce issues with any calls to Localize, and especially hardcoded keys in assets - you would need to know what the automatic prefix is in order to set up your keys correctly. I think the notice to modders to add their own prefix is likely the most straightforward solution.

@fauxnik
Copy link
Author

fauxnik commented Feb 22, 2024

Can you say more about the hardcoded keys in assets? Because it's totally possible that the helper could simply proxy the localize method and add the prefix automatically. I made a helper method in my own project to do just that. Depending on how csv/web transition injections are handled, I imagine it'd be possible to add an automatic prefix on the injection side too.

@katycat5e
Copy link
Member

Injection side is easy. But in CCL, we're using base game components that take localization keys and use the built in localize methods. There's no way to differentiate between what keys should be prefixed or not if we were to try to patch the localize method. In other mods you'd have to remember to call the langhelper localize function instead of using the existing system.

@fauxnik
Copy link
Author

fauxnik commented Feb 22, 2024

Yeah, definitely no way to patch the localize method and get it right.

Having to remember to call the right method versus having to remember to prefix all mod keys isn't all that different imo, but the former involves less work for the developer and has a very obvious symptom when it's forgotten, i.e. [missing translation]

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

No branches or pull requests

3 participants