ai-adventure-labs/server/frontend/public/js/translate.js

112 lines
6.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const metaTranslate = {
"en-US": {
"nav-home-btn": '<i class="fas fa-home"></i> Home',
"nav-connect-btn": '<i class="fas fa-network-wired"></i> Connect',
"nav-docs-btn": '<i class="fas fa-book"></i> Documentation',
},
"ru-RU": {
"nav-home-btn": '<i class="fas fa-home"></i> Главная',
"nav-connect-btn": '<i class="fas fa-network-wired"></i> Подключиться',
"nav-docs-btn": '<i class="fas fa-book"></i> Документация',
},
};
const translationTree = {
"/": {
"en-US": {
"intro-1": "Welcome to Adventure AI Labs!",
"description-1": "Embark on an unforgettable adventure with your favorite characters and friends! Visit familiar and unfamiliar locations..",
"button-1": '<i class="fas fa-users"></i> Start the adventure',
"intro-2": "Become a gamemaster",
"description-2": "Or you can become the gamemaster of the party and lead the plot of the characters and players like a creator god who tells an amazing story.",
"button-2": '<i class="fas fa-book"></i> Documentation',
"intro-3": "Needed a more gold..",
"description-3": "The project exists purely on a voluntary basis and the enthusiasm of the author, so if you want to help financially, then it will be very cool (:",
"button-3": '<i class="fab fa-bitcoin"></i> Donate',
},
"ru-RU": {
"intro-1": "Добро пожаловать в Adventure AI Labs!",
"description-1": "Отправьтесь в незабываемое приключение вместе со своими любимыми персонажами и друзьями! Посетите знакомые и незнакомые вам локации..",
"button-1": '<i class="fas fa-users"></i> Начать приключение',
"intro-2": "Стань мастером партии",
"description-2": "Либо же ты можешь стать мастером партии и вести сюжет персонажей и игроков словно бог-творец, который рассказывает удивительную историю.",
"button-2": '<i class="fas fa-book"></i> Документация',
"intro-3": "Нужно больше золота..",
"description-3": "Проект существует сугубо на добровольном начале и энтузиазме автора, поэтому если вы захотите помочь финансово, то это будет очень круто (:",
"button-3": '<i class="fab fa-bitcoin"></i> Задонатить',
}
},
"/connect": {
"en-US": {
title: "Server list",
"enable-cookie-cnt": "Enable Cookie!",
"enable-cookie-text-cnt": "To work with servers, accept the cookie agreement",
"accept-cookie-show-btn": "Show",
exampleModalLabel: "<i class=\"fas fa-cookie\"></i> Accept cookies",
cookiesText: "We are obliged to warn you that the AI Adventure Labs protocol client uses cookies for: authorization, storage of session keys and user consent to the use of cookies",
"accept-cookie-btn": "Accept",
loading: "Loading of servers...",
titleDenial: '<i class="fas fa-triangle-exclamation"></i> Denial of responsibility',
denialText: 'The server data does not belong to a centrally moderated foundation, community or individual, as well as to the developer of the software, program interface (protocol client), or protocol developer. Any content posted on servers is posted by the server administrator and can be absolutely anything. <b>You assume all risks for the content and connect to the server at your own peril and risk!</b>',
"accept-denial-btn": "Accept",
"server-name-tbl": "Name",
"server-address": "Address",
"server-encryption": "Encryprtion",
"server-ping": "Ping",
"server-action": "Action",
"add-custon-server": "Connect to custom server",
"offline-server": "Offline",
"connect-to-server-btn": "Connect",
"connection-failed": "Connection failed",
"retry-connecting": "Retry",
},
"ru-RU": {
title: "Список серверов",
"enable-cookie-cnt": "Примите соглашение о Cookie!",
"enable-cookie-text-cnt": "Для работы с серверами, примите соглашение об использовании файлов Cookie",
"accept-cookie-show-btn": "Посмотреть",
exampleModalLabel: "<i class=\"fas fa-cookie\"></i> Вопрос с печеньками",
cookiesText: "Мы обязаны вас предупредить, что клиент протокола AI Adventure Labs использует файлы куки для: авторизации, хранения ключей сессии и согласия пользователя на использование куки",
"accept-cookie-btn": "Принять",
loading: "Загрузка серверов...",
titleDenial: '<i class="fas fa-triangle-exclamation"></i> Отказ от отвественности',
denialText: 'Данные сервера не принадлежат централизованно-модерируемому фонду, сообществу или частному лицу, а также разработчику программного обеспечения, програмного интерфейса (клиента протокола), разработчику протокола. Любой размещённый на серверах контент размещается администратором сервера и может быть абсолютно любым. <b>Все риски за контент вы берёте полностью на себя и подключаетесь к серверу на свой страх и риск!</b>',
"accept-denial-btn": "Принять",
"server-name-tbl": "Имя сервера",
"server-address": "Адрес",
"server-encryption": "Шифрование",
"server-ping": "Пинг",
"server-action": "Действие",
"add-custon-server": "Подключиться напрямую",
"offline-server": "Не в сети",
"connect-to-server-btn": "Подключиться",
"connection-failed": "Соединение оборвалось",
"retry-connecting": "Повторить попытку",
}
}
}
Object.entries(translationTree).forEach(([page, langs]) => {
Object.entries(langs).forEach(([lang]) => {
translationTree[page][lang] = {...translationTree[page][lang], ...metaTranslate[lang]};
});
});
console.log(translationTree);
function tr (page, id) {
const lang = navigator.language || navigator.userLanguage;
// console.log("lang is", lang);
return (translationTree[page]?.[lang]?.[id] ?? translationTree[page]?.["en-US"][id]) ?? null
}