Commit b042d2b3 authored by Zach Pomerantz's avatar Zach Pomerantz Committed by GitHub

fix: i18n resolution (#3299)

parent 897e7f45
REACT_APP_INFURA_KEY="4bf032f2d38a4ed6bb975b80d6340847" REACT_APP_INFURA_KEY="4bf032f2d38a4ed6bb975b80d6340847"
REACT_APP_LOCALES="locales"
\ No newline at end of file
...@@ -17,7 +17,7 @@ module.exports = (webpackConfig) => ({ ...@@ -17,7 +17,7 @@ module.exports = (webpackConfig) => ({
'process.env': { 'process.env': {
...plugin.definitions['process.env'], ...plugin.definitions['process.env'],
REACT_APP_IS_WIDGET: true, REACT_APP_IS_WIDGET: true,
REACT_APP_LOCALES: "'../locales'", REACT_APP_LOCALES: '"../locales"',
}, },
}) })
} }
......
...@@ -23,7 +23,7 @@ import { CompilerOptions } from 'typescript' ...@@ -23,7 +23,7 @@ import { CompilerOptions } from 'typescript'
const REPLACEMENTS = { const REPLACEMENTS = {
'process.env.REACT_APP_IS_WIDGET': true, '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'] const EXTENSIONS = ['.js', '.jsx', '.ts', '.tsx']
......
...@@ -81,9 +81,7 @@ export async function dynamicActivate(locale: SupportedLocale) { ...@@ -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: // 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 // see https://github.com/lingui/js-lingui/issues/388#issuecomment-497779030
const catalog = const catalog =
locale === DEFAULT_LOCALE locale === DEFAULT_LOCALE ? DEFAULT_CATALOG : await import(`${process.env.REACT_APP_LOCALES}/${locale}`)
? DEFAULT_CATALOG
: await import(`${process.env.REACT_APP_LOCALES || 'locales'}/${locale}`)
i18n.load(locale, catalog.messages) i18n.load(locale, catalog.messages)
i18n.activate(locale) i18n.activate(locale)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment