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 #44

Closed
BlueSkyBlackBird opened this issue Jul 8, 2021 · 6 comments
Closed

Add localization #44

BlueSkyBlackBird opened this issue Jul 8, 2021 · 6 comments
Labels
enhancement New feature or request localization Involves translations / localizations

Comments

@BlueSkyBlackBird
Copy link

Is your feature request related to a problem, e.g. with a module? Please describe.
Currently there is no way to localize text for other languages. All settings of libWrapper are displayed in English invariant of what the games language is set to. This can be problematic for people that are not fluent in the English language.

Describe the solution you'd like
Implement foundries default solution for translation using the i18n framework. Specify translation and keys in dedicated files, each containing the translation for a specific local.

Describe alternatives you've considered
There really is no alternative. It would simple improve accessibility for the user.

Additional context
I do understand why libWrapper itself does not prioritize translations, however I would still emphasize that the amount of work to localize the project is minimal and actual translations can be done by the community.

@BlueSkyBlackBird BlueSkyBlackBird added the enhancement New feature or request label Jul 8, 2021
@ruipin
Copy link
Owner

ruipin commented Jul 8, 2021

Thanks for the feature request.

You're right, this is something I have considered in the past, but as a library my focus so far has been in getting the core functionality up and running, so I wasn't too worried about localisation.

I agree that this module has gotten to a point where localisation is indeed worth pursuing. I will need to look into the i18n framework (haven't really done anything with it before).

Do you by any chance have any examples that I can reference? Otherwise I'll see if I can ask around on Discord.

@BlueSkyBlackBird
Copy link
Author

https://gitlab.com/woodentavern/foundryvtt-bar-brawl

In the module.json you specify the language files They are usually under module/lang

"languages": [
    {
      "lang": "de",
      "name": "Deutsch",
      "path": "lang/de.json"
    },
    {
      "lang": "en",
      "name": "English",
      "path": "lang/en.json"
    }
  ],

All you then need to do is in the code reference the key in the json so: game.i18n.localize("libwrapper.settings.example"):

The content of the lang files would look like this:

{
 "libwrapper": {
   "settings": {
      "example": "This is the button text",
      "exampleHint": "This is the hint to what the button actually does",
   }
  }
}

Its pretty simple, the rest will foundry manage for you.

@ruipin
Copy link
Owner

ruipin commented Jul 8, 2021

Sounds good, thanks!

What happens if a key doesn't exist for a particular language (e.g. I added new text to the english json, but didn't update the translations since I can't speak those languages), I assume it just takes the english translation?

And what about Handlebars, is there a helper there or are we expected to write {{game.i18n.localize('xyz')}} everywhere?

Anyway, my current plan is to pursue this after (or at the same time as) I find the time to clean up more of #42 since that will trigger multiple changes to the messages output by libWrapper.

@BlueSkyBlackBird
Copy link
Author

if there is no key available it should fallback to the default (EN) language.

handlebars has a helper {{ localize "libwrapper.settings.example" }}

@ruipin ruipin added the localization Involves translations / localizations label Jul 8, 2021
@ruipin
Copy link
Owner

ruipin commented Jul 8, 2021

Adding to this ticket so I have it all tracked in the same place.

The Foundry VTT documentation has this page: https://foundryvtt.com/article/localization/
The Foundry localization API is documented in: https://foundryvtt.com/api/Localization.html

@ruipin
Copy link
Owner

ruipin commented Aug 26, 2021

This is now implemented in v1.10.0.0.

See the english JSON file. Contributions for other languages are welcome.

@ruipin ruipin closed this as completed Aug 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request localization Involves translations / localizations
Projects
None yet
Development

No branches or pull requests

2 participants