Coder Social home page Coder Social logo

react-redux-i18n's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-redux-i18n's Issues

Layout rerender with every language change

Hi,

I have component which contain load data in useEffect and render menu + language selector.

const Layout = ({loadCurrencies, loadLanguages, loadMessages}: Props): ReactNode => {

  useEffect(() => {
       // this is called with every language change
      loadCurrencies();
      loadLanguages();
      loadMessages();
  }, []);

return (
<>
   <MyMenu />
   <MyLanguageSelect />
</>
);

}

I am facing to problem with change language. Every language change trigger useEffect in my Layout component which is performance difficulty and application get stuck for a moment.

Did somebody solve similar problem?

Fallback

Hi!
How can I handle the fallback of the language?
Example:

  1. I want to translate Common.stringToTranslate
  2. react-redux-i18n does not find the string to translate
  3. react-redux-i18n shows the fallback hard coded string

i need a component like this
<Translate value="Common.stringToTranslate" fallback="this is the fallback string" />

Get current locale

Hi, this library is awesome. I am wondering, is there anyway to get the current locale name???

fix for react/redux app with Immutable js

hey! for some reason I can not create PR.

please verify and add update code when you get a chance:

in method "syncTranslationWithStore" replace

store.getState().i18n
to

store.getState().i18n ? store.getState().i18n.translations : store.getState().toJS().i18n.translations;

Problems Switching language

Hi When I use this:

I18n.t('dialog.contentComponent.componentType.picture')

Language switching is not possible any more.

I have this:

import {applyMiddleware, combineReducers, createStore} from "redux";
import thunk from "redux-thunk";
import {i18nReducer, loadTranslations, setLocale, syncTranslationWithStore} from "react-redux-i18n";

import {de} from "../locales/de";
import {en} from "../locales/en";
export const translationsObject = {
    de: de,
    en: en
};

const store = createStore(
    combineReducers({
        i18n: i18nReducer
    }),
    applyMiddleware(thunk)
);
syncTranslationWithStore(store);
store.dispatch(loadTranslations(translationsObject));
store.dispatch(setLocale('de'));
export default store;

and this for switching

    changeLanguage= (e) => {
        console.log("Change Language");
        e.preventDefault();
        if (store.getState().i18n.locale === "de") {
            store.dispatch(setLocale('en'));
        } else {
            store.dispatch(setLocale('de'));
        }
    };

Html tags are rendering

Hi,

I would like to add some return line in html tag with
like the example :

two_lines: 'Line 1<br />Line 2'

But when I display the content of this translation key, it's also rendering the html tags as text in the browser. Why ?

Looking for new maintainers

As we don't use the library day to day anymore, unfortunately we can't meet the proper maintenance requirements. To keep the project rolling, we're looking for a new maintainer (and owner).

If you're interested in taking over the project, please reach me by [email protected] or original project author - Gerben [email protected]

Hi, are people still using this?

My name is Artis and I'm the maintainer of this repo. I created it as a fork for my client I did contract work for. My contract ended and I forgot about this repo, abandoning it completely. I wonder if people are still using it and would like to receive updates?

can't get language switching reactive with redux

I'm using react-native with redux, here is my code :

import { createStore, applyMiddleware, combineReducers } from 'redux';
import thunk from 'redux-thunk';
import { i18nReducer, loadTranslations, setLocale, syncTranslationWithStore } from 'react-redux-i18n';
import { AsyncStorage } from 'react-native';
import { translationsObject } from '../i18n-config';
import rootReducer from '../reducers/index';

export default function configureStore() {
  const receiveLoginDetails = (value) => {
    if (value === null) {
      // default language
      AsyncStorage.setItem('appLang', 'fr')
        .then((value2) => {
          store.dispatch(setLocale(value2));
        });
    } else {
      store.dispatch(setLocale(value));
    }
  };

  const store = createStore(
    combineReducers({
      rootReducer,
      i18n: i18nReducer,
    }),
    applyMiddleware(thunk),
  );

  if (module.hot) {
    module.hot.accept('../reducers', () =>
      store.replaceReducer(require('../reducers/index')));
  }
  syncTranslationWithStore(store);
  store.dispatch(loadTranslations(translationsObject));
  AsyncStorage.getItem('appLang').then(receiveLoginDetails);
  return store;
}

When I switch language I need to reload app to see the strings change.

How to switch locale on user's request?

I understand that the language can be changed by changing the store.dispatch(setLocale('nl'));

But how do I switch locale on user's request? For example:

<a href="/nl" onClick={changeLanguage('nl')}>NL
<a href="/en" onClick={changeLanguage('en')}>EN

How to change setLocale for all the components, when clicking the different language links?

Translating a group of Objects/Strings

Is that possible to translate on the fly a group of strings, for instance, assuming a list of fruits :
['banana', 'apple', 'apricot', 'pineapple'] to the equivalent list in another language ?
A specific use case, would be Dropdown lists, for which rendering is updated if the user selects another language.

Passing in locale

How can I pass inside t() function argument with locale value, for exception cases?

t(key, {locale: locale-key})

re-render on setLocale()

Hi,
I'm using the I18n.t helper and when I make a dispatch(setLocale('fr')) it does change the I18n language, but it doesn't re-render all the text using it.
Anyone got an Idea how to make it work?

update locale at runtime

Hi there your work is really cool..But i have an issue.i have to issue an action which changes the locale at runtime.the action fires correctly and changes the state tree accordingly but the view isnt updated unless i refresh the page.Is there a way to achieve this dynamically? thank you

how can be refreshed strings generated from I18n.t helper

Hi,

In our web application based on Redux and React, we have a drop down to change dynamically of language. component refresh workd fine. But as you mentionned in the readme file, I18n.t helper refresh is up to us.
Actually, we use this helpers for tooltips like this :

< li title={I18n.t("application.tooltip.displayRecent")}>
< Translate value="application.navigation.navRecent"/>
< /li>

How can we handle the refresh for helpers ?

Thanks

Flicker on every re-render

I am relatively new to this package but I have noticed that every time I re-render the page the locale variable shows up before the text (value) and it causes a flicker. Does anyone else have this issue? We are using it on our React webpage.

Where do you actually store your translation object?

Has anyone used this for a real large project that might need to support multiple different languages? I find it hard to believe that having all your translations inline in app.js is sustainable on a large scale. I would like to separate my translation files by component for maximum portability and modularization (I understand the overhead this adds to the task of translating), but I'm not sure how best to do that with this package.

Example, please...

Hi.
Please, one small example...One small example is better then 100 words...

Not capitalize translation with react-i18nify 1.11.12

translation = {
  en: {
    common: {
    }
  },
  ko: {
    common: {
      helloWorld: '안녕하세요',
    }
  }
}

When translation object is given like above and locale is en,
I18n.t('common.hello') is suppose to return 'Hello World'.

But with react-i18nify 1.11.2 the result is 'helloWorld'.
After force-downgrade react-i18nify 1.8.8 works fine.

Using multiple files

Can I separate my translation files by language and start the component through this folder setting the locale? For example: file.pt-BR.json, file.en-US.json...

Best Regards,

Please add a License file

Hi
Under which license is this library available? Could you please add a LICENSE.txt file?
Thanks in advance

It will not work in the next major version of React

Thanks for your great i18n library.
I tried and worked fine.
But I have the following warning message on Google Chrome Console.
Could you confirm that?

Warning: You are manually calling a React.PropTypes validation function for the value prop on t. This is deprecated and will not work in the next major version. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details.

react-redux-i18n Under redux-saga

Hey, Great work im trying to run this code under redux-saga but i got severals erros when im trying to dispatch cause of the plain objects, do u have any suggestion, thx in advance, im kinda new on this

LTS key for localization does not work as expected

Using <Localize value={value} dateFormat="LTS" /> does not return 01.01.2018 12:16:20 PM as expected from moment.js documentation.
It returns 01.01.2018t20 (as using L and S key separately with t as string constant).

Set initial state

Hello,

Still using this lib ;)

I was wondering if it is possible to add the possibility to set an initialState to the reducer, so that loadTranslations and setLocale action don't have to be called immediately after store create which doesn't really make sense in the redux philosophy IMHO.

Here's how it would look like:

export const i18nReducerWithInitialState =  initialState = {} => {
  return (state = initialState, action) => {
    // ...
  }
}

export default i18nReducerWithInitialState({}); // for backward compatibility, 

and it would be called like:

import { combineReducers } from 'redux';
import {i18nReducerWithInitialState} from 'react-redux-i18n';
import translations from 'myproject';

const defaultLocale = 'en';

const combinedReducers = combineReducers({
  user: userReducer,
  i18nReducerWithInitialState({locale: defaultLocale, translations}),
});

Proptypes error with react 15.5.X and up

 Warning: Accessing PropTypes via the main React package is deprecated, and will be removed in  React v16.0. Use the latest available v15.* prop-types package from npm instead. For info on usage, compatibility, migration and more, see https://fb.me/prop-types-docs

Be able to pass a prop onClick on a translatable value.

Hi!

Thanks for this awesome plugin.
I'm looking for the best solution for this case:

<Translate dangerousHTML value="I want to click <a href="#" onClick={()=>(make something)}>here to do something."

Right now, dividing the sentence into 3 parts is the only way I can handle it, is there any possibility to add props or something to make events?

Adding Translation in an html attribut

I'm using the react-redux-i18n extension to translate my strings ...

for that I do the following stuff:

var T = require('react-redux-i18n').Translate;
and to translate a string in view I have this:

<p><T value="processes.new.description"/></p>
That works fine.

But Now is the question how to use it in react-toolbox Inputs and so on ...

For example this is not working:

<Input type='text' label={<t value="processes.new.inputTitle" />} name='name' value={this.state.name} onChange={this.handleChange.bind(this, 'name')} maxLength={16} />
The label is not printed ... whats the problem?

Thanks.

[react native] release build error: [BABEL] Unkwown option **/node_modules/react-redux-i18n/build/index.js

I'm facing a strange error when trying to build a react-native in release mode (prod env). Note: dev build works.

/Users/**/myapp/node_modules/react-redux-i18n/build/index.js: [BABEL] 
/Users/**/myapp/node_modules/react-redux-i18n/build/index.js: Unknown option: 
/Users/**/myapp/node_modules/react/index.js.Children. 
Check out http://babeljs.io/docs/usage/options/ for more information about options.

From a research, I understand that babel doesn't know how to import Children or React from react in this file: react-redux-i18n/build/index.js, which doesn't contain any react import.

Does someone has an idea?


.babelrc

{
  "presets": ["react-native"],
  "plugins": [
    ["module-resolver", {
      "root": ["./src"],
      "alias": {
        "@src": "./src",
        "@App": "./src/App.js",
        "@config": "./src/config.js",
        "@common": "./src/common",
        "@utilities": "./src/common/utilities",
        "@flow-types": "./src/flow-types",
        "@styles": "./src/styles",
        "@components": "./src/components",
        "@pages": "./src/components/pages",
        "@forms": "./src/components/forms",
        "@fields": "./src/components/fields",
        "@ui": "./src/components/ui",
        "@hoc": "./src/hoc",
        "@actions": "./src/actions",
        "@actionsTypes": "./src/actions/actionsTypes",
        "@selectors": "./src/selectors"
      }
    }]
  ],
  "env": {
    "development": {
      "plugins": [
        [
          "flow-react-proptypes",
          { "ignoreNodeModules": true }
        ]
      ]
    }
  }
}

package.json

"react": "16.2.0",
"react-native": "0.53.3",
"react-redux-i18n": "^1.9.2",


"babel-plugin-flow-react-proptypes": "^19.1.0",
"babel-plugin-module-resolver": "^3.1.0",
"babel-preset-react-native": "4.0.0",

react-i18nify update

It's recommended to update react-i18nify dependency to 1.9.1, where react dependency was added to peerDependencies. It will avoid duplications of react lib in my project, since we use react@^16

redux sync bug

export const loadTranslations = translations => dispatch => { I18n.forceComponentsUpdate(); dispatch({ type: LOAD_TRANSLATIONS, translations, }); };

I18n.forceComponentsUpdate should be fired after action dispatch. Or better solution component should listen store on LOAD_TRANSLATION action and then fire forceComponentsUpdate.

Helpers dont make hot change

var I18n = require('react-redux-i18n').I18n;

I used this helper and when I change language it does not change language of another component's content until another event triggers (does not make hot change.

If you tell me how I can get text instead of span element inside the Translate component I will get over my problem.
Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.