function loadEngine() { /********************* Configure locales *********************/ var localeList = ['en', 'fr', 'es']; i18n.configure({ defaultLocale: 'en', locales: localeList, directory: t411.gui.pluginsDir + 't411/locales', updateFiles: true }); if ($.inArray(t411.gui.settings.locale, localeList) > -1) { console.log('Loading t411 engine with locale' + t411.gui.settings.locale); i18n.setLocale(t411.gui.settings.locale); } else { i18n.setLocale('en'); } // menus needed by the module and menu(s) loaded by default t411.menuEntries = ["searchTypes", "searchFilters","orderBy"]; t411.defaultMenus = ["searchTypes", "searchFilters","orderBy"]; // searchTypes menus and default entry t411.searchTypes = JSON.parse('{"' + _("Search") + '":"search","' + _("Top 100") + '":"navigation"}'); t411.defaultSearchType = 'search'; t411.searchFilters = JSON.parse('{"' + _("All categories") + '":"","'+_("Videos")+'":"210","'+_("Audio")+'":"395","'+_("xXx")+'":"456"}'); t411.defaultSearchFilter = ""; // orderBy filters and default entry t411.orderBy_filters = JSON.parse('{"' + _("Select a filter") + '":"","' + _("Date") + '":"added","' + _("Seeds") + '":"seeders","' + _("Size") + '":"size"}'); t411.defaultOrderBy = ''; }
function loadEngine() { /********************* Configure locales *********************/ var localeList = ['en', 'fr']; i18n.configure({ defaultLocale: 'en', locales:localeList, directory: omgTorrent.gui.pluginsDir + 'omgtorrent/locales', updateFiles: true }); if ($.inArray(omgTorrent.gui.settings.locale, localeList) >-1) { console.log('Loading omgtorrent engine with locale' + omgTorrent.gui.settings.locale); i18n.setLocale(omgTorrent.gui.settings.locale); } else { i18n.setLocale('en'); } // menus needed by the module and menu(s) loaded by default omgTorrent.menuEntries = ["searchTypes","orderBy","categories"]; omgTorrent.defaultMenus = ["searchTypes","orderBy"]; // searchTypes menus and default entry omgTorrent.searchTypes = JSON.parse('{"'+_("Search")+'":"search","'+_("Navigation")+'":"navigation"}'); omgTorrent.defaultSearchType = 'navigation'; // orderBy filters and default entry omgTorrent.orderBy_filters = JSON.parse('{"'+_("Date")+'":"id","'+_("Seeds")+'":"seeders"}'); omgTorrent.defaultOrderBy = 'id'; // category filters and default entry omgTorrent.category_filters = JSON.parse('{"'+_("Movies")+'":"films"}'); omgTorrent.defaultCategory = 'films'; // others params omgTorrent.has_related = false; omgTorrent.categoriesLoaded = false; }
function setUpI18n(){ i18n.configure({ locales:['en', 'es'], directory: `${__dirname}/locales`, defaultLocale: locale }); }
module.exports = grunt => { const gruntConfig = {} i18n.configure({ locales: i18nConfig.locales, defaultLocale: i18nConfig.defaultLocale, updateFiles: false, objectNotation: true, directory: path.join(process.cwd(), 'config', 'locales') }) i18nConfig.locales.forEach(locale => { gruntConfig[locale] = { src: templateFilesToInject, dest: '.tmp/public/templates/' + locale, ext: '.html', expand: true, flatten: true, options: { __ (key) { return i18n.__({locale, phrase: key}) } } } }) grunt.config.set('ejs', gruntConfig) grunt.loadNpmTasks('grunt-ejs') }
function loadEngine() { /********************* Configure locales *********************/ var localeList = ['en', 'fr']; i18n.configure({ defaultLocale: 'en', locales:localeList, directory: megaFiles.gui.pluginsDir + 'mega-files/locales', updateFiles: false }); if ($.inArray(megaFiles.gui.settings.locale, localeList) >-1) { console.log('Loading megaFiles engine with locale' + megaFiles.gui.settings.locale); i18n.setLocale(megaFiles.gui.settings.locale); } else { i18n.setLocale('en'); } /********************* engine config ************************* **************************************************************/ // menus needed by the module and menu(s) loaded by default megaFiles.menuEntries = ["searchTypes"]; megaFiles.defaultMenus = ["searchTypes"]; // searchTypes menus and default entry megaFiles.searchTypes = {"Videos":"videos"}; megaFiles.defaultSearchType = 'videos'; // orderBy filters and default entry //megaFiles.orderBy_filters = JSON.parse('{"'+_("Relevant")+'":"relevant","'+_("Newest")+'":"newest","'+_("Most viewed")+'":"most_played","'+_("Most rated")+'":"most_liked"}'); // others params megaFiles.has_related = false; }
function loadEngine() { /********************* Configure locales *********************/ var localeList = ['en', 'fr', 'de']; i18n.configure({ defaultLocale: 'en', locales: localeList, directory: kick.gui.pluginsDir + 'kickass/locales', updateFiles: true }); if ($.inArray(kick.gui.settings.locale, localeList) > -1) { console.log('Loading kick engine with locale' + kick.gui.settings.locale); i18n.setLocale(kick.gui.settings.locale); } else { i18n.setLocale('en'); } // menus needed by the module and menu(s) loaded by default kick.menuEntries = ["searchTypes", "orderBy"]; kick.defaultMenus = ["searchTypes", "orderBy"]; // searchTypes menus and default entry kick.searchTypes = JSON.parse('{"' + _("Search") + '":"search"}'); kick.defaultSearchType = 'search'; // orderBy filters and default entry kick.orderBy_filters = JSON.parse('{"' + _("Date") + '":"time_add","' + _("Seeds") + '":"seeds"}'); kick.defaultOrderBy = 'time_add'; // others params kick.has_related = false; kick.categoriesLoaded = true; }
exports.t = function() { i18n.configure({ locales: ['en'] }); return i18n.__; };
function Express(name, options) { Resource.apply(this, arguments); var languague_array = process.supported_languages; i18n.configure({ locales: languague_array, defaultLocale: 'en', cookie: 'lang', directory: path.join(path.resolve('.'), 'public', 'locales'), objectNotation: true }); var app = this.app = express(), exp = this; app.configure(function () { app.use(express.cookieParser()); app.use(i18n.init); app.use(function (req, res, next) { if( req.headers.cookie && req.headers.cookie.indexOf && req.headers.cookie.indexOf('lang=') > -1){ var cookie = req.headers.cookie; req.setLocale(cookie[cookie.indexOf('lang=')+5]+cookie[cookie.indexOf('lang=')+6]); } next(); }); }); // handle all routes this.path = '/'; app.set('views', path.join(path.resolve('.'), 'views')); }
function loadEngine() { /********************* Configure locales *********************/ var localeList = ['en', 'fr', 'de']; i18n.configure({ defaultLocale: 'en', locales: localeList, directory: twitch.gui.pluginsDir + 'twitch/locales', updateFiles: true }); if ($.inArray(twitch.gui.settings.locale, localeList) > -1) { console.log('Loading twitch engine with locale' + twitch.gui.settings.locale); i18n.setLocale(twitch.gui.settings.locale); } else { i18n.setLocale('en'); } // menus needed by the module and menu(s) loaded by default twitch.menuEntries = ["searchTypes", "categories"]; twitch.defaultMenus = ["searchTypes"]; // searchTypes menus and default entry twitch.searchTypes = JSON.parse('{"' + _("Search") + '":"search","' + _("Navigation") + '":"navigation"}'); twitch.defaultSearchType = 'search'; // categories filters and default entry twitch.category_filters = JSON.parse('{"' + _("Featured") + '":"featured","' + _("Games") + '":"games","' + _("Channels") + '":"channels"}'); twitch.defaultCategory = 'featured'; // others params twitch.has_related = false; twitch.categoriesLoaded = true; }
ControllerPush.prototype._makeDsfPushMessage = function(pushInfo, worldWeatherData) { var pushMsg; var trans = {}; i18n.configure({ // setup some locales - other locales default to en silently locales: ['en', 'ko', 'ja', 'zh-CN', 'de', 'zh-TW'], // where to store json files - defaults to './locales' directory: __dirname + '/../locales', register: trans }); trans.setLocale(pushInfo.lang); var location = ""; if (pushInfo.name) { location = pushInfo.name + " "; } if (pushInfo.package === 'todayWeather') { var weatherSummary = this._makeDsfPushWeatherMessage(pushInfo, worldWeatherData, trans); pushMsg = {title: location+weatherSummary.title, text: weatherSummary.text}; } else if (pushInfo.package === 'todayAir') { var airSummary = this._makePushAirMessage(pushInfo, worldWeatherData, trans); pushMsg = {title: location+airSummary.title, text: airSummary.text}; } return pushMsg; };
initialize: function(api, next){ api.i18n = { // i18n: i18n, // simplistic determination of locale for connection determineConnectionLocale: function(connection){ // perhpas you want to look at the `accept-language` headers from a web requests // perhaps your API can use a certain cookie or URL to determine locale return api.config.i18n.defaultLocale; }, invokeConnectionLocale: function(connection){ var cmdParts = api.config.i18n.determineConnectionLocale.split('.'); var cmd = cmdParts.shift(); if(cmd !== 'api'){ throw new Error('cannot operate on a method outside of the api object'); } var method = api.utils.stringToHash(cmdParts.join('.')); var locale = method(connection); api.i18n.i18n.setLocale(connection, locale); } }; var options = api.config.i18n; options.directory = path.normalize(api.config.general.paths.locale[0]); i18n.configure(options); i18n.setLocale(api.config.i18n.defaultLocale); api.i18n.i18n = i18n; next(); }
function loadEngine() { /********************* Configure locales *********************/ var localeList = ['en', 'fr','de']; i18n.configure({ defaultLocale: 'en', locales:localeList, directory: mp3stream.gui.pluginsDir + 'mp3stream/locales', updateFiles: true }); if ($.inArray(mp3stream.gui.settings.locale, localeList) >-1) { console.log('Loading mp3stream engine with locale ' + mp3stream.gui.settings.locale); i18n.setLocale(mp3stream.gui.settings.locale); } else { i18n.setLocale('en'); } /********************* engine config ************************* **************************************************************/ // menus needed by the module and menu(s) loaded by default mp3stream.menuEntries = ["searchTypes"]; mp3stream.defaultMenus = ["searchTypes"]; // searchTypes menus and default entry mp3stream.searchTypes = JSON.parse('{"'+_("Artists")+'":"artists"}'); mp3stream.defaultSearchType = 'artists'; // others params mp3stream.has_related = false; }
function loadEngine() { /********************* Configure locales *********************/ var localeList = ['en', 'fr','de']; i18n.configure({ defaultLocale: 'en', locales:localeList, directory: shoutcast.gui.pluginsDir + 'shoutcast/locales', updateFiles: true }); if ($.inArray(shoutcast.gui.settings.locale, localeList) >-1) { console.log('Loading shoutcast engine with locale ' + shoutcast.gui.settings.locale); i18n.setLocale(shoutcast.gui.settings.locale); } else { i18n.setLocale('en'); } /********************* engine config ************************* **************************************************************/ // menus needed by the module and menu(s) loaded by default shoutcast.menuEntries = ["searchTypes","searchFilters"]; shoutcast.defaultMenus = ["searchTypes","searchFilters"]; // searchTypes menus and default entry shoutcast.searchTypes = JSON.parse('{"'+_("Search")+'":"search"}'); shoutcast.searchFilters = JSON.parse('{"'+_("Shoutcast")+'":"shoutcast","'+_("Icecast")+'":"icecast"}'); shoutcast.defaultSearchFilter = "shoutcast"; shoutcast.defaultSearchType = 'search'; // others params shoutcast.has_related = false; }
function setLocale(req, res, next) { var locale; //配置i18n i18n.configure({ locales: languages, //声明包含的语言 register: res, directory: __dirname + '/locales', //翻译json文件的路径 defaultLocale: settings.lang, //默认的语言,即为上述标准4 indent: "\t" }); //客户端可以通过修改cookie进行语言切换控制 if (req.cookies['locale']) { locale = req.cookies['locale']; } else if (req.acceptsLanguages()) { locale = req.acceptsLanguages()[0]; } if (!~languages.indexOf(locale)) { locale = settings.lang; } // 强制设置语言 locale = settings.lang; // 设置i18n对这个请求所使用的语言 res.setLocale(locale); next(); };
function loadEngine() { /********************* Configure locales *********************/ var localeList = ['en', 'fr']; i18n.configure({ defaultLocale: 'en', locales:localeList, directory: tProject.gui.pluginsDir + 'tproject/locales', updateFiles: true }); if ($.inArray(tProject.gui.settings.locale, localeList) >-1) { console.log('Loading tproject engine with locale' + tProject.gui.settings.locale); i18n.setLocale(tProject.gui.settings.locale); } else { i18n.setLocale('en'); } // menus needed by the module and menu(s) loaded by default tProject.menuEntries = ["searchTypes","orderBy","categories"]; tProject.defaultMenus = ["searchTypes","orderBy","categories"]; // searchTypes menus and default entry tProject.searchTypes = JSON.parse('{"'+_("Search torrents")+'":"search","'+_("Search Files")+'":"searchFiles"}'); tProject.defaultSearchType = 'search'; // orderBy filters and default entry tProject.orderBy_filters = JSON.parse('{"'+_("Best")+'":"best","'+_("Seeds")+'":"seeders"}'); tProject.defaultOrderBy = 'best'; // category filters and default entry tProject.category_filters = JSON.parse('{"'+_("All")+'":"9000","'+_("Videos")+'":"2000","'+_("Audio")+'":"1000"}'); tProject.defaultCategory = '9000'; // others params tProject.has_related = false; tProject.categoriesLoaded = false; }
.run(function() { i18n.configure({ locales: sails.config.i18n.locales, directory: sails.config.appPath + sails.config.i18n.localesDirectory, defaultLocale: sails.config.i18n.defaultLocale, updateFiles: sails.config.i18n.updateFiles ? sails.config.i18n.updateFiles : false, extension: '.json' }); });
function setupLexicon(localesPath) { // i18n setup. i18n.configure({ directory : localesPath, defaultLocale : "en", updateFiles : false, }); i18n.setLocale(osLocale.sync()); }
exports.configureModules = function(app) { i18n.configure({ locales: Config.locale.supported, defaultLocale: Config.locale.default }); localeHolder.setLocales(Config.locale.supported); app.use(i18n.init); };
module.exports = function(app) { i18n.configure({ locales: ['es', 'en'], defaultLocale: 'es', cookie: 'language', directory: __dirname + '/locales' }); app.use(i18n.init); }
before( function () { i18n.configure( { locales: [ 'en' ], directory: __dirname + '/../messages', defaultLocale: 'en', cookie: 'test', updateFiles: false } ); colog.silent( true ); // disable non-mocha stdout } );
i18nAdmin.init = function(callback) { i18nAdmin.configure({ // setup some locales - other locales default to en silently locales: global.settings.defaultLocales, directory: global.settings.root_path + '/locales', defaultLocale: global.settings.defaultLocale, // where to register __() and __n() to, might be "global" if you know what you are doing register: global }); callback(); };
.run(function() { i18n.configure(_.defaults(sails.config.i18n, { cookie: null, directory: sails.config.appPath + sails.config.i18n.localesDirectory, updateFiles: false, extension: '.json' })); // Expose global access to locale strings sails.__ = i18n.__; });
function initi18n(cb) { startupLogger.info("Initiating i18n.."); i18n.configure({ locales:['en', 'de'], cookie: 'locale', directory: path.resolve(__dirname + '/../locales'), extension: '.json', updateFiles: false }); cb(); }
module.exports = function () { i18n.configure({ defaultLocale: this.options.locale, directory: this.options.localePath }); this.i18n = { debug: require('../logger/i18n/debug').bind(this), warn: require('../logger/i18n/warn').bind(this), err: require('../logger/i18n/err').bind(this) }; return this.i18n.debug('DEBUG_SETUP_I18N', this.options.locale); };
export default function () { var app = this; i18n.configure({ locales: app.conf.get('i18n.locales'), objectNotation: true, cookie: app.conf.get('i18n.name'), directory: path.join(app.root, 'locales') }); app.logger.debug('configured i18n module'); }
var i18n = function(){ var i18n = require('i18n'), path = require('path'); i18n.configure({ locales:['pt-br', 'en'], defaultLocale: 'pt-br', directory: path.join(__dirname,'..', 'locale'), indent: '\t' }); return i18n; };
module.exports = function (locales) { // Internationalization i18n.configure({ // setup some locales - other locales default to en silently locales: _.keys(locales || {}), // where to register __() and __n() to, might be "global" if you know what you are doing register: global }); return i18n; };
module.exports.init = function(app) { i18n.configure({ directory: __dirname + '/../locales', }); app.set('port', (process.env.PORT || 5000)); app.set('views', __dirname + '/../views'); app.set('view engine', 'pug'); app.use(express.static(__dirname + '/../static')); app.use(bodyParser.urlencoded({extended: true})); app.use(i18n.init); };
module.exports = function(app, config) { var env = app.get('env'); i18n.configure({ locales: config.availableLocales, cookie: 'lang', directory: config.root + '/server/locales' }); app.engine('handlebars', exphbs({ layoutsDir: config.root + '/server/views/layouts/', defaultLayout: 'main', partialsDir: [config.root + '/server/views/partials/'] })); app.set('views', config.root + '/server/views'); app.set('view engine', 'handlebars'); app.use(compression()); app.use(bodyParser.urlencoded({ extended: true })); app.use(bodyParser.json()); app.use(methodOverride()); app.use(cookieParser()); app.use(i18n.init); app.use(passport.initialize()); // Persist sessions with mongoStore // We need to enable sessions for passport twitter because its an oauth 1.0 strategy app.use(session({ secret: config.secrets.session, resave: true, saveUninitialized: true, store: new mongoStore({ mongooseConnection: mongoose.connection }) })); if ('production' === env) { app.use(favicon(path.join(config.root, 'public', 'favicon.ico'))); app.use(express.static(path.join(config.root, 'public'))); app.set('appPath', config.root + '/public'); app.use(morgan('dev')); } if ('development' === env || 'test' === env) { app.use(require('connect-livereload')()); app.use(express.static(path.join(config.root, '.tmp'))); app.use(express.static(path.join(config.root, 'client'))); app.set('appPath', config.root + '/client'); app.use(morgan('dev')); app.use(errorHandler()); // Error handler - has to be last } };
constructor() { if (!instance) { super() instance = this i18n.configure({ directory: join(__dirname, "..", "..", "locales/"), objectNotation: true }) this.i18n = i18n this.setLocale(UserSettings.locale || "en") } return instance }