- md5
- a95712a1603a70619ca8c27aa4f0f0f6
- sha1
- 36302fb946b7a187d2dbb12687689ce720fbea04
- sha256
- b773b6e8c1cbda8c387cabdcdfb4326bfcfb7ef59e307c9e677118890547374f
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
/**
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
/**
* Joomla! Text related functions
*
* @since 4.0.0
*/
((window, Joomla) => {
'use strict';
/**
* Custom behavior for JavaScript I18N in Joomla! 1.6
*
* @type {{}}
*
* Allows you to call Joomla.Text._() to get a translated JavaScript string
* pushed in with Text::script() in Joomla.
*/
Joomla.Text = {
strings: {},
/**
* Translates a string into the current language.
*
* @param {String} key The string to translate
* @param {String} def Default string
*
* @returns {String}
*/
_: (key, def) => {
let newKey = key;
let newDef = def;
// Check for new strings in the optionsStorage, and load them
const newStrings = Joomla.getOptions('joomla.jtext');
if (newStrings) {
Joomla.Text.load(newStrings);
// Clean up the optionsStorage from useless data
Joomla.loadOptions({ 'joomla.jtext': null });
}
newDef = newDef === undefined ? '' : newDef;
newKey = newKey.toUpperCase();
return Joomla.Text.strings[newKey] !== undefined ? Joomla.Text.strings[newKey] : newDef;
},
/**
* Load new strings in to Joomla.Text
*
* @param {Object} object Object with new strings
* @returns {Joomla.Text}
*/
load: (object) => {
[].slice.call(Object.keys(object)).forEach((key) => {
Joomla.Text.strings[key.toUpperCase()] = object[key];
});
return Joomla.Text;
},
};
/**
* For B/C we still support Joomla.JText
*
* @type {{}}
*
* @deprecated 5.0
*/
Joomla.JText = Joomla.Text;
})(window, Joomla);
The same content is in 3 releases, Joomla 4.0.0-beta to 4.0.0-beta3. See them all, or every version of this file.