Code Monkey home page Code Monkey logo

Comments (6)

BlueSkyBlackBird avatar BlueSkyBlackBird commented on June 10, 2024 1

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.

from fvtt-lib-wrapper.

BlueSkyBlackBird avatar BlueSkyBlackBird commented on June 10, 2024 1

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

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

from fvtt-lib-wrapper.

ruipin avatar ruipin commented on June 10, 2024

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.

from fvtt-lib-wrapper.

ruipin avatar ruipin commented on June 10, 2024

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.

from fvtt-lib-wrapper.

ruipin avatar ruipin commented on June 10, 2024

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

from fvtt-lib-wrapper.

ruipin avatar ruipin commented on June 10, 2024

This is now implemented in v1.10.0.0.

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

from fvtt-lib-wrapper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.