-
Notifications
You must be signed in to change notification settings - Fork 336
Feature/custom translations frontend #857
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/custom translations frontend #857
Conversation
10cd759
to
d285bd1
Compare
4ff16fa
to
81fd1ed
Compare
src/frontend/apps/impress/src/features/language/hooks/useTranslationsCustomizer.ts
Outdated
Show resolved
Hide resolved
src/frontend/apps/impress/src/features/language/hooks/useTranslationsCustomizer.ts
Outdated
Show resolved
Hide resolved
src/frontend/apps/impress/src/features/language/hooks/useTranslationsCustomizer.ts
Outdated
Show resolved
Hide resolved
b9b16aa
to
06b91a1
Compare
06b91a1
to
af92119
Compare
src/frontend/apps/impress/src/features/language/hooks/useTranslationsCustomizer.ts
Outdated
Show resolved
Hide resolved
a65fca6
to
cddc429
Compare
cddc429
to
9a9b717
Compare
5f855f1
to
ed137ef
Compare
ed137ef
to
2e7f552
Compare
2e7f552
to
6a036b3
Compare
6a036b3
to
6a75453
Compare
0080fdc
to
bf65c8b
Compare
d86f811
to
f7abb03
Compare
src/frontend/apps/impress/src/features/language/hooks/useCustomTranslations.ts
Outdated
Show resolved
Hide resolved
src/frontend/apps/impress/src/features/language/hooks/useCustomTranslations.ts
Outdated
Show resolved
Hide resolved
src/frontend/apps/impress/src/features/language/hooks/useCustomTranslations.ts
Outdated
Show resolved
Hide resolved
|
||
const availableFrontendLanguages = useMemo( | ||
() => Object.keys(i18n?.options?.resources || { en: '<- fallback' }), | ||
[i18n], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[i18n], | |
[i18n?.options?.resources], |
src/frontend/apps/impress/src/features/language/hooks/useSynchronizedLanguage.ts
Outdated
Show resolved
Hide resolved
log('Updating frontend language (%O)', { | ||
requested: language, | ||
from: i18n.resolvedLanguage, | ||
to: closestFrontendLanguage, | ||
}); | ||
void i18n.changeLanguage(closestFrontendLanguage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same it is part of the development part, should be removed.
src/frontend/apps/impress/src/features/auth/api/useAuthMutation.ts
Outdated
Show resolved
Hide resolved
currentBackendLanguage, | ||
currentFrontendLanguage, | ||
changeLanguageSynchronized, | ||
currentUser, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is currentUser
necessary ?
[changeBackendLanguage, changeFrontendLanguage, currentUser], | ||
); | ||
|
||
useEffect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have the feeling this useEffect is trigger often.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was not good to have the useEffect in the useSynchronizedLanguage hook anyways,
as it added 1 useEffect call, everytime useSynchronizedLanguage() is instantiated.
To counteract, one would need to develop a Provider to share Context.
Since i didn't see the need for a dedicated Provider just to prevent a race condition / enable singleton pattern, i instead moved the useEffect to the ConfigProvider and simplified useSynchronizedLanguage to only be responsible for change language.
The default behavior ("sync frontend detected language to backend if backend language is null") is now handeled in the ConfigProvider. It looks more on par with what we already have in there.
f7abb03
to
4d59da8
Compare
372b8d9
to
bb1c96e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done, very useful feature. 🚀
src/frontend/apps/impress/src/features/header/components/Header.tsx
Outdated
Show resolved
Hide resolved
src/frontend/apps/impress/src/features/home/components/HomeHeader.tsx
Outdated
Show resolved
Hide resolved
src/frontend/apps/impress/src/features/left-panel/components/LeftPanel.tsx
Outdated
Show resolved
Hide resolved
b7ed541
to
5ad421c
Compare
Part of customization PoC Signed-off-by: Robin Weber <[email protected]>
Part of customization PoC Signed-off-by: Robin Weber <[email protected]>
Introduces dedicated mutations (for authentication/user operations) separating them from queries to align with best practices for data fetching and state management. Queries remain responsible for READ operations, while mutations now handle CREATE, UPDATE, and DELETE actions (for user data) improving separation of concerns. Signed-off-by: Robin Weber <[email protected]>
- Refactors "useTranslationsCustomizer" to "useCustomTranslations" - Refactors "useLanguageSynchronizer" to "useSynchronizedLanguage" - Refactors "LanguagePicker" to better reflect its component role - Refactors "LanguagePicker" to use "useSynchronizedLangue" - Removes unused "useChangeUserLanguage" - To change the user language, use "useAuthMutation" instead Signed-off-by: Robin Weber <[email protected]>
- Language will only be changed if different from current language - Added test for custom translations Signed-off-by: Robin Weber <[email protected]>
5ad421c
to
94e9978
Compare
Adds the possibilty to inject/override custom translations at runtime.