Tag: i18next

i18next改变语言没有任何input

我正在尝试在我的node.js应用程序上设置i18next。 我现在有两种语言:fr-CA和en-US。 我想有fr-CA作为默认语言。 我在app.js中这样设置,在configuration之前: i18next.init({ debug: true, lng: 'fr-CA', ignoreRoutes: [ 'img/', 'public/', 'stylesheets/', 'js/' ] }); 这是我的文件夹结构 locales/ dev/ translation.json en/ translation.json fr-CA/ translation.json fr/ translation.json 我做一个控制台login服务器启动,看看是什么i18next.lng()值,它说fr-CA 。 但是,一旦我加载一个页面,控制台将currentLng set to: en-US 。 所以它总是尝试加载locales / en / translation.json文件。 debugging显示,启动服务器时,它加载了fr-CA,fr和dev文件。 但是,一旦页面启动,它会加载en文件,就像它完全忘了fr-CA。 我的浏览器是英文的,所以我猜这是从那里得到的。 但我似乎无法find它为什么会改变。 我在这里错过了什么吗? 谢谢

ReferenceError:t没有定义

我有我的express.js / blade.js模板使用i18next库这个代码index.coffee express = require "express" gzippo = require "gzippo" assets = require "connect-assets" jsPaths = require "connect-assets-jspaths" #stylus = require "stylus" blade = require "blade" i18n = require "i18next" http = require "http" https = require "https" fs = require "fs" json = "" #### Application initialization # Create app instance. app = […]

如何让i18next-node以正确的方式显示变音符号?

我search了很多,但找不到我的问题的解决scheme。 我的应用程序使用i18next,除了一个问题,它工作正常:德语变音符号(ü,ö,ä)显示为 。 我不明白是我错了,因为这个示例应用程序没有与变音器的问题: http ://i18next-example1.eu01.aws.af.cm/?setLng=de- DE (github: https:// github.com/rbeere/i18next-jade-express-sample ) 我怎样才能找出这一个呢?

运行客户端时(在浏览器中)将助手附加到Jade

我用mongo db制作了一个由js(Express)提供的单页面应用程序。 我已经使用翡翠模板,并在浏览器中呈现一些模板。 模板渲染良好,除了我无法锻炼如何添加助手。 特别是下一个。 我build立了一个模板/ get /的路线,如下所示: var fs = require('fs'); var jade = require('jade'); exports.get = function(req, res){ fs.readFile('views/partials/listing_snippet.jade', {encoding: 'utf-8'}, function (err, data) { if (err) throw err; console.log(data); t = jade.compile(data, {client: true, compileDebug: false}); res.send('var template = {listing_snippet: ' + t.toString() + '}'); }); } 然后我把这个和jades的'runtime.js'作为脚本放在我的页面顶部。 该模板通过调用template.listing_snippet({locals: foo});渲染罚款template.listing_snippet({locals: foo}); 但我不能让i18next的帮手工作。 […]

国际问题 – 翻译正在交换

我正在尝试使用nodejs / express来构build几个虚拟主机。 每个虚拟主机都有一组本地化的文件(translation.json)。 我试图创buildi18n组件的多个实例,说我们有以下网站 foo.bar.ca (canada) foo.bar.fr (france) foo.bar.cn (china) 我正在尝试这样做: var i18n = require('i18n'); app.use(i18nOrg.initMW(app, siteObj.locale, instance(i18nOrg))); ================================================================================== //Below is the i18nOrg = require('../i18nOrg') // init middleware module.exports.initMW = function(app, locale, i18nOrg) { return function(req, res, next) { i18nOrg.configure({ updateFiles: false, objectNotation: true, directory: process.cwd() + '/app/locales/' + locale, prefix: 'translation', register: global, […]

i18Next – NodeJS – 如何更改翻译,而无需重新加载服务器

我正在使用i18next包的NodeJS来启用翻译。 我将它作为每个语言对的JSON文件的标准使用。 我想build立一个pipe理页面来编辑翻译,而不必深入代码; 那么,我怎样才能“重新加载”一次由pipe理员编辑的JSON文件,而不必重新启动服务器? 另外,是否有可能使用数据库(我正在使用mongodb),而不是JSON文件? 在这种情况下会更合适吗?

i18next不工作在jQuery中

我试图翻译与i18next jQuery的消息,但不工作。 index.js: ======== jQuery(document).ready(function($){ var msg = $.t("index.info") } translation.json: ================ "index": { "info": "The Information" } app.js: ======= i18n.init ({saveMissing: true, debug: true, sendMissingTo: 'fallback' } ); i18n.registerAppHelper (app) .serveClientScript (app) .serveDynamicResources(app) .serveMissingKeyRoute (app); 我需要在jQuery中使用i18next。 谢谢!

parsinghtml元素中的data-i18n属性

我试图从自定义正则expression式的HTML文件(也与默认的i18n.t函数)parsing'data-i18n'属性: i18next modules/ -o lang/ -r '[^a-zA-Z0-9](?:(?:t)|(?:i18n\\.t)|(?:data-i18n))(?:\\(|\\s|=)\\s*(?:(?:\'((?:(?:\\\\\')?[^\']+)+[^\\\\])\')|(?:"((?:(?:\\\\")?[^"]+)+[^\\\\])"))' parsing器可以在这里find: https : //github.com/karellm/i18next-parser 来自文档的命令: i18next /path/to/file/or/dir -r "(.*)" 正则expression式已经在regexpal和debuggex上进行了testing,它修改了正确的标签: [^a-zA-Z0-9](?:(?:t)|(?:i18n\.t)|(?:data-i18n))(?:\(|\s|=)\s*(?:(?:'((?:(?:\\')?[^']+)+[^\\])')|(?:"((?:(?:\\")?[^"]+)+[^\\])")) 我试图以各种forms逃避正则expression式string,但它不工作。 如何正确地做到这一点?

i18next正在改变resGetPath

我有一个节点应用程序使用i18next模块来处理国际化,但我有一个问题,我似乎无法解决在服务器端。 该应用程序构build在node并使用express框架。 在ap的入口点的主要app.js文件中,我需要i18n模块并运行init方法。 这是为了在客户端使用。 后来在一个不同的文件中,我试图重置resGetPath属性,以便在不同的位置加载一个翻译文件到正常的(一些文件位于默认locales/__lng__/__ns__.jsonpath,其他人在他们的拥有单独的文件夹)。 我似乎无法find一个具体的方法在i18n对象这样做,所以我一直在尝试只是用callback运行init方法。 但是,即使我这样做resGetPath属性不会更改,它不会从新文件中获取翻译string。 如果我在app.js中的第一个init调用中设置了resGetPath属性,尽pipe它按预期工作(虽然然后它在locales/__lng__/__ns__.json失去了正常的翻译) 基本上这是我想要做的: app.js i18n.init({ detectLngQS: 'lang', debug: false, useCookie: false, detectLngFromHeaders: true, fallbackLng: ['en-GB', 'dev'] }); after-app.js i18n.init({ resGetPath: path.join(__dirname, '../new-path.json') }, function(t) { // Here `t` does not get the strings in the new resGetPath }); 任何人都可以告诉我如何改变resGetPath ,或者告诉我我做错了什么?

在函数中访问i18下一个翻译不在App.js中

我使用ExpressJS和i18next。 在app.js var express = require('express') , i18n = require('i18next') , user = require('./routes/user') … //internationalization i18n.init({ lng: 'en-US', saveMissing: true, debug: true }); … app.use(i18n.handle); app.set('views', __dirname + '/views'); app.set('view engine', 'jade'); … i18n.registerAppHelper(app); … app.post('/users/save', user.save); 我可以访问玉的翻译: t('app.title') 我如何访问routes.user.js的翻译 exports.save = function(req, res){ //t('app.title') }