CoreFiles by mySites.guru
text.es674 lines, 1,813 bytes, from Joomla_4.0.0-beta5-Beta-Full_Package.zip
Raw History Compare with 4.0.0-beta4
md5
f439e3e7f845f3d1755c492d7d9a79c8
sha1
2d64d1c261183cdf237469796140287ab21b094d
sha256
0f53f1d3ca7138ed196005f0f69a47ea23e51e02a561beb9170e77750160ad55
/**
 * @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 ? newKey : 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 2 releases, Joomla 4.0.0-beta4 to 4.0.0-beta5. See them all, or every version of this file.