How to use the make-plural/make-plural function in make-plural

To help you get started, we’ve selected a few make-plural 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.js View on Github external
}

	// enforce number
	count = parseInt(count, 10);

	// 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 (PluralsForLocale[targetLocale]) {
			p = PluralsForLocale[targetLocale];
		} else {
			p = new MakePlural(targetLocale);
			PluralsForLocale[targetLocale] = p;
		}

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

	return postProcess(translated, namedValues, params, count);
}
github lingui / js-lingui / packages / lingui-i18n / src / utils.dev.js View on Github external
export const loadLanguageData = (language: string) => {
  const plurals = new MakePlural(language, {
    cardinals: true,
    ordinals: true
  })

  return { plurals }
}

make-plural

Unicode CLDR pluralization rules as JavaScript functions

ISC
Latest version published 10 days ago

Package Health Score

74 / 100
Full package analysis