How to use the intl-messageformat/lib/utils.hop function in intl-messageformat

To help you get started, we’ve selected a few intl-messageformat 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 diplomatiegouvfr / hornet-js / hornet-js-utils / src / i18n-utils.ts View on Github external
let id;
    let value;

    for (i = 0, len = pattern.length; i < len; i += 1) {
        part = pattern[ i ];

        // Exist early for string parts.
        if (typeof part === "string") {
            result += part;
            continue;
        }

        id = part.id;

        // Enforce that all required values are provided by the caller.
        if (!(values && src$utils$$.hop.call(values, id))) {
            values[ id ] = undefined;
            if(part.options && (part.options["undefined"] || part.options["=undefined"])) {
                values[ id ] = undefined;
            } else {
                values[ id ] = "{" + id + "}";
            }
        }

        value = values[ id ];

        // Recursively format plural and select parts' option — which can be a
        // nested pattern structure. The choosing of the option to use is
        // abstracted-by and delegated-to the part helper object.
        if (part.options) {
            const opt = part.getOption(value);
            if(opt) {

intl-messageformat

Formats ICU Message strings with number, date, plural, and select placeholders to create localized messages.

BSD-3-Clause
Latest version published 6 days ago

Package Health Score

100 / 100
Full package analysis