feat: refactor languages

This commit is contained in:
Zamitto 2024-09-04 23:40:05 -03:00
parent 02907d84e1
commit 40f4bbc124
28 changed files with 172 additions and 57 deletions

View file

@ -1,4 +1,5 @@
{
"language_name": "اَلْعَرَبِيَّةُ",
"home": {
"featured": "مميّز",
"trending": "شائع",

View file

@ -1,4 +1,5 @@
{
"language_name": "беларуская мова",
"home": {
"featured": "Рэкамэндаванае",
"trending": "Актуальнае",

View file

@ -1,4 +1,5 @@
{
"language_name": "Català",
"app": {
"successfully_signed_in": "Has entrat correctament"
},

View file

@ -1,4 +1,5 @@
{
"language_name": "Dansk",
"home": {
"featured": "Anbefalet",
"trending": "Trender",

View file

@ -1,4 +1,5 @@
{
"language_name": "English",
"app": {
"successfully_signed_in": "Successfully signed in"
},

View file

@ -1,4 +1,5 @@
{
"language_name": "Español",
"app": {
"successfully_signed_in": "Sesión iniciada correctamente"
},

View file

@ -1,4 +1,5 @@
{
"language_name": "فارسی",
"home": {
"featured": "پیشنهادی",
"trending": "پرطرفدار",

View file

@ -1,4 +1,5 @@
{
"language_name": "Français",
"home": {
"featured": "En vedette",
"trending": "Tendance",

View file

@ -1,4 +1,5 @@
{
"language_name": "Magyar",
"home": {
"featured": "Featured",
"trending": "Népszerű",

View file

@ -1,4 +1,5 @@
{
"language_name": "Bahasa Indonesia",
"app": {
"successfully_signed_in": "Berhasil masuk"
},

View file

@ -1,22 +1,47 @@
export { default as en } from "./en/translation.json";
export { default as ptPT } from "./pt-PT/translation.json";
export { default as ptBR } from "./pt-BR/translation.json";
export { default as es } from "./es/translation.json";
export { default as nl } from "./nl/translation.json";
export { default as fr } from "./fr/translation.json";
export { default as hu } from "./hu/translation.json";
export { default as it } from "./it/translation.json";
export { default as pl } from "./pl/translation.json";
export { default as ru } from "./ru/translation.json";
export { default as tr } from "./tr/translation.json";
export { default as be } from "./be/translation.json";
export { default as uk } from "./uk/translation.json";
export { default as zh } from "./zh/translation.json";
export { default as id } from "./id/translation.json";
export { default as ko } from "./ko/translation.json";
export { default as da } from "./da/translation.json";
export { default as ar } from "./ar/translation.json";
export { default as fa } from "./fa/translation.json";
export { default as ro } from "./ro/translation.json";
export { default as ca } from "./ca/translation.json";
export { default as kk } from "./kk/translation.json";
import en from "./en/translation.json";
import ptPT from "./pt-PT/translation.json";
import ptBR from "./pt-BR/translation.json";
import es from "./es/translation.json";
import nl from "./nl/translation.json";
import fr from "./fr/translation.json";
import hu from "./hu/translation.json";
import it from "./it/translation.json";
import pl from "./pl/translation.json";
import ru from "./ru/translation.json";
import tr from "./tr/translation.json";
import be from "./be/translation.json";
import uk from "./uk/translation.json";
import zh from "./zh/translation.json";
import id from "./id/translation.json";
import ko from "./ko/translation.json";
import da from "./da/translation.json";
import ar from "./ar/translation.json";
import fa from "./fa/translation.json";
import ro from "./ro/translation.json";
import ca from "./ca/translation.json";
import kk from "./kk/translation.json";
export default {
"pt-BR": ptBR,
"pt-PT": ptPT,
en,
es,
nl,
fr,
hu,
it,
pl,
ru,
tr,
be,
uk,
zh,
id,
ko,
da,
ar,
fa,
ro,
ca,
kk,
};

View file

@ -1,4 +1,5 @@
{
"language_name": "Italiano",
"home": {
"featured": "In primo piano",
"trending": "Di tendenza",

View file

@ -1,4 +1,5 @@
{
"language_name": "қазақ тілі",
"app": {
"successfully_signed_in": "Сәтті кіру"
},

View file

@ -1,4 +1,5 @@
{
"language_name": "한국어",
"home": {
"featured": "추천",
"trending": "인기",

View file

@ -1,4 +1,5 @@
{
"language_name": "Nederlands",
"home": {
"featured": "Uitgelicht",
"trending": "Trending",

View file

@ -1,4 +1,5 @@
{
"language_name": "Polski",
"home": {
"featured": "Wyróżnione",
"trending": "Trendujące",

View file

@ -1,4 +1,5 @@
{
"language_name": "Português (Brasil)",
"app": {
"successfully_signed_in": "Autenticado com sucesso"
},

View file

@ -1,4 +1,5 @@
{
"language_name": "Português (Portugal)",
"app": {
"successfully_signed_in": "Sessão iniciada com sucesso"
},

View file

@ -1,4 +1,5 @@
{
"language_name": "Română",
"home": {
"featured": "Recomandate",
"trending": "Populare",

View file

@ -1,4 +1,5 @@
{
"language_name": "Русский",
"app": {
"successfully_signed_in": "Успешный вход"
},

View file

@ -1,4 +1,5 @@
{
"language_name": "Türkçe",
"home": {
"featured": "Öne çıkan",
"trending": "Popüler",

View file

@ -1,4 +1,5 @@
{
"language_name": "Українська",
"app": {
"successfully_signed_in": "Успішний вхід в систему"
},

View file

@ -1,4 +1,5 @@
{
"language_name": "中文",
"app": {
"successfully_signed_in": "已成功登录"
},

View file

@ -7,7 +7,7 @@ import url from "node:url";
import { electronApp, optimizer } from "@electron-toolkit/utils";
import { logger, PythonInstance, WindowManager } from "@main/services";
import { dataSource } from "@main/data-source";
import * as resources from "@locales";
import resources from "@locales";
import { userPreferencesRepository } from "@main/repository";
import { knexClient, migrationConfig } from "./knex-client";

View file

@ -26,7 +26,7 @@ import {
import { store } from "./store";
import * as resources from "@locales";
import resources from "@locales";
import { User } from "./pages/user/user";
Sentry.init({});

View file

@ -1,7 +1,4 @@
import { useContext, useEffect, useState } from "react";
import languages from "@cospired/i18n-iso-languages";
import languagesEn from "@cospired/i18n-iso-languages/langs/en.json";
import {
TextField,
Button,
@ -9,11 +6,9 @@ import {
SelectField,
} from "@renderer/components";
import { useTranslation } from "react-i18next";
import { useAppSelector } from "@renderer/hooks";
import { changeLanguage } from "i18next";
import * as languageResources from "@locales";
import languageResources from "@locales";
import { orderBy } from "lodash-es";
import { settingsContext } from "@renderer/context";
@ -22,13 +17,6 @@ interface LanguageOption {
nativeName: string;
}
languages.registerLocale(languagesEn);
const customLanguageNames = {
ptBR: "Português (Brasil)",
ptPT: "Português (Portugal)",
};
export function SettingsGeneral() {
const { t } = useTranslation("settings");
@ -58,11 +46,9 @@ export function SettingsGeneral() {
setLanguageOptions(
orderBy(
Object.keys(languageResources).map((language) => {
Object.entries(languageResources).map(([language, value]) => {
return {
nativeName:
customLanguageNames[language] ||
languages.getName(language, "en"),
nativeName: value.language_name,
option: language,
};
}),
@ -103,8 +89,6 @@ export function SettingsGeneral() {
function updateFormWithUserPreferences() {
if (userPreferences) {
const parsedLanguage = userPreferences.language;
setForm((prev) => ({
...prev,
downloadsPath: userPreferences.downloadsPath ?? defaultDownloadsPath,
@ -112,7 +96,7 @@ export function SettingsGeneral() {
userPreferences.downloadNotificationsEnabled,
repackUpdatesNotificationsEnabled:
userPreferences.repackUpdatesNotificationsEnabled,
language: parsedLanguage,
language: userPreferences.language,
}));
}
}