Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if ( isMobile() ) {
return false;
}
return true;
},
};
// wrap translations from i18n
i18n.registerTranslateHook( ( translation, options ) => {
return communityTranslatorJumpstart.wrapTranslation( options.original, translation, options );
} );
// callback when translated component changes.
// the callback is overwritten by the translator on load/unload, so we're returning it within an anonymous function.
i18n.registerComponentUpdateHook( () => {
if ( typeof translationDataFromPage.contentChangedCallback === 'function' ) {
return translationDataFromPage.contentChangedCallback();
}
} );
export function trackTranslatorStatus( isTranslatorEnabled ) {
const newSetting = isTranslatorEnabled,
changed = _isTranslatorEnabled !== newSetting,
tracksEvent = newSetting
? 'calypso_community_translator_enabled'
: 'calypso_community_translator_disabled';
if ( changed && _isTranslatorEnabled !== undefined ) {
debug( tracksEvent );
analytics.tracks.recordEvent( tracksEvent, { locale: user.data.localeSlug } );
}
componentDidMount() {
this.setLanguage();
// wrap translations from i18n
i18n.registerTranslateHook( ( translation, options ) =>
this.wrapTranslation( options.original, translation, options )
);
// callback when translated component changes.
// the callback is overwritten by the translator on load/unload, so we're returning it within an anonymous function.
i18n.registerComponentUpdateHook( () => {} );
i18n.on( 'change', this.refresh );
userSettings.on( 'change', this.refresh );
}