Coder Social home page Coder Social logo

Comments (15)

francescarpi avatar francescarpi commented on September 16, 2024

Hi,

I'll check it today.

Thanks

from redux-i18n.

francescarpi avatar francescarpi commented on September 16, 2024

Hi!

Do you have "redux-logger" or something like that for see the store before and after to dispatch action?

I have added some tests for check this and all works fine.

53db59b

Can you show me your i18nState store content, please?

Thanks.

from redux-i18n.

sideisra avatar sideisra commented on September 16, 2024

prev state:

i18nState:{
  lang: "en"
}

action:

{
  type: "REDUX_I18N_SET_LANGUAGE",
  lang: "de-DE"
}

next state:

i18nState:{
  lang: "de-DE"
}

Thats what happens in my store and thats what i would expect. But the component seems to use the string "de-DE" as-is but can't find any translation because the translations look like this:

export const i18n = {
    translations: {
        de: {
            "Logout": "Abmelden",
        },
    },
};

from redux-i18n.

francescarpi avatar francescarpi commented on September 16, 2024

OMG!

You are right. I'm going to think how resolve it and upload a new version soon.

Thanks

from redux-i18n.

francescarpi avatar francescarpi commented on September 16, 2024

Hi,

I just created a new tag (1.1.2) that solve this problem. Please, try it and tell me if you find any errors.

Thank you so much.

from redux-i18n.

sideisra avatar sideisra commented on September 16, 2024

Thank you very much.

I tested the new version and 'de-DE' now works but only when i change the translations to:

export const i18n = {
    translations: {
        'de-DE': {
            "Logout": "Abmelden",
        },
    },
};

It works for IE but not for firefox because firefox returns 'de' as language. I think the most robust approach would be to fall back to 'de' when 'de-DE' is not available in the translations.

Should i create a new issue for that?

from redux-i18n.

francescarpi avatar francescarpi commented on September 16, 2024

Hi!

I've modified import script for generate the file as you show me. If you run your import script (from .po to translation.js) you can see it.

Try it, please and tell me.

Best regards.

from redux-i18n.

sideisra avatar sideisra commented on September 16, 2024

We don't use a po file we write the translations.js directly.

from redux-i18n.

francescarpi avatar francescarpi commented on September 16, 2024

Hi,

I'm not sure I understand to you. I just uploaded a new versión with "demo" app. Please, can you pull from github, install demo app and try it?

Tell me if works fine on chrome, firefox, IE, etc...

Best regards.

from redux-i18n.

sideisra avatar sideisra commented on September 16, 2024

Hi,

sorry i didn't recognise the demo. I tried it an now it works for "de-DE" but not for "de" any more. Sometimes there are multiple language codes (e.g. "de-DE", "de-CH" or even "de") which should fall back to the same translation (e.g. "de").

In my case with the new version i would have to duplicate the translation: "de" and "de-DE"

Best regards

from redux-i18n.

francescarpi avatar francescarpi commented on September 16, 2024

Hi,

you can have as many languages as you want. For example:

export const translations = {
  'de-DE': {
    'Hello world!': 'Hallo Welt!',
  },
  'es': {
    'Hello world!': '¡Hola mundo!',
  },
  'de-CH': {
    'Hello world!': 'Hallo Welt!',
  },
  'de': {
    'Hello world!': 'Hallo Welt!',
  },
}

And then, activate the language that you need:

this.props.dispatch(setLanguage('de-CH'))
this.props.dispatch(setLanguage('de-DE'))
this.props.dispatch(setLanguage('de'))

For test "demo", you should checkout repo and:

cd demo
npm install
npm start

And go to: http://localhost:8000

Best regards.

from redux-i18n.

sideisra avatar sideisra commented on September 16, 2024

Hm i don't want to define a translation for every language ("de-DE", "de-CH") because the translations would be the same. They would be duplicates.

It would be much more convenient when languages like "de-DE" or "de-CH" have the fallback "de" so that i have to provide "de" only.

from redux-i18n.

francescarpi avatar francescarpi commented on September 16, 2024

Ok. Perfect :). Now I understand to you fine. I can make that if language is not in translations dictionary and has "-", make an split and take first part.

I like it, this is a good new feature.

Thanks!

from redux-i18n.

francescarpi avatar francescarpi commented on September 16, 2024

Hi!

You have a new version (1.1.4)

;)

Best regards.

from redux-i18n.

sideisra avatar sideisra commented on September 16, 2024

It works. Thank you very much :-)

from redux-i18n.

Related Issues (20)

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.