How to use @hint/utils-i18n - 7 common examples

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;
        }
github webhintio / hint / packages / formatter-html / src / result.ts View on Github external
public constructor(name: string, url: string, isScanner: boolean, language?: string) {
        this.hints = [];
        this.passed = [];
        this.name = name;
        this.localizedName = getCategoryName(name.toLowerCase() as Category, language);

        this.hintsCount = 0;

        this.image = categoryImages[name.toLowerCase()];
        this.isScanner = isScanner;

        if (this.image && !isScanner) {
            this.image = this.image.substr(1);
        }

        this.status = 'finished';
        this.url = url;
    }
github webhintio / hint / packages / extension-browser / src / devtools / views / controls / feedback-link.tsx View on Github external
useEffect(() => {
        const disabledCategories = config.disabledCategories || [];
        const browserslists = config.browserslist || '';
        const ignoredUrls = config.ignoredUrls;

        let body = template
            .replace('__webhint version:__', `__webhint version:__ ${version}`)
            .replace('__Browser version:__', `__Browser version:__ ${navigator.userAgent}`)
            .replace('[x] Recommended settings', `[${!browserslists ? 'x' : ' '}] Recommended settings`)
            .replace('[ ] Custom: ', `[${browserslists ? 'x' : ' '}] Custom: ${browserslists ? browserslists : ''} `);

        for (const category of categories) {
            body = body.replace(`[x] ${getCategoryName(category)}`, `[${disabledCategories.includes(category) ? ' ' : 'x'}] ${getCategoryName(category)}`);
        }

        if (error) {
            body = body.replace('', `${error.message}\n${error.stack}`);
        }

        const getLocation = async () => {
            const loc = await evaluate('window.location');
            const origin = loc.origin;
            const noIgnored = ignoredUrls === undefined;
            const isSameOrigin = !noIgnored && (ignoredUrls === '--webhint-third-party' || ignoredUrls === `^(?!${escapeRegExp(origin)})`);
            const isCustom = !noIgnored && !isSameOrigin;

            body = body.replace('[x] None', `* [${noIgnored ? 'x' : ' '}] None`)
                .replace('[ ] Different origin', `* [${isSameOrigin ? 'x' : ' '}] Different origin`)
                .replace('[ ] Custom: ', `* [${isCustom ? 'x' : ' '}] Custom: ${isCustom ? ignoredUrls : ''} `);
github webhintio / hint / packages / extension-browser / src / devtools / views / pages / config / sections / categories.tsx View on Github external
const categoryInputs = categories.map((category) => {
        const isDisabled = disabled && disabled.includes(category);

        return (
            
                
                
                    {getCategoryName(category)}
                
            
        );
    });
github webhintio / hint / packages / extension-browser / src / devtools / views / pages / results / category.tsx View on Github external
const Category = ({ name, hints, showPassed }: Props) => {
    const shownHints = hints.filter((hint) => {
        return showPassed || hint.problems.length > 0;
    });

    return (
        <div>
            <div id="{`results-category-${name}`}">
                <span>
                    {getCategoryName(name)}
                </span>
            </div>
            <div>
                {shownHints.map((hint) =&gt; {
                    return ;
                })}
            </div>
        </div>
    );
};
github webhintio / hint / packages / extension-browser / src / devtools / views / pages / results / category-summary.tsx View on Github external
const CategorySummary = ({ name, hints, passed }: CategoryResults) =&gt; {
    let statusStyle = '';

    if (passed &lt; hints.length) {
        statusStyle = hasError(hints) ? styles.error : styles.warn;
    }

    return (
        <a data-icon="{name}" href="{`#results-category-${name}`}">
            {getCategoryName(name)}
            <span>{hints.length - passed}</span>
        </a>
    );
};
github webhintio / webhint.io / src / server / routes / scanner.js View on Github external
return (key, substitutions) => {
        return getMessageUtils(key, formatterHTMLPath, {
            language,
            substitutions
        });
    };
};

@hint/utils-i18n

util for i18n

Apache-2.0
Latest version published 10 months ago

Package Health Score

88 / 100
Full package analysis