Closed medamineziraoui closed 2 years ago
Description: Add traduction feature, and add select language to user profile in both english and french languages.
Type of change New feature ( breaking change with adds functionality )
Platform tests
Checklist:
[ ] Add select language in user user profile so we can switch languages.
[ ] Add libs react-i18next i18next
react-i18next i18next
[ ] Add new file i18n.ts in the src/config folder
i18n.ts
src/config
[ ] Add locales folder in the src directory
locales
[ ] Add index.ts in locales containing
index.ts
export * as en from './en'; export * as fr from './fr';
[ ] Add both en and fr in the locales folder
en
fr
[ ] Add trads for text that will be translated in both fr and en texts
[ ] Update get account query
export const useAccount = (config: UseQueryOptions<Account> = {}) => { const { i18n } = useTranslation(); ... const { data: account, ...rest } = useQuery( ['account'], (): Promise<Account> => axios.get('/account'), { onSuccess: (data) => { i18n.changeLanguage(data?.langKey); if (config?.onSuccess) { config?.onSuccess(data); } }, ... };
[ ] Change Update Account query
export const useUpdateAccount = ( config: UseMutationOptions<Account, unknown, Account> = {} ) => { const { i18n } = useTranslation(); ... { onMutate: (data) => { i18n.changeLanguage(data?.langKey); if (config?.onMutate) { config.onMutate(data); } }, ...config, } ...
[ ] Add th configuration
import i18n from 'i18next'; import { initReactI18next } from 'react-i18next'; import * as locales from '../locales'; import { AVAILABLE_LANGUAGES, DEFAULT_LANGUAGE_KEY } from '../constants/i18n'; i18n .use(initReactI18next) .init({ defaultNS: 'common', resources: locales, lng: DEFAULT_LANGUAGE_KEY, fallbackLng: DEFAULT_LANGUAGE_KEY, interpolation: { escapeValue: false }, }); i18n.on('languageChanged', (langKey) => { // store langukey in the smartphone local storage }); export default i18n;
[ ] Update trads (duh)
Files to translate ( en ):
yes
No
Update
An error occurred
Retry
Loading...
An error occurred while updating your profile, please retry
Your profile has been updated
My account
Email address
Email address is required
Email is invalid
First Name
John
Last Name
Doe
Logout
About this app
App version
Build number
Environnement
Mode
Using Hermes JS Engine
Network helper
IPV6 Address:
IPV4 Address:
SSID
Api URL:
Backend connected:
Not Connected
Connected
Welcome
Log in
Password
Password is required
Forgot Password?
Log In
Need an Account?
Register Now!
Your account has been created successfully. You can now log in
This email is already used by another account
An error occurred while trying to create your account, please retry
Password should have at least 6 characters
Confirm Password
Password confirmation is required
Passwords do not match
Register
Reset Password
Enter the email address you used to register
Send Email
Description: Add traduction feature, and add select language to user profile in both english and french languages.
Type of change New feature ( breaking change with adds functionality )
Platform tests
Checklist:
[ ] Add select language in user user profile so we can switch languages.
[ ] Add libs
react-i18next i18next
[ ] Add new file
i18n.ts
in thesrc/config
folder[ ] Add
locales
folder in the src directory[ ] Add
index.ts
inlocales
containing[ ] Add both
en
andfr
in thelocales
folder[ ] Add trads for text that will be translated in both
fr
anden
texts[ ] Update get account query
[ ] Change Update Account query
[ ] Add th configuration
[ ] Update trads (duh)
Files to translate ( en ):
yes
No
Update
An error occurred
Retry
Loading...
An error occurred while updating your profile, please retry
Your profile has been updated
My account
Email address
Email address is required
Email is invalid
First Name
John
Last Name
Doe
Logout
About this app
App version
Build number
Environnement
Mode
Using Hermes JS Engine
Network helper
IPV6 Address:
IPV4 Address:
SSID
Api URL:
Backend connected:
Not Connected
Connected
Welcome
Log in
Password
Password is required
Forgot Password?
Log In
Need an Account?
Register Now!
About this app
Your account has been created successfully. You can now log in
This email is already used by another account
An error occurred while trying to create your account, please retry
Password should have at least 6 characters
Confirm Password
Password confirmation is required
Passwords do not match
Register
Reset Password
Enter the email address you used to register
Send Email