Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Rocket.Chat
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RocketChat
Rocket.Chat
Commits
919fe1f3
Unverified
Commit
919fe1f3
authored
1 year ago
by
gabriellsh
Committed by
Diego Sampaio
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
chore: get translations from CDN (#30331)
parent
5e3473a2
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.changeset/soft-cows-juggle.md
+5
-0
5 additions, 0 deletions
.changeset/soft-cows-juggle.md
apps/meteor/client/providers/TranslationProvider.tsx
+5
-5
5 additions, 5 deletions
apps/meteor/client/providers/TranslationProvider.tsx
with
10 additions
and
5 deletions
.changeset/soft-cows-juggle.md
0 → 100644
+
5
−
0
View file @
919fe1f3
---
"
@rocket.chat/meteor"
:
patch
---
download translation files through CDN
This diff is collapsed.
Click to expand it.
apps/meteor/client/providers/TranslationProvider.tsx
+
5
−
5
View file @
919fe1f3
...
...
@@ -2,7 +2,7 @@ import { useLocalStorage, useMutableCallback } from '@rocket.chat/fuselage-hooks
import
languages
from
'
@rocket.chat/i18n/dist/languages
'
;
import
en
from
'
@rocket.chat/i18n/src/locales/en.i18n.json
'
;
import
type
{
TranslationKey
,
TranslationContextValue
}
from
'
@rocket.chat/ui-contexts
'
;
import
{
useMethod
,
useSetting
,
TranslationContext
,
useAbsoluteUrl
}
from
'
@rocket.chat/ui-contexts
'
;
import
{
useMethod
,
useSetting
,
TranslationContext
}
from
'
@rocket.chat/ui-contexts
'
;
import
type
i18next
from
'
i18next
'
;
import
I18NextHttpBackend
from
'
i18next-http-backend
'
;
import
sprintf
from
'
i18next-sprintf-postprocessor
'
;
...
...
@@ -12,6 +12,7 @@ import React, { useEffect, useMemo } from 'react';
import
{
I18nextProvider
,
initReactI18next
,
useTranslation
}
from
'
react-i18next
'
;
import
{
CachedCollectionManager
}
from
'
../../app/ui-cached-collection/client
'
;
import
{
getURL
}
from
'
../../app/utils/client
'
;
import
{
i18n
,
addSprinfToI18n
}
from
'
../../app/utils/lib/i18n
'
;
import
{
AppClientOrchestratorInstance
}
from
'
../../ee/client/apps/orchestrator
'
;
import
{
applyCustomTranslations
}
from
'
../lib/utils/applyCustomTranslations
'
;
...
...
@@ -39,8 +40,6 @@ const parseToJSON = (customTranslations: string): Record<string, Record<string,
const
localeCache
=
new
Map
<
string
,
Promise
<
string
>>
();
const
useI18next
=
(
lng
:
string
):
typeof
i18next
=>
{
const
basePath
=
useAbsoluteUrl
()(
'
/i18n
'
);
const
customTranslations
=
useSetting
(
'
Custom_Translations
'
);
const
parsedCustomTranslations
=
useMemo
(()
=>
{
...
...
@@ -105,17 +104,18 @@ const useI18next = (lng: string): typeof i18next => {
partialBundledLanguages
:
true
,
defaultNS
:
'
core
'
,
backend
:
{
loadPath
:
`
${
basePath
}
/{{lng}}.json
`
,
loadPath
:
'
i18n
/{{lng}}.json
'
,
parse
:
(
data
:
string
,
lngs
?:
string
|
string
[],
namespaces
:
string
|
string
[]
=
[])
=>
extractKeys
(
JSON
.
parse
(
data
),
lngs
,
namespaces
),
request
:
(
_options
,
url
,
_payload
,
callback
)
=>
{
const
params
=
url
.
split
(
'
/
'
);
const
lng
=
params
[
params
.
length
-
1
];
let
promise
=
localeCache
.
get
(
lng
);
if
(
!
promise
)
{
promise
=
fetch
(
url
).
then
((
res
)
=>
res
.
text
());
promise
=
fetch
(
getURL
(
url
)
)
.
then
((
res
)
=>
res
.
text
());
localeCache
.
set
(
lng
,
promise
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment