-
Notifications
You must be signed in to change notification settings - Fork 540
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
Allows configuring available languages through env and adds Hindi to CARE #8692
Changes from 2 commits
6f8d62d
346bcd5
c230b1a
c468642
dd808ee
9b071b3
3547988
148a154
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -38,6 +38,9 @@ const careConfig = { | |||||
customLogo: logo(env.REACT_CUSTOM_LOGO), | ||||||
customLogoAlt: logo(env.REACT_CUSTOM_LOGO_ALT), | ||||||
customDescription: env.REACT_CUSTOM_DESCRIPTION, | ||||||
availableLocales: (env.REACT_AVAILABLE_LOCALES || "") | ||||||
.split(",") | ||||||
.map((l) => l.trim().toLowerCase()), | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bodhish this is to be sure that random case characters in the ENV don't break things. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets not have it, env configuration is one time and validation for the env will take care of it. #8470 |
||||||
|
||||||
gmapsApiKey: | ||||||
env.REACT_GMAPS_API_KEY || "AIzaSyDsBAc3y7deI5ZO3NtK5GuzKwtUzQNJNUk", | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ import { useEffect } from "react"; | |
import { useTranslation } from "react-i18next"; | ||
import { LANGUAGE_NAMES } from "../../Locale/config"; | ||
import { classNames } from "../../Utils/utils"; | ||
import careConfig from "@careConfig"; | ||
|
||
export const LanguageSelectorLogin = () => { | ||
const { i18n, t } = useTranslation(); | ||
|
@@ -17,12 +18,16 @@ export const LanguageSelectorLogin = () => { | |
} | ||
}; | ||
|
||
const availableLocales = Object.keys(LANGUAGE_NAMES).filter( | ||
(l) => l === "en" || careConfig.availableLocales?.includes(l), | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need a special case for en? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So that even when there are no available languages set in env english is still there There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think its safe to assume that the env will configured correctly, we also have a default set, so I think we can ignore it |
||
|
||
return ( | ||
<div className="mt-8 flex flex-col items-center text-sm text-secondary-800"> | ||
{t("available_in")} | ||
<br /> | ||
<div className="inline-flex flex-wrap gap-3"> | ||
{Object.keys(LANGUAGE_NAMES).map((e: string) => ( | ||
<div className="inline-flex flex-wrap items-center justify-center gap-3"> | ||
{availableLocales.map((e: string) => ( | ||
<button | ||
key={e} | ||
onClick={() => handleLanguage(e)} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ export const LANGUAGE_NAMES: { [key: string]: any } = { | |
ml: "മലയാളം", | ||
mr: "मराठी", | ||
kn: "ಕನ್ನಡ", | ||
hi: "हिन्दी", | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import Asset from "./Asset.json"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need this for all languages 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. Using dynamic imports as much as possible now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update: Dynamic imports were causing issues during build due to their async nature. Reverted back. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I really don't want us to have this file for each language, not a priority to fix now but I think we should find a better solution for this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can take this up in a later issue. Tracking it through #8705 |
||
import Auth from "./Auth.json"; | ||
import Bed from "./Bed.json"; | ||
import Common from "./Common.json"; | ||
import Consultation from "./Consultation.json"; | ||
import CoverImageEdit from "./CoverImageEdit.json"; | ||
import Diagnosis from "./Diagnosis.json"; | ||
import Entities from "./Entities.json"; | ||
import ErrorPages from "./ErrorPages.json"; | ||
import ExternalResult from "./ExternalResult.json"; | ||
import Facility from "./Facility.json"; | ||
import FileUpload from "./FileUpload.json"; | ||
import HCX from "./HCX.json"; | ||
import Hub from "./Hub.json"; | ||
import LogUpdate from "./LogUpdate.json"; | ||
import Medicine from "./Medicine.json"; | ||
import Notifications from "./Notifications.json"; | ||
import Patient from "./Patient.json"; | ||
import Resource from "./Resource.json"; | ||
import Shifting from "./Shifting.json"; | ||
import Users from "./Users.json"; | ||
|
||
export default { | ||
...Auth, | ||
...Asset, | ||
...Common, | ||
...Consultation, | ||
...CoverImageEdit, | ||
...Entities, | ||
...ErrorPages, | ||
...ExternalResult, | ||
...Facility, | ||
...Hub, | ||
...Medicine, | ||
...Diagnosis, | ||
...Notifications, | ||
...Patient, | ||
...Resource, | ||
...Shifting, | ||
...Bed, | ||
...Users, | ||
...LogUpdate, | ||
...FileUpload, | ||
...HCX, | ||
}; |
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 we pick small case? 🤔
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.
wouldn't 'ALLOWED_LOCALES' term be more appropriate?
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.
Agreed @rithviknishad