mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
feat: add a new library in setting general
This commit is contained in:
parent
15c21164e4
commit
f4cf33d369
1 changed files with 14 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
|||
import { useContext, useEffect, useState } from "react";
|
||||
import ISO6391 from "iso-639-1";
|
||||
import languages from "@cospired/i18n-iso-languages";
|
||||
import languagesEn from "@cospired/i18n-iso-languages/langs/en.json";
|
||||
|
||||
import {
|
||||
TextField,
|
||||
|
@ -21,6 +22,14 @@ interface LanguageOption {
|
|||
nativeName: string;
|
||||
}
|
||||
|
||||
languages.registerLocale(languagesEn);
|
||||
|
||||
const customLanguageNames = {
|
||||
ptBR: "Português (Brasil)",
|
||||
ptPT: "Português (Portugal)",
|
||||
// Adicione outros idiomas personalizados aqui, se necessário
|
||||
};
|
||||
|
||||
export function SettingsGeneral() {
|
||||
const { t } = useTranslation("settings");
|
||||
|
||||
|
@ -52,7 +61,9 @@ export function SettingsGeneral() {
|
|||
orderBy(
|
||||
Object.keys(languageResources).map((language) => {
|
||||
return {
|
||||
nativeName: ISO6391.getNativeName(language),
|
||||
nativeName:
|
||||
customLanguageNames[language] ||
|
||||
languages.getName(language, "en"),
|
||||
option: language,
|
||||
};
|
||||
}),
|
||||
|
@ -93,7 +104,7 @@ export function SettingsGeneral() {
|
|||
|
||||
function updateFormWithUserPreferences() {
|
||||
if (userPreferences) {
|
||||
const parsedLanguage = userPreferences.language.split("-")[0];
|
||||
const parsedLanguage = userPreferences.language;
|
||||
|
||||
setForm((prev) => ({
|
||||
...prev,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue