BugiDev / BugiDev/react-native-calendar-strip

Use locales crash the app on start in release

Open
#232 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
976
Forks
336
PR merge metrics
No merged PRs in 30d

Description

Am having issues to configure the lib with 3 languages: `en`, `fr` and `de`.

I have found some issues related to the problem, but none worked for me. Some related issues include #89 #110 & #141.

For me the following elements need clarification:

- The `locale.name` uses `fr` or `en`. Should'nt we use a full language and region code like `fr-ch` or `en-uk`? This seems to have been discussed on moment.

- The `locale.name` seems to sometimes require just a language, but sometimes a region too. Depending on moment.js implementation. See `node_modules/moment/locale/*.js` for a list.

- The `locale.config` object : why do we need to pass this as we still import the locale file? Why, if I specify the whole `locale.config` file as a copy of the `moment` lib, I still require `moment` to be imported?

While digging for solutions, I have found none that worked. Seeing the amount of issues are related to localization, there seems to be a lack of documentation and maybe some refactoring is required.

# My current issue

Am just trying to set that up properly for the 3 languages stated above. I have tried many variants, but based on what I have read in the readme and in the related issues, I should do the following:

1. import the moment libs
```
import 'moment'
# required ? import 'moment/min/locales'
import 'moment/locale/en'
import 'moment/locale/de'
import 'moment/locale/fr'
```

Use component as follow:

```
1. Move this case inside
// block for masculine words below.
// See https://github.com/moment/moment/issues/3375
case 'D':
return number + (number === 1 ? 'er' : '');

// Words with masculine grammatical gender: mois, trimestre, jour
default:
case 'M':
case 'Q':
case 'DDD':
case 'd':
return number + (number === 1 ? 'er' : 'e');

// Words with feminine grammatical gender: semaine
case 'w':
case 'W':
return number + (number === 1 ? 're' : 'e');
}
},
week: {
dow: 1, // Monday is the first day of the week.
doy: 4, // The week that contains Jan 4th is the first week of the year.
}, }}
...
```
That does not work and crash on app start on release.

# Hypothese

Couldn't be the import something like:

```
import 'moment'
import 'moment/min/locales'
import localeEnGb from 'moment/locale/en-gb'
import localeDeCh from 'moment/locale/de-ch'
import localeFrCh from 'moment/locale/fr-ch'
```
Then the setup of the component like:

```

Contributor guide

Open the contributing guide

Research direction

Start with the README's locale configuration guidance and the CalendarStrip usage shown in the issue, then compare the mentioned moment/locale imports with the release-start crash. Review related issues #89, #110, and #141; done means the supported setup for en, fr, and de is documented and the release app no longer crashes.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
internationalization, mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.