i18next

How can I use translations in i18next in javascript

 ̄綄美尐妖づ 提交于 2019-12-20 05:11:06
问题 I know that I can use i18next to translate languages in html. For example: <div data-i18n="someKey"></div> But is there a way to somehow use it in JS. For example if I want to do something like alert(someKey) ? 回答1: It should be alert(t(someKey)) (see http://i18next.com/ at end of page). 回答2: Having read the homepage of the project... i18n.init(function(t) { // translate nav $(".nav").i18n(); // programatical access var appName = t("app.name"); }); That last part is what you're looking for.

Translate JQuery Mobile widgets

旧时模样 提交于 2019-12-20 04:37:07
问题 Using i18next, how can I translate JQuery Mobile widgets? Specifically, I'd like to know how to do that without resorting to using data-i18n-target to modify generated inner elements, because that is brittle since future widget versions may change the generated code. Is there a specific page lifecycle event I can subscribe to in order to be able to have i18next modify the DOM before the widget transformation happens? In this example (see jsfiddle), some markup is correctly translated, but

How to use i18next to localise my website?

大憨熊 提交于 2019-12-13 02:58:21
问题 I have a very simple website with no backend, just pure html pages. I need to have English/Chinese versions for this website, what I need to achieve is have a button on NavBar, when users click this button, the wording on entire website will be changed to Chinese/English. All the examples I have seen that they are all require something like this: localize(".nav"); So does it mean that I need to do something like this: localize("body"); in order to get the whole website language switched? 回答1:

Translation for each component for react-i18next

拈花ヽ惹草 提交于 2019-12-12 05:39:19
问题 Im using react-i18next. Thing is that it expects the <I18nextProvider> to be wrapper on the outside of my App. I cannot wrap it inside my component itself since that will trigger errors. Is it even possible to run multiple instances of that provider? Since i have about 12 reusable components that i want to deliver with multi-language support. How should i handle that since i want to handle the translations, if possible, in those components itself. The thing i have right now is giving me

Not able to translate <a> tag inside div by i18next library

落花浮王杯 提交于 2019-12-12 03:59:57
问题 </head> <body> <div id="add"> <div data-i18n="key">You have to <a href="">Click here</a> to find better result</div> // If I am using that way that translate complete div and remove link from my text. <div data-i18n="key">You have to</div> <a href="" data-i18n="key2">Click here</a> <div data-i18n="key3">to find better result</div> // If I am using that way code working fine but for this I have to use 3 keys for single sentences. Is it possible to fix this by single key ? <script> i18next

(0, _reactI18next.translate) is not a function

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 07:47:08
问题 Actually I am new to react native and here I am trying to change language to Arabic using 'react-i18next' but when executed the following error ocures ReactNativeJS ▶︎ (0, _reactI18next.translate) is not a function. (In '(0, _reactI18next.translate)('common', { bindI18n: 'languageChanged', bindStore: false })', '(0, _reactI18next.translate)' is undefined) this is my code import React from 'react'; import AppNavigator from './src/controller/AppNavigator'; import { translate } from 'react

Use i18next with XHR backend in client-side javascript

你离开我真会死。 提交于 2019-12-11 07:19:59
问题 The documentation at i18next-xhr-backend tells me to use import to load their module. But when I use the import -statement, nothing happens and Firefox gives me a SyntaxError in the developer console: SyntaxError: import declarations may only appear at top level of a module So how can I use i18next library with the XHR-backend? The following code example works if the .use(XHR) -line and the corresponding import is commented out ( Warning: i18next::backendConnector: No backend was added via

dynamic translation/translation with variable with i18next

天大地大妈咪最大 提交于 2019-12-11 01:22:19
问题 How come I can't translate dynamically resp. using a variable with i18next? For example in my JS-file I got this: Here I use a variable and assign it to the i18n function and it doesn't work: //this does not work: var dynamicTranslation = "myText.toBetranslated"; console.log("translation dynamic ", !{JSON.stringify(t(dynamicTranslation))}); Here I hardcoded the string from above directly into the i18n function and it does work: //inserted string is the same string as in dynamic translation

How to get i18next-node to display umlauts the right way?

若如初见. 提交于 2019-12-10 11:44:06
问题 I searched around quite a bit but couldn't find a solution for my problem. My app uses i18next and it works fine except for one issue: german umlauts (ü,ö,ä) are displayed as �. I don't understand were I got it wrong, since this example app has no problem with umlauts: http://i18next-example1.eu01.aws.af.cm/?setLng=de-DE (github: https://github.com/rbeere/i18next-jade-express-sample) How can I figure this one out? 回答1: The culprit might be: The Translation.json file is not saved as UTF8. If

i18next translation problems

独自空忆成欢 提交于 2019-12-08 02:22:14
问题 I still try to use i18next for translations of my jQuery application. After some general problems (solved here: How to use i18next? Problems with translations) and there solution I wanted to translate all my visible text. But here I got problems and I need help to solve this. I hope someone can help me. <html> <head> <meta http-equiv="content-type" content="text/html; charset="UTF-8"> <link href="jquery-mobile/jquery.mobile.theme-1.0.min.css" rel="stylesheet" type="text/css"/> <link href=