From bdd41db73648f60d04f940d15efe6e7a89337f48 Mon Sep 17 00:00:00 2001 From: Spythere Date: Tue, 5 May 2026 21:01:30 +0200 Subject: [PATCH] refactor(driver): improved locale naming inside propositions component --- .../DriverView/DriverPropositions.vue | 259 ++++++++++-------- src/components/DriverView/DriverTrainCard.vue | 32 +-- src/components/guide/essentials/scope | 0 src/locales/en.json | 52 ++-- src/locales/pl.json | 60 ++-- 5 files changed, 220 insertions(+), 183 deletions(-) create mode 100644 src/components/guide/essentials/scope diff --git a/src/components/DriverView/DriverPropositions.vue b/src/components/DriverView/DriverPropositions.vue index a10e2e8..fb6c107 100644 --- a/src/components/DriverView/DriverPropositions.vue +++ b/src/components/DriverView/DriverPropositions.vue @@ -1,104 +1,101 @@ @@ -110,7 +107,8 @@ import { Train } from '../../typings/common'; import rulesJSON from '../../data/trainNumberRules.json'; import { useApiStore } from '../../store/apiStore'; -const { t } = useI18n(); +const { t, locale } = useI18n(); + const apiStore = useApiStore(); const props = defineProps({ @@ -127,6 +125,8 @@ const chosenCategoryIndex = ref(0); const numberPropositions = ref([]); const chosenCategoryRules = ref([]); +const analysisLanguage = ref(locale.value); + watch( computed(() => props.chosenTrain.trainNo), () => { @@ -139,6 +139,11 @@ onMounted(() => { generateNumberPropositions(); }); +function selectCategory(i: number) { + chosenCategoryIndex.value = i; + generateNumberPropositions(); +} + function generateNumberPropositions() { const categoryCode = chosenCategory.value?.slice(0, 2); const trainNoStr = props.chosenTrain.trainNo.toString(); @@ -197,6 +202,28 @@ function generateNumberPropositions() { chosenCategoryRules.value = rules; } +function copyStockToClipboard() { + const stockString = props.chosenTrain.stockList.join(';'); + + if (!stockString) { + alert(t('analysis.stock-clipboard-failure')); + return; + } + + navigator.clipboard + .writeText(stockString) + .then(() => { + prompt(t('analysis.stock-clipboard-success'), stockString); + }) + .catch(() => { + alert(t('analysis.stock-clipboard-failure')); + }); +} + +function changeAnalysisLanguage(langId: string) { + analysisLanguage.value = langId; +} + const chosenCategory = computed(() => { return availableCategories.value[chosenCategoryIndex.value]; }); @@ -310,22 +337,17 @@ const availableCategories = computed(() => { return availableCategories.map((c) => `${c}${categoryTraction}`); }); -function selectCategory(i: number) { - chosenCategoryIndex.value = i; - generateNumberPropositions(); -} +const analysisHtml = computed(() => { + let analysisStr = `${t('analysis.title')}: `; -const analysisString = computed(() => { - let analysisStr = 'Analiza: '; - - analysisStr = `$number, ${chosenCategory.value} (${props.chosenTrain.stockList[0]}, ${(props.chosenTrain.mass / 1000).toFixed(1)}t, ${props.chosenTrain.length}m)`; + analysisStr += `${chosenCategory.value} $number (${props.chosenTrain.stockList[0]}, ${(props.chosenTrain.mass / 1000).toFixed(1)}t, ${props.chosenTrain.length}m)`; if (Object.keys(cargoWarnings.value).length > 0) { if (Object.keys(cargoWarnings.value).some((k) => k.includes('-twr'))) - analysisStr += `
${t('cargo-warnings.has-twr')}`; + analysisStr += `
${t('analysis.warnings.has-twr')}`; if (Object.keys(cargoWarnings.value).some((k) => k.includes('-tn'))) - analysisStr += `
${t('cargo-warnings.has-tn')}`; + analysisStr += `
${t('analysis.warnings.has-tn')}`; if (cargoWarnings.value['zags-loaded-twr'] || cargoWarnings.value['zags-empty-tn']) { analysisStr += `
33UN1965 ${cargoWarnings.value['zags-loaded-twr'] || 0}/${cargoWarnings.value['zags-empty-tn'] || 0} Zags`; @@ -336,7 +358,7 @@ const analysisString = computed(() => { } if (Object.keys(cargoWarnings.value).some((k) => k.includes('-pn'))) { - analysisStr += `${t('cargo-warnings.has-pn')}:`; + analysisStr += `${t('analysis.warnings.has-pn')}:`; if (cargoWarnings.value['innofreight-all-pn']) { analysisStr += `
- Innofreight - przekroczona skrajnia`; @@ -356,9 +378,15 @@ const analysisString = computed(() => { @use '../../styles/responsive'; @use '../../styles/badge'; -.driver-propositions { - margin-bottom: 1em; +hr.divider { + margin: 0.5em 0; + border-bottom: #111; + border-width: 2px; +} + +.analysis-box { padding: 0.5em; + margin-bottom: 1em; background-color: #111; } @@ -391,34 +419,43 @@ const analysisString = computed(() => { color: #ccc; } -.cargo-warnings { - margin-top: 0.5em; - - h3 { - margin: 0.5em 0; - } -} - .warnings-container { display: flex; flex-wrap: wrap; gap: 0.5em; } -.analysis { +.analysis-html { + display: inline-block; + padding: 0.5em; + background-color: #2e2e2e; margin-top: 0.5em; + user-select: none; +} - h3 { - margin: 0.5em 0; +.analysis-header { + display: flex; + align-items: center; + gap: 0.5em; + + .btn { + padding: 0; } } -.actions { - margin-top: 0.5em; +.analysis-actions { + display: flex; + gap: 0.5em; + margin: 0.5em 0; +} + +.number-info { + font-size: 0.85em; + color: #aaa; } @include responsive.smallScreen { - .driver-propositions { + .analysis-box { text-align: center; } diff --git a/src/components/DriverView/DriverTrainCard.vue b/src/components/DriverView/DriverTrainCard.vue index a32a30e..cfcc24d 100644 --- a/src/components/DriverView/DriverTrainCard.vue +++ b/src/components/DriverView/DriverTrainCard.vue @@ -4,12 +4,8 @@
- -
@@ -44,32 +40,12 @@ const props = defineProps({ } }); -function copyStockToClipboard() { - const stockString = props.chosenTrain.stockList.join(';'); - - if (!stockString) { - alert(i18n.t('trains.stock-clipboard-failure')); - return; - } - - navigator.clipboard - .writeText(stockString) - .then(() => { - prompt(i18n.t('trains.stock-clipboard-success'), stockString); - }) - .catch(() => { - alert(i18n.t('trains.stock-clipboard-failure')); - }); -} - function toggleNumberPropositions() { arePropositionsVisible.value = !arePropositionsVisible.value; } diff --git a/src/components/guide/essentials/scope b/src/components/guide/essentials/scope new file mode 100644 index 0000000..e69de29 diff --git a/src/locales/en.json b/src/locales/en.json index 90d0729..4790207 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -437,27 +437,45 @@ "driver-not-found-desc-2": "You can browse timetable history in the", "driver-not-found-journal": "TIMETABLES JOURNAL", "driver-not-found-others": "Player {driver} is online as:", - "driver-not-found-return": "RETURN TO THE MAIN SITE", + "driver-not-found-return": "RETURN TO THE MAIN SITE" + }, + + "analysis": { + "button-show": "ANALYSIS & STOCK", + "number-info": "will be automatically updated to the current train number chosen in the simulator after the analysis is sent in the chat.", + "button-copy": "COPY THE ANALYSIS", + "title": "Analysis content", "stock-copy": "COPY THE STOCK", - "number-propositions": "NUMBER & WARNINGS SUGGESTIONS", "stock-clipboard-success": "Successfully copied the railway stock in a text form to your clipboard!", "stock-clipboard-failure": "Oops! Something happened and the railway stock couldn't be copied to your clipboard! :/", - "number-propositions-header": "Generate number examples for a train category:", - "number-propositions-third-number": "Third digit:", - "number-propositions-last-nums": "{count} last digits from the range of:", - "number-propositions-title": "Propositions:", - "number-propositions-empty": "No propositions available for the chosen category! :/" - }, - "cargo-warnings": { - "title": "Additional cargo warnings:", - "pn-innofreight": "PN: Innofreight C45: exceeded gauge", - "twr-un1965": "TWR: UN1965 (LPG)", - "tn-un1965": "TN: unclean tanks after UN1965", - "tn-un1202": "TN: UN1202 (diesel fuel)", - "tn-un1202-empty": "TN: unclean tanks after UN1202", - "pn-military": "PN: military transport", - "pn-edk80": "PN: EDK80 railway crane" + + "propositions": { + "title": "Number propositions:", + "header": "Generate number examples for the chosen train category:", + "third-number": "Third digit:", + "last-nums": "{count} last digits from the range of:", + "empty": "No propositions available for the chosen category! :/" + }, + + "warnings": { + "title": "Additional cargo warnings:", + "zags-loaded-twr": "TWR: UN1965 (LPG)", + "zags-empty-tn": "TN: unclean tanks after UN1965", + "zans-loaded-tn": "TN: UN1202 (diesel fuel)", + "zans-empty-tn": "TN: unclean tanks after UN1202", + "military-all-pn": "PN: military transport", + "edk80-all-pn": "PN: EDK80 railway crane", + "innofreight-all-pn": "PN: Innofreight C45: exceeded gauge", + + "has-pn": "* contains extraordinary deliveries (PN)", + "has-tn": "* contains dangerous cargo (TN)", + "has-twr": "* contains high risk dangerous cargo (TWR)", + + "empty": "empty", + "loaded": "loaded" + } }, + "train-stats": { "stats-button": "STATISTICS", "title": "ONLINE TRAINS STATS", diff --git a/src/locales/pl.json b/src/locales/pl.json index f4e554d..ff8bb21 100644 --- a/src/locales/pl.json +++ b/src/locales/pl.json @@ -426,31 +426,45 @@ "driver-not-found-others": "Gracz {driver} jest online jako:", "driver-not-found-return": "WRÓĆ NA STRONĘ GŁÓWNĄ", "stock-copy": "SKOPIUJ SKŁAD", - "number-propositions": "PROPOZYCJE NUMERÓW I UWAG", "stock-clipboard-success": "Pomyślnie skopiowano skład w postaci tekstowej do schowka!", - "stock-clipboard-failure": "Ups! Nie udało się skopiować składu do schowka! :/", - "number-propositions-header": "Wygeneruj propozycje numerów dla pociągu kategorii:", - "number-propositions-third-number": "Trzecia cyfra:", - "number-propositions-last-nums": "{count} ostatnie cyfry z przedziału:", - "number-propositions-title": "Propozycje:", - "number-propositions-empty": "Brak propozycji dla wybranej kategorii! :/" + "stock-clipboard-failure": "Ups! Nie udało się skopiować składu do schowka! :/" }, - "cargo-warnings": { - "title": "Dodatkowe uwagi przewozowe:", - "zags-loaded-twr": "TWR: UN1965 (LPG)", - "zags-empty-tn": "TN: brudne cysterny po UN1965", - "zans-tn": "TN: UN1202 (olej napędowy)", - "zans-empty-tn": "TN: brudne cysterny po UN1202", - "military-all-pn": "PN: transport wojskowy", - "edk80-all-pn": "PN: żuraw kolejowy EDK80", - "innofreight-all-pn": "PN: Innofreight C45: przekroczona skrajnia", - "has-pn": "* przejazd z przesyłkami nadzwyczajnymi (PN)", - "has-tn": "* przewozi towary niebezpieczne (TN)", - "has-twr": "* przewozi towary niebezpieczne wysokiego ryzyka (TWR)", + "analysis": { + "button-show": "ANALIZA I SKŁAD", + "number-info": "zostanie automatycznie zaktualizowany na obecny numer wybrany w symulatorze po wysłaniu wiadomości na czacie.", + "button-copy": "SKOPIUJ ANALIZĘ", + "title": "Treść analizy", - "empty": "puste", - "loaded": "pełne" + "stock-copy": "SKOPIUJ SKŁAD", + "stock-clipboard-success": "Pomyślnie skopiowano skład w postaci tekstowej do schowka:", + "stock-clipboard-failure": "Ups! Nie udało się skopiować składu do schowka! :/", + + "propositions": { + "title": "Propozycje numerów:", + "header": "Wygeneruj analizę dla pociągu wybranej kategorii:", + "third-number": "Trzecia cyfra:", + "last-nums": "{count} ostatnie cyfry z przedziału:", + "empty": "Brak propozycji dla wybranej kategorii!" + }, + + "warnings": { + "title": "Dodatkowe uwagi przewozowe:", + "zags-loaded-twr": "TWR: UN1965 (LPG)", + "zags-empty-tn": "TN: brudne cysterny po UN1965", + "zans-loaded-tn": "TN: UN1202 (olej napędowy)", + "zans-empty-tn": "TN: brudne cysterny po UN1202", + "military-all-pn": "PN: transport wojskowy", + "edk80-all-pn": "PN: żuraw kolejowy EDK80", + "innofreight-all-pn": "PN: Innofreight C45: przekroczona skrajnia", + + "has-pn": "* przejazd z przesyłkami nadzwyczajnymi (PN)", + "has-tn": "* przewozi towary niebezpieczne (TN)", + "has-twr": "* przewozi towary niebezpieczne wysokiego ryzyka (TWR)", + + "empty": "puste", + "loaded": "pełne" + } }, "train-stats": { "stats-button": "STATYSTYKI", @@ -497,9 +511,7 @@ "stock-timetable-speed": "Prędkość RJ", "stock-dangers": "DODATKOWE UWAGI", "stock-preview": "PODGLĄD SKŁADU", - "stock-copy": "SKOPIUJ SKŁAD", - "stock-clipboard-success": "Pomyślnie skopiowano skład w postaci tekstowej do schowka:", - "stock-clipboard-failure": "Ups! Nie udało się skopiować składu do schowka! :/", + "stock-copy": "KOPIUJ SKŁAD", "load-data": "Pobierz dalszą historię...", "last-seen-at": "Ostatnio widziany na: ", "currently-at": "Obecnie na scenerii: ",