Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 105 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
"dependencies": {
"@tauri-apps/api": "^2.5.0",
"@tauri-apps/plugin-dialog": "^2.2.2",
"i18next": "^26.3.6",
"i18next-browser-languagedetector": "^8.2.1",
"lucide-react": "^0.475.0",
"react": "^19.0.0",
"react-dom": "^19.0.0"
"react-dom": "^19.0.0",
"react-i18next": "^17.0.10"
},
"devDependencies": {
"@tauri-apps/cli": "^2.5.0",
Expand Down
21 changes: 21 additions & 0 deletions src/components/LanguageSelector.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { useTranslation } from "react-i18next";
import { SUPPORTED_LANGUAGES } from "../i18n";

export function LanguageSelector() {
const { t, i18n } = useTranslation();

return (
<select
className="language-selector"
value={i18n.language}
onChange={(event) => i18n.changeLanguage(event.target.value)}
aria-label={t("topbar.languageSelector")}
>
{SUPPORTED_LANGUAGES.map((language) => (
<option key={language.code} value={language.code}>
{language.label}
</option>
))}
</select>
);
}
31 changes: 31 additions & 0 deletions src/i18n.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import i18n from "i18next";
import { initReactI18next } from "react-i18next";
import LanguageDetector from "i18next-browser-languagedetector";
import en from "./locales/en/translation.json";
import ptBR from "./locales/pt-BR/translation.json";

i18n
.use(LanguageDetector)
.use(initReactI18next)
.init({
resources: {
en: { translation: en },
"pt-BR": { translation: ptBR },
},
fallbackLng: "en",
interpolation: {
escapeValue: false,
},
detection: {
order: ["localStorage", "navigator"],
caches: ["localStorage"],
lookupLocalStorage: "autoshorts_language",
},
});

export default i18n;

export const SUPPORTED_LANGUAGES = [
{ code: "en", label: "English" },
{ code: "pt-BR", label: "Português (Brasil)" },
] as const;
Loading