-
Notifications
You must be signed in to change notification settings - Fork 287
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
base: main
Are you sure you want to change the base?
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
Part of customization PoC Signed-off-by: Robin Weber <[email protected]>
6a75453
to
0080fdc
Compare
59e7532
to
d86f811
Compare
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]>
d86f811
to
f7abb03
Compare
@@ -11,5 +11,5 @@ export interface User { | |||
email: string; | |||
full_name: string; | |||
short_name: string; | |||
language: string; | |||
language?: string; |
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.
language
can be undefined from the backend ?
const currentCustomTranslations: Resource = useMemo( | ||
() => currentConfig?.theme_customization?.translations || {}, | ||
[currentConfig], | ||
); | ||
|
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.
const currentCustomTranslations: Resource = useMemo( | |
() => currentConfig?.theme_customization?.translations || {}, | |
[currentConfig], | |
); | |
const currentCustomTranslations: Resource = currentConfig?.theme_customization?.translations || {}; | |
return { | ||
currentCustomTranslations, | ||
customizeTranslations, | ||
}; | ||
}; |
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.
You don't seem to need to export them.
); | ||
|
||
useEffect(() => { | ||
if (currentCustomTranslations) { |
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.
currentCustomTranslations
seems everytime defined.
if (currentCustomTranslations) { |
|
||
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], |
log('Updating backend language (%O)', { | ||
requested: language, | ||
from: user.language, | ||
to: closestBackendLanguage, | ||
}); |
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.
Should be just during the development part I think.
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.
function createUser(): Promise<User> { | ||
throw new Error('Not yet implemented.'); | ||
} |
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.
We are creating things that we don't need yet (maybe never ?), same for the deleteUser.
After this feature is made to manage the authentication, I don't know if it is the good place to add the user mutation.
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.
Adds the possibilty to inject/override custom translations at runtime.