Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
124f6420
Unverified
Commit
124f6420
authored
Mar 30, 2022
by
Zach Pomerantz
Committed by
GitHub
Mar 30, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: lazy load en-us (#3626)
parent
91f5fc08
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
10 deletions
+8
-10
locales.ts
src/constants/locales.ts
+0
-3
i18n.tsx
src/lib/i18n.tsx
+8
-7
No files found.
src/constants/locales.ts
View file @
124f6420
...
...
@@ -35,10 +35,7 @@ export const SUPPORTED_LOCALES = [
]
export
type
SupportedLocale
=
typeof
SUPPORTED_LOCALES
[
number
]
|
'
pseudo
'
// eslint-disable-next-line import/first
import
*
as
enUS
from
'
locales/en-US
'
export
const
DEFAULT_LOCALE
:
SupportedLocale
=
'
en-US
'
export
const
DEFAULT_CATALOG
=
enUS
export
const
LOCALE_LABEL
:
{
[
locale
in
SupportedLocale
]:
string
}
=
{
'
af-ZA
'
:
'
Afrikaans
'
,
...
...
src/lib/i18n.tsx
View file @
124f6420
import
{
i18n
}
from
'
@lingui/core
'
import
{
I18nProvider
}
from
'
@lingui/react
'
import
{
DEFAULT_CATALOG
,
DEFAULT_LOCALE
,
SupportedLocale
}
from
'
constants/locales
'
import
{
SupportedLocale
}
from
'
constants/locales
'
import
{
af
,
ar
,
...
...
@@ -78,12 +78,13 @@ const plurals: LocalePlural = {
export
async
function
dynamicActivate
(
locale
:
SupportedLocale
)
{
i18n
.
loadLocaleData
(
locale
,
{
plurals
:
()
=>
plurals
[
locale
]
})
// 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
}
/
${
locale
}
.js`
)
// Bundlers will either export it as default or as a named export named default.
i18n
.
load
(
locale
,
catalog
.
messages
||
catalog
.
default
.
messages
)
try
{
// There are no default messages in production,
// see https://github.com/lingui/js-lingui/issues/388#issuecomment-497779030
const
catalog
=
await
import
(
`
${
process
.
env
.
REACT_APP_LOCALES
}
/
${
locale
}
.js`
)
// Bundlers will either export it as default or as a named export named default.
i18n
.
load
(
locale
,
catalog
.
messages
||
catalog
.
default
.
messages
)
}
catch
{}
i18n
.
activate
(
locale
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment