Move all "edit.js" functions into Modules
Create new repository to track these
This commit is contained in:
34
src/utils/l10nTranslation.mjs
Normal file
34
src/utils/l10nTranslation.mjs
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
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__
|
||||
Reference in New Issue
Block a user