-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(web): infrastructure for typesafe, shared translations
- Loading branch information
Showing
27 changed files
with
303 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import i18n from "i18next"; | ||
import { initReactI18next } from "react-i18next"; | ||
import { resources, defaultNS } from "@abrechnung/translations"; | ||
|
||
i18n.use(initReactI18next).init({ | ||
ns: [defaultNS], | ||
resources, | ||
defaultNS, | ||
lng: "en", | ||
fallbackLng: "en", | ||
debug: true, | ||
interpolation: { escapeValue: false }, | ||
}); | ||
|
||
export default i18n; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import "i18next"; | ||
import type { resources, defaultNS } from "@abrechnung/translations"; | ||
|
||
declare module "i18next" { | ||
interface CustomTypeOptions { | ||
defaultNS: typeof defaultNS; | ||
resources: (typeof resources)["en"]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { MenuItem, Select, SelectChangeEvent, SelectProps } from "@mui/material"; | ||
import * as React from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
|
||
export type LanguageSelectProps = Omit<SelectProps, "value" | "onChange">; | ||
|
||
export const LanguageSelect: React.FC<LanguageSelectProps> = (props) => { | ||
const { t, i18n } = useTranslation(); | ||
|
||
const handleSetLanguage = (event: SelectChangeEvent<unknown>) => { | ||
const lang = event.target.value as string; | ||
i18n.changeLanguage(lang); | ||
}; | ||
|
||
return ( | ||
<Select value={i18n.language} sx={{ color: "inherit" }} onChange={handleSetLanguage} {...props}> | ||
<MenuItem value="en-US">{t("languages.en")}</MenuItem> | ||
<MenuItem value="de-DE">{t("languages.de")}</MenuItem> | ||
</Select> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import "i18next"; | ||
import type { resources, defaultNS } from "@abrechnung/translations"; | ||
|
||
declare module "i18next" { | ||
interface CustomTypeOptions { | ||
defaultNS: typeof defaultNS; | ||
nsSeparator: ""; | ||
resources: { "": (typeof resources)["en"]["translations"] }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.