How to use the @wordpress/i18n.setLocaleData function in @wordpress/i18n

To help you get started, we’ve selected a few @wordpress/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 wordpress-mobile / gutenberg-mobile / src / index.js View on Github external
const setupLocale = ( locale, extraTranslations ) => {
	I18nManager.forceRTL( false ); // Change to `true` to debug RTL layout easily.

	let gutenbergTranslations = getTranslation( locale );
	if ( locale && ! gutenbergTranslations ) {
		// Try stripping out the regional
		locale = locale.replace( /[-_][A-Za-z]+$/, '' );
		gutenbergTranslations = getTranslation( locale );
	}
	const translations = Object.assign( {}, gutenbergTranslations, extraTranslations );
	// eslint-disable-next-line no-console
	console.log( 'locale', locale, translations );
	// Only change the locale if it's supported by gutenberg
	if ( gutenbergTranslations || extraTranslations ) {
		setLocaleData( translations );
	}
};
github WordPress / gutenberg / packages / react-native-editor / src / index.js View on Github external
const setupLocale = ( locale, extraTranslations ) => {
	I18nManager.forceRTL( false ); // Change to `true` to debug RTL layout easily.

	let gutenbergTranslations = getTranslation( locale );
	if ( locale && ! gutenbergTranslations ) {
		// Try stripping out the regional
		locale = locale.replace( /[-_][A-Za-z]+$/, '' );
		gutenbergTranslations = getTranslation( locale );
	}
	const translations = Object.assign( {}, gutenbergTranslations, extraTranslations );
	// eslint-disable-next-line no-console
	console.log( 'locale', locale, translations );
	// Only change the locale if it's supported by gutenberg
	if ( gutenbergTranslations || extraTranslations ) {
		setLocaleData( translations );
	}
};
github google / site-kit-wp / assets / js / googlesitekit-dashboard-splash.js View on Github external
constructor( props ) {
		super( props );
		this.state = {
			hasError: false,
		};

		// Set up translations.
		setLocaleData( googlesitekit.locale, 'google-site-kit' );
	}
github google / site-kit-wp / assets / js / googlesitekit-module.js View on Github external
constructor( props ) {
		super( props );
		this.state = { hasError: false };

		// Set up translations.
		setLocaleData( googlesitekit.locale, 'google-site-kit' );

		const {
			showModuleSetupWizard,
		} = googlesitekit.setup;

		this.state = {
			showModuleSetupWizard,
		};
	}
github google / site-kit-wp / assets / js / googlesitekit-wp-dashboard.js View on Github external
constructor( props ) {
		super( props );
		this.state = { hasError: false };

		// Set up translations.
		setLocaleData( googlesitekit.locale, 'google-site-kit' );
	}
github Yoast / wordpress-seo / js / src / helpers / i18n.js View on Github external
export function setTextdomainL10n( textdomain, l10nNamespace = "wpseoYoastJSL10n" ) {
	const translations = get( window, [ l10nNamespace, textdomain, "locale_data", textdomain ], false );

	if ( translations === false ) {
		// Jed needs to have meta information in the object keyed by an empty string.
		setLocaleData( { "": {} }, textdomain );
	} else {
		setLocaleData( translations, textdomain );
	}
}
github google / site-kit-wp / assets / js / googlesitekit-adminbar.js View on Github external
constructor( props ) {
		super( props );

		// Set up translations.
		setLocaleData( googlesitekit.locale, 'google-site-kit' );

		this.handleMoreDetailsLink = this.handleMoreDetailsLink.bind( this );
	}
github google / site-kit-wp / assets / js / googlesitekit-dashboard.js View on Github external
constructor( props ) {
		super( props );
		this.state = {
			hasError: false,
		};

		// Set up translations.
		setLocaleData( googlesitekit.locale, 'google-site-kit' );
	}
github Yoast / wordpress-seo / js / src / helpers / i18n.js View on Github external
export function setTextdomainL10n( textdomain, l10nNamespace = "wpseoYoastJSL10n" ) {
	const translations = get( window, [ l10nNamespace, textdomain, "locale_data", textdomain ], false );

	if ( translations === false ) {
		// Jed needs to have meta information in the object keyed by an empty string.
		setLocaleData( { "": {} }, textdomain );
	} else {
		setLocaleData( translations, textdomain );
	}
}
github wp-erp / wp-erp / modules / accounting / assets / src / admin / i18n.js View on Github external
window.acct_add_locale = function(name, localeData) {
    setLocaleData(localeData, name);
};

@wordpress/i18n

WordPress internationalization (i18n) library.

GPL-2.0-or-later
Latest version published 6 days ago

Package Health Score

98 / 100
Full package analysis