How to use the @hint/utils-i18n.format.toString function in @hint/utils-i18n

To help you get started, we’ve selected a few @hint/utils-i18n examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github webhintio / hint / packages / formatter-html / scripts / create-get-message.js View on Github external
/**
 * This will create a get-message.js that will be used by the browser
 * to show localized strings.
 *
 * The formatter-html will use this file in the CLI and in the online
 * service.
 *
 * The generated file will use `window.localeStrings` which is initialize
 * for the `messages.js` generated by `compile-locales.js`.
 */
const content = `// Autogenerated by scripts/create-get-message.js

(function () {

    /* eslint-disable padding-line-between-statements, no-var, prefer-arrow-callback */
    var format = ${format.toString().split('\n')
        .map((line, index) => {
            if (index === 0) {
                return line;
            }

            return `    ${line}`;
        })
        .join('\n')};
    /* eslint-enable padding-line-between-statements */

    window.getMessage = function (key, substitutions) {
        var localeString = window.localeStrings && window.localeStrings[key];

        if (!localeString) {
            return key;
        }

@hint/utils-i18n

util for i18n

Apache-2.0
Latest version published 1 year ago

Package Health Score

81 / 100
Full package analysis