i18next

i18next translation outside component

為{幸葍}努か 提交于 2021-02-07 14:43:35
问题 I'm new for i18next, trying to localize/translate website. Everything works for translation inside of component, but outside (means json files with i18n.t() it doesn't retrieve needed information, instead showing default value. I'm using create-react-app and it's default settings for folders reference, maybe this is the key problem, but I can't find out why and what to change. import i18n from '../../i18n'; const navigation = [ { 'id' : 'dashboard', 'title' : i18n.t('analytics.title', 'NOT

How to type check i18n dictionaries with TypeScript?

Deadly 提交于 2021-02-04 17:29:12
问题 Is there a possibility to type check existing keys in react-i18next dictionaries? So that TS will warn you during compile time if key doesn't exist. Example. Suppose, we have this dictionary: { "footer": { "copyright": "Some copyrights" }, "header": { "logo": "Logo", "link": "Link", }, } If I provide non-existent key, TS should blow up: const { t } = useTranslation(); <span> { t('footer.copyright') } </span> // this is OK, because footer.copyright exists <span> { t('footer.logo') } </span> //

How to type check i18n dictionaries with TypeScript?

人走茶凉 提交于 2021-02-04 17:29:06
问题 Is there a possibility to type check existing keys in react-i18next dictionaries? So that TS will warn you during compile time if key doesn't exist. Example. Suppose, we have this dictionary: { "footer": { "copyright": "Some copyrights" }, "header": { "logo": "Logo", "link": "Link", }, } If I provide non-existent key, TS should blow up: const { t } = useTranslation(); <span> { t('footer.copyright') } </span> // this is OK, because footer.copyright exists <span> { t('footer.logo') } </span> //

Unable to use JSON from S3 buck in i18next

早过忘川 提交于 2021-01-29 12:32:54
问题 This is how my i18n file looks like - import i18n from 'i18next' import { initReactI18next } from 'react-i18next' import HttpApi from 'i18next-http-backend'; i18n .use(HttpApi) .use(initReactI18next) .init({ // resources: resourcesObj, initImmediate: false, backend: { loadPath: 'https://bucketlink.amazonaws.com/locales/{{lng}}/{{ns}}.json', crossDomain: true, allowMultiLoading: true, }, lng: "en", fallbackLng: "en", debug: false, ns: ["translations"], defaultNS: "translations", keySeparator:

react-i18next doesn't translate

允我心安 提交于 2021-01-29 05:59:02
问题 I have tryed to implement react-i18next to my react application but it doesn't give a f... that I want it to work Console doesn't show any error. It just doesn't translate. Anyone had similar problem and can help me figure out why it doesn't translate? my i18n.js file content: import i18n from 'i18next'; import { initReactI18next } from 'react-i18next'; import translationPL from './translations/pl/common.json'; const resources = { pl: { translation: translationPL } }; i18n .use

Cannot get react-i18next to read JSON files via FETCH backend

这一生的挚爱 提交于 2021-01-29 03:42:55
问题 I'm trying to use react-i18next on the client using the i18next-fetch-backend , and even though I can get to the JSON translation files via a browser, something is screwy with how they're being handled during the init routine. For the record, I'm using create-react-app as the basis of my front-end React application, if that makes a difference, and so far all of my testing is in localhost (with the React app on localhost:3000, and the "server" on localhost:8000). Here's my init file: import

HTML tags in i18next translation files in React

瘦欲@ 提交于 2020-07-07 01:40:02
问题 I'm using i18next in a project and can't get around including html tags in translation files and having them properly rendered. An example of my .json translation file: "en": { "product": { "header": "Welcome, <strong>User!</strong>" } } There is an excellent answer to this question, but relating to JQuery. I'm not using JQuery, my project is React and here is the setup that I have: import i18next from 'i18next'; import en from 'locales/en'; i18next. init({ lng: 'en', fallbackLng: false,

HTML tags in i18next translation files in React

这一生的挚爱 提交于 2020-07-07 01:37:58
问题 I'm using i18next in a project and can't get around including html tags in translation files and having them properly rendered. An example of my .json translation file: "en": { "product": { "header": "Welcome, <strong>User!</strong>" } } There is an excellent answer to this question, but relating to JQuery. I'm not using JQuery, my project is React and here is the setup that I have: import i18next from 'i18next'; import en from 'locales/en'; i18next. init({ lng: 'en', fallbackLng: false,