rxaviers / cldr-data-npm

Npm module for Unicode CLDR JSON data
MIT License
42 stars 28 forks source link

Load all Locales #61

Open andreoliveira56 opened 6 years ago

andreoliveira56 commented 6 years ago

Hi! How can I load all the locales?

I am in a project that expects to adapt to all languages/formats.

And in ll the example I can find, I need to do something like:

import likelySubtags from 'cldr-data/supplemental/likelySubtags.json';
import currencyData from'cldr-data/supplemental/currencyData.json';
import weekData from'cldr-data/supplemental/weekData.json';

import bgLocalCurrency from'cldr-data/main/bg/currencies.json';
import bgNumbers from'cldr-data/main/bg/numbers.json';
import bgCaGregorian from'cldr-data/main/bg/ca-gregorian.json';
import bgDateFields from'cldr-data/main/bg/dateFields.json';

import gbLocalCurrency from'cldr-data/main/en-GB/currencies.json';
import gbNumbers from'cldr-data/main/en-GB/numbers.json';
import gbCaGregorian from'cldr-data/main/en-GB/ca-gregorian.json';
import gbDateFields from'cldr-data/main/en-GB/dateFields.json';

import { IntlProvider, load } from '@progress/kendo-react-intl';
import { DateFormatter } from './DateFormatter.jsx';
import { CurrencyFormatter } from './CurrencyFormatter.jsx';
import { Chooser } from './Chooser.jsx';

load(
    likelySubtags,
    currencyData,
    weekData,
    bgLocalCurrency,
    bgNumbers,
    bgCaGregorian,
    bgDateFields,
    gbLocalCurrency,
    gbNumbers,
    gbCaGregorian,
    gbDateFields
);

Obviously, this is not great.

I tried to do import data from 'cldr-data' but webpack explodes. Then I tried to do something like const caGregorian = require('cldr-data/main/' + name + '/ca-gregorian.json') but it explodes as well.

Is there a way to include all the locales? Is there a better way to handle this?

I really dont know and I would appreciate some help.

Thanks.


Update 1: I get the error when I try to require cldr-data Module not found: Error: Can't resolve 'fs' in '....\node_modules\cldr-data'