Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use locales crash the app on start in release

See original GitHub issue

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 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 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:

          locale={{name: 'fr', config: 
months: 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split(
        monthsShort: 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split(
        monthsRegex: monthsRegex,
        monthsShortRegex: monthsRegex,
        monthsStrictRegex: monthsStrictRegex,
        monthsShortStrictRegex: monthsShortStrictRegex,
        monthsParse: monthsParse,
        longMonthsParse: monthsParse,
        shortMonthsParse: monthsParse,
        weekdays: 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
        weekdaysShort: 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
        weekdaysMin: 'di_lu_ma_me_je_ve_sa'.split('_'),
        weekdaysParseExact: true,
        longDateFormat: {
            LT: 'HH:mm',
            LTS: 'HH:mm:ss',
            L: 'DD/MM/YYYY',
            LL: 'D MMMM YYYY',
            LLL: 'D MMMM YYYY HH:mm',
            LLLL: 'dddd D MMMM YYYY HH:mm',
        calendar: {
            sameDay: '[Aujourd’hui à] LT',
            nextDay: '[Demain à] LT',
            nextWeek: 'dddd [à] LT',
            lastDay: '[Hier à] LT',
            lastWeek: 'dddd [dernier à] LT',
            sameElse: 'L',
        relativeTime: {
            future: 'dans %s',
            past: 'il y a %s',
            s: 'quelques secondes',
            ss: '%d secondes',
            m: 'une minute',
            mm: '%d minutes',
            h: 'une heure',
            hh: '%d heures',
            d: 'un jour',
            dd: '%d jours',
            w: 'une semaine',
            ww: '%d semaines',
            M: 'un mois',
            MM: '%d mois',
            y: 'un an',
            yy: '%d ans',
        dayOfMonthOrdinalParse: /\d{1,2}(er|)/,
        ordinal: function (number, period) {
            switch (period) {
                // TODO: Return 'e' when day of month > 1. Move this case inside
                // block for masculine words below.
                // See
                case 'D':
                    return number + (number === 1 ? 'er' : '');

                // Words with masculine grammatical gender: mois, trimestre, jour
                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.


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:

          locale={{name: 'fr-ch', config: localeFrCh }}

Wouldn’t that be cleaner and better developer experience?

Who can help me? What can I do to fix this?

Thanks for your help and input!

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

Looooongcommented, May 12, 2022

I have the similar crash where moment complain that the specified locale passed to the calendar strip prop is not loaded/configured. It turns out that I have 2 different versions of moment, one installed in node_modules/moment and the other installed in node_modules/react-native-calendar-strip/node_modules/moment.

Because of this, I got the following behaviours:

  • My app moment configured with our locale is not reflected on RN calendar strip because the library is using its own version of moment which still uses the default locale.
  • In development mode, passing locale via locale prop does not change the localization inside RN calendar strip because the specified locale is not loaded/configured for the RN calendar strip’s moment.
  • In production mode, passing locale via locale prop results in a crash because the specified locale is not loaded/configured.

The temporary workaround

  • Specify resolutions in package.json:
  "resolutions": {
    "moment": "^2.29.0"
  • Ensure that node_modules/react-native-calendar-strip/node_modules/moment does not exist after running yarn install.
  • After that, we can configure the locale and use RN calendar strip without passing locale prop.
import moment from 'moment'
import 'moment/locale/vi'


The permanent fix

moment should be specified as peer dependency inside the library’s package.json.

trongtv147commented, Jul 26, 2022

This is what I tried: import ‘react-native-calendar-strip’; import ‘react-native-calendar-strip/node_modules/moment/locale/vi’;

Read more comments on GitHub >

github_iconTop Results From Across the Web

App crash in release mode due to localizations after null ...
After null-safety migration and update Flutter sdk from 2.8.0 to 3.3.4, my app crashes on launch in release mode.
Read more >
App crashes immediately on start u… | Apple Developer Forums
I have an iPhone app which is crashing on iOS9 devices only after being released through TestFlight or the App Store. The build...
Read more >
React Native Android release build crash on device - Medium
For me when I found my app is crashing on device, I connected my device with my loptop and used adb logcat command...
Read more >
Troubleshooting build errors and crashes - Expo Documentation
If your native toolchains are installed correctly and you are unable to build and run your project in release mode on your local...
Read more >
Is your app crashing on TestFlight? Issues and potential ...
Try building and testing the app in RELEASE mode locally. · Check if third-party dependencies work with RELEASE mode. · Check compiler ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found