a JTranslationBundle object
if bundle is invalid or already defined
// Supported locales can be retrieved by calling JMap.Language.getLocales()
const bundle = {
id: "my-custom-bundle-id",
defaultLocale: "fr",
translationsByLocale: {
"fr" : {
"my-custom-key": "Ceci est ma traduction personnalisée en français"
},
"en" : {
"my-custom-key": "This is my custom translation in English"
}
}
}
JMap.Language.addBundle(bundle)
JMap.Language.setLocale("fr")
let params = {key: "my-custom-key", bundleId: "my-custom-bundle-id"}
console.log(JMap.Language.translate(params))
// "Ceci est ma traduction personnalisée en français"
JMap.Language.addBundle
This method lets you add your own translations into JMap Server NG translation engine (for instance, all translations needed for one of your extensions)
Once added, a bundle cannot be overriden, and its identity must be unique (its id). You can specify a default locale for your bundle, in wich case the JMap Server NG translation engine will fall back to your bundle's default locale instead of on the system's default locale if a translation is not found in your bundle for the current locale.