From bcf786f66470c2050e3195272f4589be44a65a8c Mon Sep 17 00:00:00 2001 From: Sceat Date: Tue, 30 Jul 2024 00:30:52 +0900 Subject: [PATCH] feat: improve servver connection, skin variants, and start of central i18n --- package-lock.json | 25 ++++ package.json | 1 + src/assets/translations/en.yaml | 36 ++++++ src/assets/translations/fr.yaml | 36 ++++++ src/components/cards/item-inventory.vue | 2 +- src/components/game-ui/game-interface.vue | 2 - src/components/game-ui/ws-connect-btn.vue | 139 ---------------------- src/core/game/error_handler.js | 39 +++--- src/core/game/game.js | 19 ++- src/core/modules/game_connect.js | 2 +- src/core/modules/sui_data.js | 9 +- src/core/sui/client.js | 35 +++--- src/core/utils/three/load_model.js | 1 - src/i18n.js | 108 +---------------- vite.config.js | 2 + 15 files changed, 169 insertions(+), 287 deletions(-) create mode 100644 src/assets/translations/en.yaml create mode 100644 src/assets/translations/fr.yaml delete mode 100644 src/components/game-ui/ws-connect-btn.vue diff --git a/package-lock.json b/package-lock.json index 4899601e..98e0a997 100644 --- a/package-lock.json +++ b/package-lock.json @@ -69,6 +69,7 @@ "@iconify-json/token": "^1.1.6", "@iconify-json/token-branded": "^1.1.7", "@iconify-json/twemoji": "^1.1.15", + "@modyfi/vite-plugin-yaml": "^1.1.0", "@types/dat.gui": "^0.7.13", "@types/node": "^20.14.11", "@types/three": "^0.166.0", @@ -3526,6 +3527,21 @@ "node": ">=10" } }, + "node_modules/@modyfi/vite-plugin-yaml": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@modyfi/vite-plugin-yaml/-/vite-plugin-yaml-1.1.0.tgz", + "integrity": "sha512-L26xfzkSo1yamODCAtk/ipVlL6OEw2bcJ92zunyHu8zxi7+meV0zefA9xscRMDCsMY8xL3C3wi3DhMiPxcbxbw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rollup/pluginutils": "5.1.0", + "js-yaml": "4.1.0", + "tosource": "2.0.0-alpha.3" + }, + "peerDependencies": { + "vite": "^3.2.7 || ^4.0.5 || ^5.0.5" + } + }, "node_modules/@mysten/bcs": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@mysten/bcs/-/bcs-1.0.3.tgz", @@ -11555,6 +11571,15 @@ "dev": true, "license": "MIT" }, + "node_modules/tosource": { + "version": "2.0.0-alpha.3", + "resolved": "https://registry.npmjs.org/tosource/-/tosource-2.0.0-alpha.3.tgz", + "integrity": "sha512-KAB2lrSS48y91MzFPFuDg4hLbvDiyTjOVgaK7Erw+5AmZXNq4sFRVn8r6yxSLuNs15PaokrDRpS61ERY9uZOug==", + "dev": true, + "engines": { + "node": ">=10" + } + }, "node_modules/tr46": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz", diff --git a/package.json b/package.json index 4ef637c3..a8ea363f 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,7 @@ "@iconify-json/token": "^1.1.6", "@iconify-json/token-branded": "^1.1.7", "@iconify-json/twemoji": "^1.1.15", + "@modyfi/vite-plugin-yaml": "^1.1.0", "@types/dat.gui": "^0.7.13", "@types/node": "^20.14.11", "@types/three": "^0.166.0", diff --git a/src/assets/translations/en.yaml b/src/assets/translations/en.yaml new file mode 100644 index 00000000..92f77a58 --- /dev/null +++ b/src/assets/translations/en.yaml @@ -0,0 +1,36 @@ +SERVER_ALREADY_ONLINE: It seems you are already connected to the server, please wait a few seconds and try again +SERVER_EARLY_ACCESS_KEY_REQUIRED: You need an early access key to play on AresRPG +SERVER_MAX_PLAYERS: Sorry sir, the server is full and we don't yet have the capacity to handle that much players, please try again later +SERVER_SIGNATURE_TIMEOUT: Please sign the message faster! +SERVER_INVALID_SIGNATURE: Invalid signature +SERVER_MOVE_FIRST: Please move before doing this action, the server must acknowledge your existence first +SERVER_CHARACTER_UNLOCKED: Did you unlock your character ? +SERVER_MAX_CHARACTERS_PER_PLAYER: You can't play with that many characters! +APP_LOGIN_AGAIN: Please login again +APP_WALLET_NOT_FOUND: Wallet not found +APP_OUTDATED: The app is outdated and can't use this feature. Please update the app. +WALLET_PLEASE_SWITCH_NETWORK: Please switch to the Sui +SUI_ENOKI_SALT: Enoki failed to deliver the transaction (salt failure). Please try again. +SUI_NO_GAS: You need Sui in your wallet to perform this action +SUI_NOT_ENOUGH_FOOD: You do not have enough food! +WALLET_CONFIG: Wallet configuration error +SUI_SUBSCRIBED: Connected to Sui +SUI_PET_ALREADY_FED: This pet is not hungry +SUI_INV_NOT_EMPTY: You must unequip all items before that +SUI_SUBSCRIBE_ERROR: The Sui node refused the subscription, please refresh the page to try again +SUI_NO_PERSONAL_KIOSK: This action requires to create a character first +SUI_SUBSCRIBE_START: Subscribing to Sui node... +SUI_FETCHING_DATA: Fetching characters and items.. +SUI_DATA_FETCHED: Successfully fetched characters and items +APP_WAIT_A_MINUTE: Please wait before trying again +SUI_ENOKI_DOWN: The sponsoring service seems to be malfunctioning, please try again later. + +WS_FAILED_TO_CONNECT: Failed to connect to the server, check https://status.aresrpg.world for more information +WS_RECONNECTED: Back online! +WS_CONNECTING_TO_SERVER: Connecting to the server +WS_CONNECTED_TO_SERVER: Connected to the server + +SUI_ITEM_SOLD: was sold +SUI_INVALID_CONTRACT: The contract is invalid, is your app up to date ? Try to refresh the page +WALLET_SIGN_MESSAGE: "[AresRPG] This is a verification message to prove that you own this address. It will allow you to connect to the server" +BROWSER_NO_PERF: Your device does not support WebGL or it is running under conditions that would cause major performance issues. Please try on a different device or ensure your browser and drivers are up to date. diff --git a/src/assets/translations/fr.yaml b/src/assets/translations/fr.yaml new file mode 100644 index 00000000..7370d1c9 --- /dev/null +++ b/src/assets/translations/fr.yaml @@ -0,0 +1,36 @@ +SERVER_ALREADY_ONLINE: Il semble que vous êtes déjà connecté au serveur, veuillez patienter quelques secondes et réessayer +SERVER_EARLY_ACCESS_KEY_REQUIRED: Vous avez besoin d'une clé d'accès anticipé pour jouer sur AresRPG +SERVER_MAX_PLAYERS: Désolé sir, le serveur est plein et nous n'avons pas encore la capacité de gérer autant de joueurs, veuillez réessayer plus tard +SERVER_SIGNATURE_TIMEOUT: Veuillez signer le message plus rapidement ! +SERVER_INVALID_SIGNATURE: Signature invalide +SERVER_MOVE_FIRST: Veuillez vous déplacer avant de faire cette action, le serveur doit reconnaître votre existence d'abord +SERVER_CHARACTER_UNLOCKED: Avez-vous débloqué votre personnage ? +SERVER_MAX_CHARACTERS_PER_PLAYER: Vous ne pouvez pas jouer avec autant de personnages ! +APP_LOGIN_AGAIN: Veuillez vous reconnecter +APP_WALLET_NOT_FOUND: Portefeuille non trouvé +APP_OUTDATED: L'application est obsolète et ne peut pas utiliser cette fonctionnalité. Veuillez mettre à jour l'application. +WALLET_PLEASE_SWITCH_NETWORK: Veuillez changer de réseau Sui +SUI_ENOKI_SALT: Enoki n'a pas réussi à livrer la transaction (échec du salt). Veuillez réessayer. +SUI_NO_GAS: Vous avez besoin de Sui dans votre portefeuille pour effectuer cette action +SUI_NOT_ENOUGH_FOOD: Vous n'avez pas assez de nourriture ! +WALLET_CONFIG: Erreur de configuration du portefeuille +SUI_SUBSCRIBED: Connecté à Sui +SUI_PET_ALREADY_FED: Ce famillier n'a pas faim +SUI_INV_NOT_EMPTY: Vous devez déséquiper tous les objets avant cela +SUI_SUBSCRIBE_ERROR: La node Sui a refusé l'abonnement, veuillez rafraîchir la page pour réessayer +SUI_NO_PERSONAL_KIOSK: Cette action nécessite de créer d'abord un personnage +SUI_SUBSCRIBE_START: Abonnement a la node Sui en cours... +SUI_FETCHING_DATA: Récupération des personnages et des objets... +SUI_DATA_FETCHED: Récupération des personnages et des objets réussie +APP_WAIT_A_MINUTE: Veuillez patienter avant de réessayer +SUI_ENOKI_DOWN: Le service de sponsoring semble être en panne, veuillez réessayer plus tard. + +WS_FAILED_TO_CONNECT: Échec de la connexion au serveur, consultez https://status.aresrpg.world pour plus d'informations +WS_RECONNECTED: De retour en ligne ! +WS_CONNECTING_TO_SERVER: Connexion au serveur +WS_CONNECTED_TO_SERVER: Connecté au serveur + +SUI_ITEM_SOLD: a été vendu +SUI_INVALID_CONTRACT: Le contrat est invalide, votre application est-elle à jour ? Essayez de rafraîchir la page +WALLET_SIGN_MESSAGE: "[AresRPG] Ceci est un message de vérification pour prouver que vous possédez cette adresse. Cela vous permettra de vous connecter au serveur" +BROWSER_NO_PERF: Votre appareil ne prend pas en charge WebGL ou fonctionne dans des conditions qui entraîneraient de graves problèmes de performance. Veuillez essayer sur un autre appareil ou assurez-vous que votre navigateur et vos pilotes sont à jour. diff --git a/src/components/cards/item-inventory.vue b/src/components/cards/item-inventory.vue index 04d4bcba..e7f7546d 100644 --- a/src/components/cards/item-inventory.vue +++ b/src/components/cards/item-inventory.vue @@ -136,7 +136,7 @@ function on_right_click_item(event, item) { try { const fed = await sui_feed_pet(selected_item.value); if (fed) tx.update('success', t('fed')); - else tx.update('error', t('NOT_ENOUGH_FOOD')); + else tx.update('error', t('SUI_NOT_ENOUGH_FOOD')); } catch (error) { if (error.message.includes('101)')) { tx.update('error', t('pet_full')); diff --git a/src/components/game-ui/game-interface.vue b/src/components/game-ui/game-interface.vue index 4cf3e0f7..0146fa90 100644 --- a/src/components/game-ui/game-interface.vue +++ b/src/components/game-ui/game-interface.vue @@ -4,7 +4,6 @@ .no-characters zoneVue characterSelectVue - wsConnectBtnVue .middle gameInventory(v-if="inventory_opened") .bottom_panel @@ -21,7 +20,6 @@ import { ref } from 'vue'; import characterSelectVue from './character-select.vue'; -import wsConnectBtnVue from './ws-connect-btn.vue'; import zoneVue from './zone.vue'; import gameChat from './game-chat.vue'; import gameHealth from './game-health.vue'; diff --git a/src/components/game-ui/ws-connect-btn.vue b/src/components/game-ui/ws-connect-btn.vue deleted file mode 100644 index 861f9829..00000000 --- a/src/components/game-ui/ws-connect-btn.vue +++ /dev/null @@ -1,139 +0,0 @@ - -en: - disconnect: Leave multiplayer - connect: Join multiplayer - offline_ws: You are playing solo - online_ws: You are connected to the server - connecting_ws: Joining server.. - login_first: You need to login before connecting to the server - wrong_network: No {network} server available -fr: - disconnect: Quitter le multijoueur - connect: Rejoindre le multijoueur - offline_ws: Vous jouez en solo - online_ws: Vous êtes connecté au serveur - connecting_ws: Connexion au serveur.. - login_first: Vous devez vous connecter avant de rejoindre le serveur - wrong_network: Aucun serveur {network} disponible - - - - - - - diff --git a/src/core/game/error_handler.js b/src/core/game/error_handler.js index 0bd36622..c6614c8f 100644 --- a/src/core/game/error_handler.js +++ b/src/core/game/error_handler.js @@ -8,13 +8,20 @@ import FluentEmojiSkull from '~icons/fluent-emoji/skull' const { t } = i18n.global +let server_down_toast = null + +export function notify_reconnected() { + if (server_down_toast) { + server_down_toast.update('success', t('WS_RECONNECTED')) + server_down_toast = null + } +} + export async function handle_server_error(reason) { if (!reason) { - toast.error( - t('NO_REASON'), - 'Can the dev do something?', - "", - ) + if (!server_down_toast) + server_down_toast = toast.tx(t('WS_CONNECTING_TO_SERVER')) + server_down_toast.update('loading', t('WS_CONNECTING_TO_SERVER')) return } @@ -22,40 +29,44 @@ export async function handle_server_error(reason) { case 'USER_DISCONNECTED': return case 'ALREADY_ONLINE': - toast.error(t('ALREADY_ONLINE'), 'Oh no!', "") + toast.error( + t('SERVER_ALREADY_ONLINE'), + 'Oh no!', + "", + ) break case 'EARLY_ACCESS_KEY_REQUIRED': toast.error( - t('EARLY_ACCESS_KEY_REQUIRED'), + t('SERVER_EARLY_ACCESS_KEY_REQUIRED'), 'Oh no!', "", ) break case 'MAX_PLAYERS': - toast.info(t('MAX_PLAYERS'), 'Suuuuu', "") + toast.info(t('SERVER_MAX_PLAYERS'), 'Suuuuu', "") break case 'SIGNATURE_TIMEOUT': if (ws_status.value === 'CLOSED') toast.error( - t('SIGNATURE_TIMEOUT'), + t('SERVER_SIGNATURE_TIMEOUT'), 'Aaaaaaaah 🫠', "", ) break case 'INVALID_SIGNATURE': - toast.error(t('INVALID_SIGNATURE')) + toast.error(t('SERVER_INVALID_SIGNATURE')) break case 'CHARACTER_INVALID': - toast.error(t('MOVE_FIRST')) + toast.error(t('SERVER_MOVE_FIRST')) break case 'CHARACTER_UNLOCKED': - toast.error(t('CHARACTER_UNLOCKED'), '...', FluentEmojiSkull) + toast.error(t('SERVER_CHARACTER_UNLOCKED'), '...', FluentEmojiSkull) break case 'INVALID_CONTRACT': - toast.error(t('INVALID_CONTRACT')) + toast.error(t('SUI_INVALID_CONTRACT')) break case 'MAX_CHARACTERS_PER_PLAYER': - toast.error(t('MAX_CHARACTERS_PER_PLAYER')) + toast.error(t('SERVER_MAX_CHARACTERS_PER_PLAYER')) break default: toast.error(reason) diff --git a/src/core/game/game.js b/src/core/game/game.js index c4a5663e..75f5c99c 100644 --- a/src/core/game/game.js +++ b/src/core/game/game.js @@ -66,7 +66,7 @@ import game_entites_stroll from '../modules/game_entites_stroll.js' import player_entities_interract from '../modules/player_entities_interract.js' import game_fights from '../modules/game_fights.js' -import { handle_server_error } from './error_handler.js' +import { handle_server_error, notify_reconnected } from './error_handler.js' import { get_spells } from './spells_per_class.js' // @ts-ignore @@ -329,7 +329,7 @@ const renderer = new WebGLRenderer({ }) if (!renderer) { - toast.error(i18n.global.t('no_perf'), 'Rekt!', MdiClippy, 15000) + toast.error(i18n.global.t('BROWSER_NO_PERF'), 'Rekt!', MdiClippy, 15000) decrease_loading() throw new Error('Failed to create WebGLRenderer') } @@ -381,13 +381,16 @@ renderer.info.autoReset = false composer.setSize(window.innerWidth, window.innerHeight) function connect_ws() { + logger.SOCKET('Connecting to server') + const connecting_toast = toast.tx(i18n.global.t('WS_CONNECTING_TO_SERVER')) return new Promise((resolve, reject) => { const { selected_address } = get_state().sui const server_url = VITE_SERVER_URL.replaceAll('http', 'ws') + const { status } = useWebSocket( `${server_url}?address=${selected_address}`, { - autoReconnect: false, + autoReconnect: true, async onDisconnected(ws, event) { decrease_loading() await handle_server_error(event.reason) @@ -416,6 +419,8 @@ function connect_ws() { ws.binaryType = 'arraybuffer' logger.SOCKET(`connected to ${server_url}`) + notify_reconnected() + ares_client = create_client({ socket_write: ws.send.bind(ws), socket_end: message => ws.close(1000, message), @@ -423,6 +428,11 @@ function connect_ws() { ares_client.stream.pipe(packets) + connecting_toast.update( + 'success', + i18n.global.t('WS_CONNECTED_TO_SERVER'), + ) + resolve() }, }, @@ -431,6 +441,9 @@ function connect_ws() { watch(status, value => { ws_status.value = value }) + }).catch(error => { + console.error('Failed to connect:', error) + connecting_toast.update('error', i18n.global.t('WS_FAILED_TO_CONNECT')) }) } diff --git a/src/core/modules/game_connect.js b/src/core/modules/game_connect.js index d1712d0a..f785676d 100644 --- a/src/core/modules/game_connect.js +++ b/src/core/modules/game_connect.js @@ -20,7 +20,7 @@ export default function () { } = i18n events.on('packet/signatureRequest', async ({ payload }) => { - const message = `${t('sign_message')}\n\n::${payload}` + const message = `${t('WALLET_SIGN_MESSAGE')}\n\n::${payload}` try { await sui_sign_payload(message) context.dispatch('action/set_online', true) diff --git a/src/core/modules/sui_data.js b/src/core/modules/sui_data.js index 437e4c62..68ed4c5d 100644 --- a/src/core/modules/sui_data.js +++ b/src/core/modules/sui_data.js @@ -421,7 +421,7 @@ export default function () { if (selected_address) { if (tx) tx.remove() - tx = toast.tx(t('FETCHING_DATA')) + tx = toast.tx(t('SUI_FETCHING_DATA')) // unsubscription is handled internally sui_subscribe(controller).then(emitter => { @@ -702,7 +702,7 @@ export default function () { // if the price isn't 0 toast.info( // @ts-ignore - `${my_listing.name} ${t('item_sold')}`, + `${my_listing.name} ${t('SUI_ITEM_SOLD')}`, // @ts-ignore `+${pretty_print_mists(my_listing.list_price)} Sui`, EmojioneMoneyBag, @@ -874,13 +874,14 @@ export default function () { update_tokens: true, update_finished_crafts: true, }) - tx.update('success', t('DATA_FETCHED')) + tx.update('success', t('SUI_DATA_FETCHED')) + context.connect_ws() } catch (error) { console.error(error) tx.remove() } } else { - if (tx) tx.update('error', t('LOGIN_AGAIN')) + if (tx) tx.update('error', t('APP_LOGIN_AGAIN')) controller.abort() controller = new AbortController() diff --git a/src/core/sui/client.js b/src/core/sui/client.js index 22b7b8ec..226d7db7 100644 --- a/src/core/sui/client.js +++ b/src/core/sui/client.js @@ -159,7 +159,7 @@ async function execute_sponsored({ transaction, sender, wallet }) { }).then(res => res.json()) if (error === 'FAILURE') - toast.warn(t('ENOKI_DOWN'), 'Beeb boop', GameIconsBrokenBottle) + toast.warn(t('SUI_ENOKI_DOWN'), 'Beeb boop', GameIconsBrokenBottle) if (error) throw new Error(error) @@ -202,7 +202,7 @@ async function execute_unsponsored({ transaction, sender, wallet }) { export const execute = async transaction => { const sender = get_address() if (!sender) { - toast.error(t('LOGIN_AGAIN'), t('WALLET_NOT_FOUND')) + toast.error(t('APP_LOGIN_AGAIN'), t('APP_WALLET_NOT_FOUND')) throw new Error('Wallet not found') } @@ -211,7 +211,7 @@ export const execute = async transaction => { if (wallet.chain !== `sui:${NETWORK}`) { toast.error( - t('PLEASE_SWITCH_NETWORK') + ' ' + NETWORK, + t('WALLET_PLEASE_SWITCH_NETWORK') + ' ' + NETWORK, t('WALLET_CONFIG'), MaterialSymbolsLightRuleSettings, ) @@ -237,20 +237,15 @@ export const execute = async transaction => { console.dir({ execute_error: true, error }) if (code === 'salt_failure') - toast.error(t('ENOKI_SALT'), 'Oh no!', TwemojiSalt) + toast.error(t('SUI_ENOKI_SALT'), 'Oh no!', TwemojiSalt) else if (message.includes('No valid gas coins')) - toast.error(t('NO_GAS'), 'Suuuuuu', MapGasStation) + toast.error(t('SUI_NO_GAS'), 'Suuuuuu', MapGasStation) else if (message === 'EAlreadyFed') - toast.warn(t('E_PET_ALREADY_FED'), 'Burp!', TwemojiSushi) - else if (message === 'EInventoryNotEmpty') toast.error(t('INV_NOT_EMPTY')) + toast.warn(t('SUI_PET_ALREADY_FED'), 'Burp!', TwemojiSushi) + else if (message === 'EInventoryNotEmpty') + toast.error(t('SUI_INV_NOT_EMPTY')) else if (message.includes('Some("assert_latest") }, 1')) - toast.error(t('OUTDATED')) - else if (message === 'FAILURE') { - // let upstream handle the error - // toast.error(t('FAILURE')) - } else { - // toast.error(message, 'Transaction failed') - } + toast.error(t('APP_OUTDATED')) throw error } } @@ -277,7 +272,7 @@ export async function sui_faucet_mint(ticker) { if (last_mint.has(ticker)) { const last = last_mint.get(ticker) if (Date.now() - last < 5000) { - toast.warn(t('WAIT_A_MINUTE')) + toast.warn(t('APP_WAIT_A_MINUTE')) return 'WAIT_A_MINUTE' } } @@ -448,7 +443,7 @@ export async function sui_reveal_craft(finished_craft) { ) if (!first_personal_kiosk) { - toast.error(t('NO_PERSONAL_KIOSK')) + toast.error(t('SUI_NO_PERSONAL_KIOSK')) return } @@ -736,7 +731,7 @@ export async function sui_is_character_name_taken(name) { }) } catch (error) { if (error.message === 'NO_GAS') - toast.error(t('NO_GAS'), 'Suuuuuu', MapGasStation) + toast.error(t('SUI_NO_GAS'), 'Suuuuuu', MapGasStation) else toast.error(error.message, 'Transaction failed') } } @@ -1112,7 +1107,7 @@ export async function sui_subscribe({ signal }) { signal.addEventListener('abort', try_reset, { once: true }) - const tx_toast = toast.tx(t('SUBSCRIBE_START')) + const tx_toast = toast.tx(t('SUI_SUBSCRIBE_START')) try { await try_reset() @@ -1142,14 +1137,14 @@ export async function sui_subscribe({ signal }) { }, }) }) - tx_toast.update('success', t('SUI_SUBSCRIBE_OK')) + tx_toast.update('success', t('SUI_SUBSCRIBED')) } catch (error) { if (error.message.includes('Invalid params')) console.error( 'Unable to subscribe to the Sui node as it is too crowded. Please try again later.', ) else console.error('Unable to subscribe to the Sui node', error) - tx_toast.update('error', t('SUBSCRIBE_ERROR')) + tx_toast.update('error', t('SUI_SUBSCRIBE_ERROR')) active_subscription.unsubscribe = null } diff --git a/src/core/utils/three/load_model.js b/src/core/utils/three/load_model.js index 2f056a7b..311c955f 100644 --- a/src/core/utils/three/load_model.js +++ b/src/core/utils/three/load_model.js @@ -51,7 +51,6 @@ export async function load( model: cloned, skinned_mesh: cloned.getObjectByName(mesh_name), async set_variant(variant) { - console.log('set variant', variant) await functions.selectVariant(cloned, variant) }, compute_animations() { diff --git a/src/i18n.js b/src/i18n.js index 36c38a76..e778b466 100644 --- a/src/i18n.js +++ b/src/i18n.js @@ -1,112 +1,16 @@ import { createI18n } from 'vue-i18n' -const error_translations = { - en: { - ALREADY_ONLINE: - 'It seems you are already connected to the server, please wait a few seconds and try again', - EARLY_ACCESS_KEY_REQUIRED: - 'You need an early access key to play on AresRPG', - MAX_PLAYERS: `Sorry sir, the server is full and we don't yet have the capacity to handle that much players, please try again later`, - SIGNATURE_TIMEOUT: 'Please sign the message faster!', - INVALID_SIGNATURE: 'Invalid signature', - NO_REASON: 'The server appears to be down, please try again later', - MOVE_FIRST: - 'Please move before doing this action, the server must acknowledge your existence first', - CHARACTER_UNLOCKED: 'Did you unlock your character ?', - INVALID_CONTRACT: - 'The contract is invalid, is your app up to date ? Try to refresh the page', - MAX_CHARACTERS_PER_PLAYER: `You can't play with that many characters!`, - }, - fr: { - ALREADY_ONLINE: - 'Il semblerait que vous soyez déjà connecté au serveur, veuillez patienter quelques secondes et réessayer', - EARLY_ACCESS_KEY_REQUIRED: - "Vous avez besoin d'une clé beta pour jouer sur AresRPG", - MAX_PLAYERS: `Désolé Sir, le serveur est plein et nous n'avons pas encore la capacité de gérer autant de joueurs, veuillez réessayer plus tard`, - SIGNATURE_TIMEOUT: 'Veuillez signer le message plus rapidement!', - INVALID_SIGNATURE: 'Signature invalide', - NO_REASON: - 'Le serveur semble être hors ligne, veuillez réessayer plus tard', - MOVE_FIRST: `Veuillez bouger avant de faire cette action, le serveur doit d'abord reconnaître votre existence`, - CHARACTER_UNLOCKED: 'Avez-vous débloqué votre personnage ?', - INVALID_CONTRACT: - 'Le contrat est invalide, votre application est-elle à jour ? Essayez de rafraîchir la page', - MAX_CHARACTERS_PER_PLAYER: `Vous ne pouvez pas jouer avec autant de personnages !`, - }, -} - -const error_sui = { - en: { - LOGIN_AGAIN: 'Please login again', - WALLET_NOT_FOUND: 'Wallet not found', - PLEASE_SWITCH_NETWORK: 'Please switch to the Sui', - ENOKI_SALT: - 'Enoki failed to deliver the transaction (salt failure). Please try again.', - OUTDATED: `The app is outdated and can't use this feature. Please update the app.`, - NO_GAS: 'You need Sui in your wallet to perform this action', - NOT_ENOUGH_FOOD: `You do not have enough food!`, - WALLET_CONFIG: 'Wallet configuration error', - SUI_SUBSCRIBE_OK: 'Connected to Sui', - E_PET_ALREADY_FED: 'This pet is not hungry', - INV_NOT_EMPTY: 'You must unequip all items before that', - SUBSCRIBE_ERROR: - 'The Sui node refused the subscription, please refresh the page to try again', - FAILURE: 'Блять! This transaction failed, please try again', - NO_PERSONAL_KIOSK: 'This action requires to create a character first', - SUBSCRIBE_START: 'Subscribing to Sui node...', - FETCHING_DATA: 'Fetching characters and items..', - DATA_FETCHED: 'Successfully fetched characters and items', - WAIT_A_MINUTE: 'Please wait before trying again', - ENOKI_DOWN: - 'The sponsoring service seems to be malfunctioning, please try again later.', - }, - fr: { - LOGIN_AGAIN: 'Veuillez vous reconnecter', - WALLET_NOT_FOUND: 'Portefeuille introuvable', - PLEASE_SWITCH_NETWORK: 'Veuillez passer sur le Sui', - ENOKI_SALT: - "Enoki n'a pas pu livrer la transaction (échec du salt). Veuillez réessayer.", - OUTDATED: `L'application est obsolète et ne peut pas utiliser cette fonctionnalité. Veuillez mettre à jour l'application.`, - NO_GAS: - 'Vous avez besoin de Sui dans votre portefeuille pour effectuer cette action', - NOT_ENOUGH_FOOD: `Vous n'avez pas assez de nourriture!`, - WALLET_CONFIG: 'Erreur de configuration du portefeuille', - SUI_SUBSCRIBE_OK: 'Connecté à Sui', - E_PET_ALREADY_FED: 'Ce famillier n a pas faim', - INV_NOT_EMPTY: `Vous devez déséquiper tous les objets d'abord`, - SUBSCRIBE_ERROR: `La node Sui a refusé la connection, veuillez rafraîchir la page pour réessayer`, - FAILURE: 'Блять! Cette transaction a échoué, veuillez réessayer', - NO_PERSONAL_KIOSK: `Cette action nécessite de créer un personnage d'abord`, - SUBSCRIBE_START: 'Connexion à la node Sui...', - FETCHING_DATA: 'Récupération des personnages et objets..', - DATA_FETCHED: 'Personnages et objets récupérés avec succès', - WAIT_A_MINUTE: 'Veuillez attendre avant de réessayer', - ENOKI_DOWN: - 'Le service de sponsoring semble dysfonctionner, veuillez réessayer plus tard.', - }, -} +// @ts-ignore +import en from './assets/translations/en.yaml' +// @ts-ignore +import fr from './assets/translations/fr.yaml' export const i18n = createI18n({ legacy: false, locale: 'en', allowComposition: true, // you need to specify that! messages: { - fr: { - ...error_translations.fr, - ...error_sui.fr, - item_sold: 'a été vendu', - sign_message: - '[AresRPG] Ceci est un message de vérification pour prouver que vous possédez cette adresse. Il vous permettra de vous connecter au serveur', - no_perf: `Votre appareil ne supporte pas WebGL ou il fonctionne dans des conditions qui causeraient des problèmes de performances majeurs. Veuillez essayer sur un autre appareil ou assurez-vous que votre navigateur et vos pilotes sont à jour.`, - }, - en: { - ...error_translations.en, - ...error_sui.en, - item_sold: 'was sold', - sign_message: - '[AresRPG] This is a verification message to prove that you own this address. It will allow you to connect to the server', - no_perf: - 'Your device does not support WebGL or it is running under conditions that would cause major performance issues. Please try on a different device or ensure your browser and drivers are up to date.', - }, + fr, + en, }, }) diff --git a/vite.config.js b/vite.config.js index 4b2f773d..4ab04417 100644 --- a/vite.config.js +++ b/vite.config.js @@ -4,6 +4,7 @@ import vueI18n from '@intlify/unplugin-vue-i18n/vite' import { nodePolyfills } from 'vite-plugin-node-polyfills' import Icons from 'unplugin-icons/vite' import { VitePWA } from 'vite-plugin-pwa' +import ViteYaml from '@modyfi/vite-plugin-yaml' // https://vitejs.dev/config/ export default defineConfig({ @@ -13,6 +14,7 @@ export default defineConfig({ plugins: [ vue(), vueI18n({}), + ViteYaml(), nodePolyfills({ // To add only specific polyfills, add them here. If no option is passed, adds all polyfills include: ['stream', 'events', 'path', 'timers/promises', 'util'],