@enact/i18n
Version:
Internationalization support for Enact using iLib
52 lines (49 loc) • 1.24 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.$L = $L;
exports["default"] = void 0;
exports.toIString = toIString;
require("../src/glue");
var _resBundle = require("../src/resBundle");
/**
* Provides functions to map to translated strings.
*
* Usage:
* ```
* import $L, {toIString} from '@enact/i18n/$L';
* $L('Close'); // => "Close" in the current locale
* toIString('Close'); // => an ilib IString representing "Close" in the current locale
* ```
*
* @module i18n/$L
* @exports $L
* @exports $toIString
*/
/**
* Maps a string or key/value object to a translated string for the current locale.
*
* @function
* @memberof i18n/$L
* @param {String|Object} str Source string
*
* @returns {ilib.IString} The translated string
*/
function toIString(str) {
var rb = (0, _resBundle.getResBundle)();
return (0, _resBundle.getIStringFromBundle)(str, rb);
}
/**
* Maps a string or key/value object to a translated string for the current locale.
*
* @function
* @memberof i18n/$L
* @param {String|Object} str Source string
*
* @returns {String} The translated string
*/
function $L(str) {
return String(toIString(str));
}
var _default = exports["default"] = $L;