Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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';
} );
}