35 lines
677 B
JavaScript
35 lines
677 B
JavaScript
/*
|
|
Description: Translation call
|
|
Date: 2025//3/6
|
|
Creator: Clemens Schwaighofer
|
|
*/
|
|
|
|
export { l10nTranslation };
|
|
import { isObject } from './JavaScriptHelpers.mjs';
|
|
|
|
class l10nTranslation {
|
|
|
|
#i18n = {};
|
|
|
|
constructor(i18n) {
|
|
this.#i18n = i18n;
|
|
|
|
}
|
|
/**
|
|
* uses the i18n object created in the translation template
|
|
* that is filled from gettext in PHP
|
|
* @param {String} string text to translate
|
|
* @return {String} translated text (based on PHP selected language)
|
|
*/
|
|
__(string)
|
|
{
|
|
if (typeof this.#i18n !== 'undefined' && isObject(this.#i18n) && this.#i18n[string]) {
|
|
return this.#i18n[string];
|
|
} else {
|
|
return string;
|
|
}
|
|
}
|
|
}
|
|
|
|
// __END__
|