Skip to content

Commit

Permalink
fix: Magic Folders localization does not work with Metro
Browse files Browse the repository at this point in the history
Metro does not support dynamic requires and the error was swallowed by
an empty catch.

Replaced the dynamic requires with explicit imports.

I missed this problem before because the warning was not obvious in
flagship app logs and since I did not remove magic folders for my tests
but just the destination folder, magic folders references where still
present and did their job.
  • Loading branch information
doubleface authored and doubleface committed Oct 5, 2023
1 parent e5aeef0 commit abf767b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions docs/api/cozy-client/modules/models.document.locales.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

*Defined in*

[packages/cozy-client/src/models/document/locales/index.js:23](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/models/document/locales/index.js#L23)
[packages/cozy-client/src/models/document/locales/index.js:21](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/models/document/locales/index.js#L21)

***

Expand All @@ -61,4 +61,4 @@

*Defined in*

[packages/cozy-client/src/models/document/locales/index.js:43](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/models/document/locales/index.js#L43)
[packages/cozy-client/src/models/document/locales/index.js:41](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/models/document/locales/index.js#L41)
12 changes: 5 additions & 7 deletions packages/cozy-client/src/models/document/locales/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import Polyglot from 'node-polyglot'

import { getEmojiByCountry } from '../emojiCountry'
import enLocale from './en.json'
import frLocale from './fr.json'

const locales = { en: enLocale, fr: frLocale }

const polyglots = {}
const langs = ['fr', 'en']
for (const lang of langs) {
let locales = {}
try {
locales = require(`./${lang}.json`)
} catch (e) {
// eslint-disable-line no-empty-block
}
const polyglot = new Polyglot()
polyglot.extend(locales)
polyglot.extend(locales[lang])
polyglots[lang] = polyglot
}

Expand Down

0 comments on commit abf767b

Please sign in to comment.