Comments (6)
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.
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.
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.
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.
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.
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)
- Question: Help with a possible async issue HOT 2
- The Settings Application is unable to handle manual wrappers when package ID auto-detection fails. HOT 1
- crash on preexisting world HOT 1
- Allow user to bind arguments when calling libWrapper.register HOT 2
- [BUG] Incompatibility between Settings Extender and libWrapper in V9 HOT 4
- [BUG?] libWrapper: A non-critical error occurred while initializing libWrapper. HOT 4
- [Request] Reduce logging verbosity HOT 5
- [BUG] Malformed log verbosity setting prevents libWrapper initialisation HOT 2
- SW5e: Libwrapper seems to be returning NaN for ability check mod, saving throw mod, AC, Initiative mod, and potentially others. HOT 7
- [CORE ISSUE] libWrapper fails on v10p1 / v10p2 when modules try to register a wrapper HOT 3
- V10 compatibility for module.json HOT 3
- Question re wrapping order HOT 2
- [BUG] HOT 2
- Error-Warnings due to v9 style data access HOT 1
- [BUG] Incorrect error message when calling the libWrapper API before the libWrapper.Ready hook HOT 1
- [BUG] URL to faulty module's page is run-in with following sentence, merging the two HOT 8
- [BUG] HOT 1
- weaponProf variable unassaigned? HOT 1
- [BUG] Info from `Hooks.onError` getting lost HOT 3
- Reword compatibility warnings and improve README to be more user-friendly HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fvtt-lib-wrapper.