How to use the make-plural-compiler.load function in make-plural-compiler

To help you get started, we’ve selected a few make-plural-compiler 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 TrigenSoftware / i18n-for-browser / src / index.ts View on Github external
}
	}

	translated = translate(config, locale, singular, plural);

	// find the correct plural rule for given locale
	if (typeof translated === 'object') {

		let p = null;

		// create a new Plural for locale
		// and try to cache instance
		if (pluralsInstanceForLocale[locale]) {
			p = pluralsInstanceForLocale[locale];
		} else {
			MakePlural.load(plurals);
			p = new MakePlural(locale).compile();
			pluralsInstanceForLocale[locale] = p;
		}

		// fallback to 'other' on case of missing translations
		translated = translated[p(countNumber)] || translated.other;
	}

	// Accept an object with named values as the last parameter
	if (typeof values[values.length - 1] === 'object') {
		namedValues = values.pop();
	}

	return postProcess(config, translated, namedValues, values, countNumber);
}