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; }
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; }
ipcRenderer.on('CONFIG_UPDATE', (event, config) => { console.log('CONFIG_UPDATE', config) global.config = config if (config.global && config.global.locales) i18n.setLocale(config.global.locales) else i18n.setLocale(/zh/.test(lang) ? 'zh-CN' : 'en-US') render() })
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 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; }
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 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', '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: 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; }
var setLocale = function(user) { if( user.profile.language === 'Swedish' ) { return i18n.setLocale('se'); } if ( user.profile.language === 'Italian' ) { return i18n.setLocale('it'); } return i18n.setLocale('en'); }
this.setLangage = function() { var _this = this; if (getRandom() === 1) { i18n.setLocale('es'); _this.output.language = 'es'; } else { i18n.setLocale('en'); _this.output.language = 'en'; } },
exports.index = function(req,res){ //console.log(i18n.getLocale()); var lang = req.query.lang; if(lang=='zh-cn') { i18n.setLocale('zh-cn'); } else { i18n.setLocale('en-us'); } res.render('index',{title:__('title')}); }
exports.overrideLocaleFromPrefix = function (req, res, next, lang) { if (lang === null) { return; } i18n.setLocale(lang.toLowerCase()); next(); };
const langRouter = (req, res, next) => { const selectedLang = req.params.lang; //i18n.setLocale(req, req.params.lang); i18n.setLocale([req, res.locals], selectedLang); res.locals.language = '/' + selectedLang; next(); };
exports.locale = function(req, res) { var locale = _locale(req.params.locale); res.setHeader('Set-Cookie', 'locale=' + locale); i18n.setLocale(locale); _loadConfig(res, locale, _configLoaded); };
module.exports = (keyword, list, lang) => { if (!keyword) return ''; if (!_.isEmpty(list)) return ''; I18n.setLocale(lang); const text = I18n.__(keyword); return new Handlebars.SafeString(`<span class="pill th">${text}</span>`); }
exports.lang = function(req, res, next) { // set default if(req.session.user && req.session.user.lang){ //console.log(req.session.user); i18n.setLocale(req, req.session.user.lang); if(req.session.localJS){ res.locals.i18n = req.session.localJS; }else{ var local = fs.readFileSync("locales/" + req.session.user.lang + ".js","utf8"); local = local.replace(/[\r\n]/g,"").replace(/"/g,"'"); res.locals.i18n = local; req.session.localJS = local; } }else{ res.locals.i18n = ""; } res.locals.i = function() { return i18n.__.apply(req, arguments); }; res.locals.n = function() { return i18n.__n.apply(req, arguments); }; next(); }
router.post('/actions/change-language', function(req, res) { let maxAge = 1000 * 60 * config.sessionCookieDuration; // cookie age: 30 days let lang = req.body.lang; let redirectTo = req.body['redirect-to']; let hasLanguageNotice = req.body['has-language-notice'] ? true : false; if (!languages.isValid(lang)) { req.flash('siteErrors', req.__('invalid language')); if (redirectTo) return res.redirect(redirectTo); else return res.redirect('back'); } res.cookie('locale', lang, { maxAge, httpOnly: true }); i18n.setLocale(req, lang); // Don't show on pages with language notices on them, to avoid message overkill. if (!hasLanguageNotice) req.flash('siteMessages', req.__('notification language-changed')); if (redirectTo) res.redirect(redirectTo); else res.redirect('back'); });
const langRouter = (req, res, next) => { if (/^(en|hu)$/.exec(req.params.lang)) { i18n.setLocale([req, res.locals], req.params.lang); res.locals.language = `/${req.params.lang}`; } next(); };
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(); }
$(document).ready(function() { // setup locale i18n.configure({ defaultLocale: 'en', locales:localeList, directory: path.dirname(process.execPath) + '/locales', updateFiles: true }); if ($.inArray(settings.locale, localeList) >-1) { locale=settings.locale; i18n.setLocale(locale); } else { i18n.setLocale('en'); } });
app.use(function (req, res, next) { var lang = req.session.lang; if(lang){ i18n.setLocale(req, lang); next(); }else i18n.init(req, res, next); });
.then(function(lang) { i18n.setLocale(lang) config['lang'] = lang return helper.condition(!opts.skipconfig, require('./inquirer/config')) })
function setOrDetectLocale(locale) { if (locale && !isSupported(locale)) { console.log("===== locale " + locale + " not supported ====="); } if (locale) { return i18n.setLocale(locale.substr(0, 2)); } setDefaultLocale(); }
var initApp = function () { var mainWindow = new App.View.AppHomeView(); try { i18n.setLocale('bn'); App.Window.show(mainWindow); } catch (e) { console.error('Couldn\'t start app: ', e, e.stack); } };
function setupLexicon(localesPath) { // i18n setup. i18n.configure({ directory : localesPath, defaultLocale : "en", updateFiles : false, }); i18n.setLocale(osLocale.sync()); }
.then(result => { let offsetDate = result.offsetDate; let feedItems = result.feedItems; let updatedDate; feedItems.forEach(item => { item.populateUserInfo(req.user); if (item.thing) item.thing.populateUserInfo(req.user); // For Atom feed - most recently modified item in the result set if (!updatedDate || item._revDate > updatedDate) updatedDate = item._revDate; }); let paginationURL; if (offsetDate) { if (options.paginationURL) paginationURL = options.paginationURL.replace('%isodate', offsetDate.toISOString()); else paginationURL = `/feed/before/${offsetDate.toISOString()}`; } let vars = { titleKey: options.titleKey, titleParam: options.titleParam, deferPageHeader: options.deferPageHeader, feedItems, paginationURL, pageLimit: options.limit, embeddedFeeds: feeds.getEmbeddedFeeds(req, options) }; Object.assign(vars, options.extraVars); if (!options.format) { render.template(req, res, options.template, vars); } else if (options.format == 'atom') { Object.assign(vars, { layout: 'layout-atom', language, updatedDate, selfURL: url.resolve(config.qualifiedURL, options.atomURLPrefix) + `/${language}`, htmlURL: url.resolve(config.qualifiedURL, options.htmlURL) }); i18n.setLocale(req, language); res.type('application/atom+xml'); render.template(req, res, 'review-feed-atom', vars); } else throw new Error(`Format '${options.format}' not supported.`); })
process.on('uncaughtException', function (err) { try { if (err.message.indexOf('[sprintf]') !== -1) { var currentLocale = App.Localization.langcodes[i18n.getLocale()].nativeName; AdvSettings.set('language', 'en'); i18n.setLocale('en'); App.vent.trigger('movies:list'); $('.notification_alert').show().html('An error occured with the localization in ' + currentLocale).delay(4000).fadeOut(400); } } catch (e) {} win.error(err, err.stack); });
function loadEngine() { /********************* Configure locales *********************/ var localeList = ['en', 'fr']; i18n.configure({ defaultLocale: 'en', locales:localeList, directory: gshark.gui.pluginsDir + 'grooveshark/locales', updateFiles: true }); if ($.inArray(gshark.gui.settings.locale, localeList) >-1) { console.log('Loading gshark engine with locale' + gshark.gui.settings.locale); i18n.setLocale(gshark.gui.settings.locale); } else { i18n.setLocale('en'); } // engine config gshark.menuEntries = ["searchTypes","categories"]; gshark.defaultSearchType = 'popular'; gshark.defaultMenus = ["searchTypes"]; gshark.searchTypes = JSON.parse('{"'+_("Songs")+'":"songs","'+_("Albums")+'":"albums","'+_("Playlists")+'":"playlists","'+_("Popular")+'":"popular"}'); //gshark.orderBy_filters = JSON.parse('{"'+_("Date")+'":"age","'+_("Title")+'":"song","'+_("Artist")+'":"artist"}'); gshark.has_related = false; var totalItems = 0; var currentSearch = ""; gshark.search_type_changed(); gshark.initialized = true; gshark.searchType = 'popular'; gshark.searchInit = false; gshark.albumsCount = 0; gshark.playlistsCount = 0; gshark.songsCount = 0; gshark.ignoreSection = false; // fix css for search menu $('#search').css({"position":"fixed","z-index": "500","top": "74px","width": "46%","background": "white","overflow": "auto","height":"25px"}); }
function localeMiddleware(req, res, next) { res.locals.currentUri = req._parsedUrl.pathname; res.locals.defaultLang = i18n.getLocale(); res.locals.availableLangs = config.locales; var preferredLang = req.query['lang']; if(preferredLang !== undefined){ req.session.preferredLang = preferredLang === 'default' && null || preferredLang; } if(req.session && req.session.preferredLang){ i18n.setLocale(req.session.preferredLang); } res.locals.preferredLang = i18n.getLocale(); next(); }