rxaviers / react-globalize-webpack-plugin

react-globalize webpack plugin
Other
3 stars 8 forks source link

developmentLocale seems to block entry in supportedLocale #19

Open hrimhari opened 8 years ago

hrimhari commented 8 years ago

I specify developmentLocale: "en" and I have "en" in the list of supportedLocales.

If I don't say anything to Globalize about which locale to use in the app, it will pick the last one loaded.

I wanted to force it to use "en", so I manually did Globalize.locale("en"), but instead of loading the customized messages for "en" it used the default messages in the application.

My app has:

<FormatMessage>msgTest</FormatMessage>
<FormatMessage variables={{ number: numberFormatter( 123.456 ) }}>{"Globalize.formatNumber: {number}"}</FormatMessage>

My localization:

{
    "en": {
        "Globalize.formatNumber: (number)": "English Globalize.formatNumber: {number}",
        "msgTest": "This is a test message"
    },
    "fr": {
        "Globalize.formatNumber: (number)": "Globalize.formatNumber: numéro {number}",
        "Test fallback": "Test fallback",
        "msgTest": "Ceci est un message de test"
    },
    "pt": {
        "Globalize.formatNumber: (number)": "Globalize.formatNumber: número {number}",
        "Test fallback": "Teste de fallback",
        "msgTest": "Mensagem de teste"
    }
}

If Globalize.locale("fr"), I see in the browser:

Ceci est un message de testGlobalize.formatNumber: numéro 123,46

If Globalize.locale("en"), I see in the browser:

msgTestGlobalize.formatNumber: 123,46

Also a comma where I should be seeing a dot...

My plugin configuration:

        messages: "./src/messages.json",
        production: true,
        developmentLocale: "en",
        supportedLocales: [ "en", "fr", "pt" ],
        output: "i18n/[locale].js"
johannott commented 7 years ago

Hi @rxaviers I am also seeing this issue outlined by @hrimhari where in en the key is displayed instead of the value, in other words it is not getting replaced.

In my code I try to use the method where the string value is placed directly in FormatMessage and so then the key/value pairs in en are the same. There is times however where I need to use a different key e.g message-1 but it does not get picked up from the json.

Have you seen this issue?