Skip to content

Commit

Permalink
fix: i18n resolution (#3299)
Browse files Browse the repository at this point in the history
  • Loading branch information
zzmp authored Feb 11, 2022
1 parent 897e7f4 commit b042d2b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
REACT_APP_INFURA_KEY="4bf032f2d38a4ed6bb975b80d6340847"
REACT_APP_INFURA_KEY="4bf032f2d38a4ed6bb975b80d6340847"
REACT_APP_LOCALES="locales"
2 changes: 1 addition & 1 deletion cosmos.override.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = (webpackConfig) => ({
'process.env': {
...plugin.definitions['process.env'],
REACT_APP_IS_WIDGET: true,
REACT_APP_LOCALES: "'../locales'",
REACT_APP_LOCALES: '"../locales"',
},
})
}
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { CompilerOptions } from 'typescript'

const REPLACEMENTS = {
'process.env.REACT_APP_IS_WIDGET': true,
'process.env.REACT_APP_LOCALES': "'./locales'",
'process.env.REACT_APP_LOCALES': '"./locales"',
}

const EXTENSIONS = ['.js', '.jsx', '.ts', '.tsx']
Expand Down
4 changes: 1 addition & 3 deletions src/lib/i18n.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ export async function dynamicActivate(locale: SupportedLocale) {
// There are no default messages in production; instead, bundle the default to save a network request:
// see https://github.com/lingui/js-lingui/issues/388#issuecomment-497779030
const catalog =
locale === DEFAULT_LOCALE
? DEFAULT_CATALOG
: await import(`${process.env.REACT_APP_LOCALES || 'locales'}/${locale}`)
locale === DEFAULT_LOCALE ? DEFAULT_CATALOG : await import(`${process.env.REACT_APP_LOCALES}/${locale}`)
i18n.load(locale, catalog.messages)
i18n.activate(locale)
}
Expand Down

0 comments on commit b042d2b

Please sign in to comment.