-
Notifications
You must be signed in to change notification settings - Fork 191
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
feat(i18n): initial setup #711
Conversation
@bumi @escapedcat initial setup for i18n |
if you have gone through the documentation! either we can use nesting of keys or react i18next namespaces currently, I am using namespace. if we wish to use nesting of keys as a key management strategy we can do that as well |
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.
}, | ||
"lint-staged": { | ||
"src/**/*.{js,jsx,ts,tsx}": [ | ||
"src/**/*.{js,jsx,ts,tsx,json}": [ |
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.
🙌
3d78783
to
1f1f19a
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.
Awesome job @pavanjoshi914 !
1f1f19a
to
5ab80a2
Compare
Squashed all the commits into a single commit. @bumi PR is ready to be merged! |
regarding weblate! currently, we can just focus on completing i18n with a single alternate language. setup for continuous localization can be done once we are finished with this |
5ab80a2
to
2c1abfc
Compare
Applied for the "Libre hosting" plan on weblate already |
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 think we should save the selected language in the settings storage. Otherwise it will get lost after the app reloads.
You can see how to save the settings there:
async function saveSetting( |
sure so we will have incoming locale from three places
Case 1. storing browser detected language or fallback language when a user installs the app we let the browser detector, detect the language and use that language. either browser detected language will be used and if not available fallback language
Case 2: store language changed via locale switcher
|
Can you elaborate on |
2c1abfc
to
079834f
Compare
I made a silly mistake! I thought
did required changes @bumi @escapedcat kindly review |
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.
From the code I don't fully understand where we load the language from the settings.
Can you point me to that?
Also how do we roll this out? Should we only show the language switcher in dev mode until we have a decent amount of the app translated?
... |
sorry, my bad. forgot...sure. really good, let's add that to the wiki? and add a link in the i18config in code to that wiki page? |
(ups and I don't even hit the right button this morning, sorry. :) ) |
sure , but before that i have to do few revisions to make it more formal. |
Good point. We can also add |
haha nice one @escapedcat 😁 |
@bumi If you're looking for a translation platform, I recommend hosted.weblate.org, they are free for open source projects if you apply. I'm using it for Citadel and it works great |
I think this will not happen! what does it mean by reloading? (refreshing browser?). And uses the following sequence in priority to resolve the locale. cookie |
@pavanjoshi914 Going to test it now! |
The vertical alignment of the LanguageSwitcher seems off. It also doesn't show the pointer cursor while hovering over it. |
src/app/router/Welcome/Welcome.tsx
Outdated
{process.env.NODE_ENV === "development" && <DevMenu />} | ||
|
||
{process.env.NODE_ENV === "development" && ( | ||
<Fragment> |
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.
Troughout the project we use the short syntax for fragments that doesn't require an import.
https://reactjs.org/docs/fragments.html#short-syntax
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.
done
import { useState } from "react"; | ||
import type { ChangeEvent } from "react"; | ||
import i18n from "i18next"; | ||
import "../../../i18n/i18nConfig"; |
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 can replace the two i18n imports by:
import i18n from "../../../i18n/i18nConfig";
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.
done
import api from "../../../common/lib/api"; | ||
|
||
export default function LocaleSwitcher() { | ||
const [dropdownLang, setDropdownLang] = useState(i18n.language || "en"); |
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 [dropdownLang, setDropdownLang] = useState(i18n.language || "en"); | |
const [dropdownLang, setDropdownLang] = useState(i18n.language || i18n.options.fallbackLng[0]); |
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.
done
c344ac0
to
05a92a0
Compare
not sure what I have to do here! any screenshot which can help to understand where is the problem? |
I think he meant you can use this component instead of a normal select: You can find an example how to use it here:
|
already using! but i refactored by default class present with component! |
05a92a0
to
b380dc9
Compare
the only important class was |
👍 Ah sorry, didn't see. Might be good having default styles on a select which can be extended or overwritten, but we can take care of that later on. |
yup but the class has |
@pavanjoshi914 What is the problem with the w-full class? You let the width of the component to be decided by the parent that it's wrapped in. It might need some updated styling if it's too high now, as it has been styled a while ago and not used in prod yet. But I would keep default styles instead of passing in custom classes, and let a parent element decide how it's aligned, what it's width is etc. |
so I can wrap the select element in div tag to overwrite few of the styles. |
w-full means width: 100%; which means take 100% width of the parent container. So if your parent container is 400px wide, w-full means a width of 400px. |
b380dc9
to
7d4b1ac
Compare
setup i18next react-i18next browser-language-detector create locale switcher styling for both light and dark mode translate heading enable json imports in tsconfig language persistence throughout different components language persistence between different sessions browser language detections format JSON translation file using built-in eslint JSON formatted and run automated using lintstaged format existing json file place language switcher on intro and under settings (for intro under development mode) store locale in extensions storage signed-off-by: pavan joshi <pavanj914@gmail.com>
7d4b1ac
to
d3b853e
Compare
@dylancom can you review it again! |
If your screen width is smaller than 1300px in the Welcome screen, then you can't click the language switcher. (elements overlapping) |
signed-off-by: pavan joshi <pavanj914@gmail.com>
d3b853e
to
36c1efd
Compare
oops! corrected |
@bumi kindly review and merge |
Solves #600
Type of change
New feature (non-breaking change which adds functionality)
Describe the changes you have made in this PR -
setup i18next react-i18next browser-language-detector
create locale switcher
styling for both light and dark mode
translate heading
enable JSON imports in config
language persistence throughout the component
language persistence between different sessions
browser language detections
format JSON translation file using built-in eslint JSON formatted and run automated using lintstaged
Screenshots of the changes (If any) -
Updates
locale switcher shifted under settings
locale switcher on Intro shown only under development mode
store locale in extension's storage as well
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist: