How to use the i18n-calypso.hasTranslation 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 / lib / i18n-utils / empathy-mode.js View on Github external
i18n.registerTranslateHook( ( translation, options ) => {
		const locale = i18n.getLocaleSlug();
		if ( 'en' === locale ) {
			return translation;
		}

		if ( i18n.hasTranslation( options.original ) ) {
			if ( options.components ) {
				translation = interpolateComponents( {
					mixedString: options.original,
					components: options.components,
				} );
			} else {
				translation = options.original;
			}

			return translation;
		}
		return locale + '-untranslated';
	} );
}