How to use the i18n-calypso.getLocale function in i18n-calypso

To help you get started, we’ve selected a few i18n-calypso 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 Automattic / wp-calypso / client / components / community-translator / index.jsx View on Github external
setLanguage() {
		this.languageJson = i18n.getLocale() || { '': {} };
		// The '' here is a Jed convention used for storing configuration data
		// alongside translations in the same dictionary (because '' will never
		// be a legitimately translatable string)
		// See https://messageformat.github.io/Jed/
		const { localeSlug, localeVariant } = this.languageJson[ '' ];
		this.localeCode = localeVariant || localeSlug;
		this.currentLocale = find( languages, lang => lang.langSlug === this.localeCode );
	}
github Automattic / wp-calypso / client / lib / translator-jumpstart / index.js View on Github external
updateTranslation( newTranslation ) {
		const locale = i18n.getLocale(),
			key = newTranslation.key,
			plural = newTranslation.plural,
			translations = newTranslation.translations;
		// jed expects:
		// 'context\004singular': [plural, translatedSingular, translatedPlural...]
		debug(
			'Updating ',
			newTranslation.singular,
			'from',
			locale[ key ],
			'to',
			[ plural ].concat( translations )
		);
		locale[ key ] = [ plural ].concat( translations );

		i18n.setLocale( locale );
github Automattic / wp-calypso / client / lib / translator-jumpstart / index.js View on Github external
init( isUserSettingsReady ) {
		const languageJson = i18n.getLocale() || { '': {} };
		const { localeSlug: localeCode, localeVariant } = languageJson[ '' ];

		if ( localeCode && languageJson ) {
			this.updateTranslationData( localeCode, languageJson, localeVariant );
		} else {
			debug( 'trying to initialize translator without loaded language' );
		}

		if ( initialized ) {
			return;
		}

		if ( ! isUndefined( isUserSettingsReady ) ) {
			_isUserSettingsReady = isUserSettingsReady;
		}
		if ( ! _isUserSettingsReady ) {