Skip to content

Missing locale data for: "en-US". Using default locale: "en" as fallback. #204

Closed

Description

@catamphetamine
[React Intl] Missing locale data for: "en-US". Using default locale: "en" as fallback.

Activity

  1. changed the title [-][React Intl] Missing locale data for: "en-US". Using default locale: "en" as fallback.[/-] [+]Missing locale data for: "en-US". Using default locale: "en" as fallback.[/+] on Nov 3, 2015
  2. catamphetamine commented on Nov 3, 2015

    @catamphetamine
    Author

    I found the cause of the error:

    <IntlProvider locale={locale} messages={messages}>
    

    It doesn't support a properly formatted locale.

    A workaround:

    function get_language(locale)
    {
        const dash_index = locale.indexOf('-')
        if (dash_index >= 0)
        {
            return locale.substring(0, dash_index)
        }
        return locale
    }
    
    // not real locale
    <IntlProvider locale={get_language(locale)} messages={messages}>
    
  3. ericf commented on Nov 3, 2015

    @ericf
    Collaborator

    You'll need to load locale-data/en.js to get support for en-US. By default only the root, en locale data is provided.

    It doesn't support a properly formatted locale.

    This is incorrect. The locale data files are provide per language, e.g. en.js, but they contain data for all locales in that language, e.g. en-US, en-GB, etc.

  4. added 4 commits that reference this issue on Jan 13, 2016
    1dc62da
    3575e9e
    5f1397f
    36bd26e
  5. SachaG commented on Jun 9, 2016

    @SachaG

    I just ran into this issue. So just to clarify, in the following snippet fr works but fr_FR doesn't:

    import fr from 'react-intl/locale-data/fr';
    import { addLocaleData } from 'react-intl';
    addLocaleData([...fr]);
    ...
    <IntlProvider locale="fr" messages={myStrings}>
    

    Is that the expected behavior? What would I need to do if I did want to use fr_FR or fr_CA instead?

  6. ericf commented on Jun 9, 2016

    @ericf
    Collaborator

    @SachaG The locale needs to be a BCP-47 language tag. Replace _ with -.

  7. mccrodp commented on Feb 19, 2018

    @mccrodp

    Hey @ericf, thanks for your answers. I am getting this in Gatsby w/ community i18n plugin. I have added the locale-data as you can see here, but I still get the below error. Any more specific ideas to what is missing? I have only de and en-US langs set, no en at the moment as it's not my repo.

    commons.js:77217 [React Intl] Missing message: "selectLanguage" for locale: "en-US"
    commons.js:77217 [React Intl] Missing message: "selectLanguage" for locale: "de"
    commons.js:77217 [React Intl] Missing message: "selectLanguage" for locale: "en"

    This seems to be workign now via:

    import { addLocaleData } from 'react-intl';
    
    import en from 'react-intl/locale-data/en';
    import 'intl/locale-data/jsonp/en';
    
    addLocaleData(en); // It seems this also adds "en-US" locale?
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions