Skip to content

Commit

Permalink
Add Russian language support and update language handling logic
Browse files Browse the repository at this point in the history
  • Loading branch information
MatinDehghanian committed Dec 14, 2024
1 parent 9ad10fe commit 7578512
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ VITE_SUPPORT_URL=https://t.me/YourID
VITE_OFF_SECTIONS={"appsBox": true, "logoBox": true, "timeBox": true, "usageBox": true, "userBox": true, "supportBox": true, "configs": true}
# Apps JSON URL
VITE_JSON_APPS_URL=https://raw.githubusercontent.com/MatinDehghanian/public-assets/refs/heads/main/json/os.json
# Second Language Select {Options : en - ru }
VITE_SECOND_LANG=ru

### Host Settings
# Host URL
Expand Down
4 changes: 2 additions & 2 deletions src/components/Apps.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ const renderAppAccordion = (
<AccordionDetails>
<Grid container direction="column" gap={".7rem"} alignItems={"center"}>
<Typography sx={{ paddingBottom: "1rem" }}>
{lang === "en" ? app.description : app.faDescription}
{lang === "fa" ? app.faDescription : app.description}
</Typography>
{app.downloadLink &&
renderButtonGrid(
Expand Down Expand Up @@ -356,7 +356,7 @@ const Apps = ({ subLink }) => {
</Grid>
<Grid item xs={10} display="flex" justifyContent="center">
<Typography>
{lang === "en" ? os.engName : os.name}
{lang === "fa" ? os.name : os.engName}
</Typography>
</Grid>
</Grid>
Expand Down
11 changes: 7 additions & 4 deletions src/components/RadioButtons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ const RadioButtons = ({ setIsDarkMode }) => {
};

const handleLangChange = () => {
const newLang = lang === "fa" ? "en" : "fa";
const newLang =
lang === "fa" ? import.meta.env.VITE_SECOND_LANG || "en" : "fa";
i18n.changeLanguage(newLang);
Cookies.set("language", newLang, { expires: 90 });
};
Expand Down Expand Up @@ -81,10 +82,12 @@ const RadioButtons = ({ setIsDarkMode }) => {
icon={"فارسی"}
/>
<CapsuleButton
label="EN"
isActive={lang === "en"}
label={import.meta.env.VITE_SECOND_LANG || "en"}
isActive={lang === import.meta.env.VITE_SECOND_LANG || "en"}
onClick={handleLangChange}
icon={"English"}
icon={
import.meta.env.VITE_SECOND_LANG === "ru" ? "Русский" : "English"
}
/>
</Grid>
{/* Theme Toggle */}
Expand Down
47 changes: 47 additions & 0 deletions src/locales/ru/translation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"remaining_volume": "Осталось траффика",
"initial_volume": "Весь траффик",
"remaining_time": "Осталось времени",
"initial_time": "Всего времени",
"megabytes": "МБ",
"gigabytes": "ГБ",
"days": "дней",
"welcome": "Приветствуем",
"Russian": "Русский",
"English": "English",
"Persian": "فارسی",
"status": {
"active": "Активно",
"expired": "Срок закончился",
"on_hold": "На удержании",
"disabled": "Отключена",
"limited": "Закончился лимит"
},
"support": "Поддержка",
"userPanelTitle": "Подписка пользователя {brandName}.",
"userPanelWelcome": "Добро пожаловать в подписку пользователя {brandName}.",
"operatingSystems": "Операционные системы",
"configuration": "Добавить в приложение",
"download": "Скачать",
"watchVideo": "Посмотреть туториал",
"configsList": "Список конфигов",
"emergancyList": "Emergancy конфиги",
"linkCopied": "Ссылка скопирована",
"expired": "Срок закончился",
"hours": "часов",
"minutes": "минут",
"years": "лет",
"copyAll": "Скопировать все",
"B": "Б",
"KB": "КБ",
"MB": "МБ",
"GB": "ГБ",
"TB": "ТБ",
"negative": "Негативно",
"infinity": "Бесконечно",
"subQRCode": "QR-код подписки",
"free": "Бесплатно",
"light": "Светлая",
"dark": "Темная",
"ended": "Закончилось"
}
2 changes: 1 addition & 1 deletion src/utils/Helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const extractNameFromConfigURL = (url) => {


export const calculateRemainingTime = (expire, t) => {
if (!expire) return t("unknown");
if (!expire) return t("infinity");

let expireTimestamp;
if (typeof expire === "number") {
Expand Down
6 changes: 5 additions & 1 deletion src/utils/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import i18n from "i18next";
import { initReactI18next } from "react-i18next";
import enTranslation from "../locales/en/translation.json";
import faTranslation from "../locales/fa/translation.json";
import ruTranslation from "../locales/ru/translation.json";

i18n.use(initReactI18next).init({
resources: {
Expand All @@ -11,9 +12,12 @@ i18n.use(initReactI18next).init({
fa: {
translation: faTranslation,
},
ru: {
translation: ruTranslation,
},
},
lng: "fa",
fallbackLng: "en",
fallbackLng: import.meta.env.VITE_SECOND_LANG || "en",
interpolation: {
escapeValue: false,
},
Expand Down

0 comments on commit 7578512

Please sign in to comment.