Counterpart翻译和本地化库
Counterpart 是一个翻译和本地化库,用于 Node.js 和浏览器。
示例代码:
translate.registerTranslations('de', require('counterpart/locales/de')); translate.registerTranslations('de', require('./locales/de.json')); translate('foo', { locale: 'de' }); translate.getLocale() // => 'en' translate.setLocale('de') // => 'en' (returns the previous locale) translate.getLocale() // => 'de' translate.onLocaleChange(function(newLocale, oldLocale) { // do important stuff here... }, [callbackContext]);
评论