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

Allow overriding translations #48

Open
rayz1065 opened this issue Jul 10, 2024 · 4 comments
Open

Allow overriding translations #48

rayz1065 opened this issue Jul 10, 2024 · 4 comments

Comments

@rayz1065
Copy link
Member

For some use-cases it would be useful to have the ability to override certain translations programmatically, for example by loading multiple translation files before loading the default translations.

This is currently not possible since the matchBundles in src/fluent.ts only allows matching a single bundle per locale.

Current behavior

  • the default locale is en
  • bot tries to translate "hi" into locale it;
  • "hi" is not present in the override file;
  • bot falls back to the default bundle with locale en.

Desired behavior

What I would like to happen is for the bot to first try finding the translation in the other files of locale it.
Adding this behavior only requires changing how bundles are matched. It also does not break any test, as having multiple bundles for a single locale was previously unsupported.

@KnorpelSenf
Copy link
Member

This sounds like what you really want is to specify one locale in several files that all get merged. In other words, you want to split up the translation strings into several files per language. Is that correct?

@rayz1065
Copy link
Member Author

That would be the ideal behavior, but it would require properly handling warnings for messages missing in locales. I have a few ideas of how this could be implemented (for example firing the warning only when all the bundles for a locale have been exhausted) but I would like to hear your opinions about it.

@EdJoPaTo
Copy link
Member

Shouldn't the file handling and translation be separate? At least for my bots I read in all the fluent files at startup and translations then should be handled independently of the file system.

Before the rewrite to fluent this library used to check for a translation until there is one (user settings until default). Not sure how exactly the current implementation behaves.

@rayz1065
Copy link
Member Author

Shouldn't the file handling and translation be separate

Yes sorry I was a bit imprecise with my words, I meant to say that I would like the plugin to first iterate through all the bundles (not files) of the same locale before falling back to the default bundle.

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 a pull request may close this issue.

3 participants