Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IntlNumberType.get(locale) Do not work with shorts locales #83

Closed
retyui opened this issue Oct 7, 2019 · 2 comments
Closed

IntlNumberType.get(locale) Do not work with shorts locales #83

retyui opened this issue Oct 7, 2019 · 2 comments
Assignees

Comments

@retyui
Copy link
Contributor

retyui commented Oct 7, 2019

I have interesting bug, I use locales like('en', 'ru')

_getNumberModuleForLang always return default value IntlCLDRNumberType01

Because:

locale = 'ru';

getNumberVariations() 
    => IntlNumberType.get(locale) 
        => FBLocaleToLang.get(locale) // return ''
----------------------------------^^^ here bug

Snippet:

(()=>{
    const _locToLang = {
        "cx_PH": "ceb",
        "ck_US": "chr",
        "fb_AA": "en",
        "fb_AC": "en",
        "fbt_AC": "en",
        "fb_HA": "en",
        "fb_AR": "ar",
        "fb_HX": "en",
        "fb_LS": "en",
        "fb_LL": "en",
        "fb_RL": "en",
        "fb_ZH": "zh",
        "tl_PH": "fil",
        "sy_SY": "syr",
        "qc_GT": "quc",
        "tl_ST": "tlh",
        "gx_GR": "grc",
        "qz_MM": "my",
        "eh_IN": "hi",
        "cb_IQ": "ckb",
        "zz_TR": "zza",
        "tz_MA": "tzm",
        "sz_PL": "szl",
        "bp_IN": "bho",
        "ns_ZA": "nso",
        "fv_NG": "fuv",
        "em_ZM": "bem",
        "qr_GR": "rup",
        "qk_DZ": "kab",
        "qv_IT": "vec",
        "qs_DE": "dsb",
        "qb_DE": "hsb",
        "qe_US": "esu",
        "bv_DE": "bar",
        "qt_US": "tli",
        "nh_MX": "nah",
        "tq_AR": "tob",
        "fn_IT": "fur",
        "lr_IT": "lij"
    };

    const FBLocaleToLang = {
        get: function(locale) {
            return _locToLang[locale] || locale.substring(0, locale.indexOf('_'));
        },
    };

    
    return FBLocaleToLang.get('en'); // return ""
    return FBLocaleToLang.get('ru'); // return ""
})();
@jrwats
Copy link
Contributor

jrwats commented Oct 9, 2019

@retyui you should be able to get what you want by using IntlNumberType.forLanguage. Please re-open if this doesn't work.

@jrwats jrwats closed this as completed Oct 9, 2019
@jrwats jrwats reopened this Oct 9, 2019
@jrwats
Copy link
Contributor

jrwats commented Oct 9, 2019

Actually, before I close, can you tell me where you're hitting this? Is it in the translate script?

@jrwats jrwats self-assigned this Oct 9, 2019
@jrwats jrwats assigned retyui and unassigned jrwats Oct 10, 2019
facebook-github-bot pushed a commit that referenced this issue Oct 10, 2019
Summary:
via: #83

```js
var locale = 'ru';

fbt._prama(...)
   => getNumberVariations(...)
      => IntlNumberType.get(locale)    // Always return default value `IntlCLDRNumberType01`
         => FBLocaleToLang.get(locale) // Because result here is an empty string ''

FBLocaleToLang.get('ru') => ''
FBLocaleToLang.get('zza') => ''
```
Pull Request resolved: #85

Differential Revision: D17854003

Pulled By: jrwats

fbshipit-source-id: 6011ff7587d62ec0881ec6bdf64bee0a0a41ff2f
@retyui retyui closed this as completed Oct 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants