Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Language Selector (vue-i18n) #66

Merged
merged 3 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 125 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
},
"dependencies": {
"@picocss/pico": "^2.0.6",
"vue": "^3.5.13"
"pinia": "^2.3.0",
"vue": "^3.5.13",
"vue-i18n": "^11.0.1"
},
"devDependencies": {
"@types/node": "^22.10.2",
Expand Down
60 changes: 42 additions & 18 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
<script setup lang="ts">
import { computed, ref } from 'vue';
import { computed, ref, watch } from 'vue';
import NavBar from './components/NavBar.vue';
import TraitInput from './components/TraitInput.vue';
import StatInput from './components/StatInput.vue';
import { isNumberInput } from './helpers/validation';
import HelpPopup from './components/HelpPopup.vue';
import { useI18n } from '@/hooks/useI18n';
import { usePageDataStore } from '@/stores/pageData';
import { storeToRefs } from 'pinia';

const pageData = usePageDataStore();
const { selectedLanguage } = storeToRefs(pageData);

const { t } = useI18n();

const levelUps = [4, 8, 15, 25, 30, 35, 40, 45, 50, 55]; // NoSonar these are given by the game

Expand All @@ -18,8 +26,23 @@ const traitValues = ref<number[]>([0]);
const addTrait = () => traitValues.value.push(0);
const removeTrait = (index: number) => (traitValues.value = traitValues.value.filter((_, idx) => idx !== index));

const stats = ['Combat', 'Exploration', 'Industrial', 'Trade'];
const statValues = ref<number[]>(Array.from({ length: stats.length }, () => 0));
const stats = ref([
Muhaddil marked this conversation as resolved.
Show resolved Hide resolved
t('translation.combat'),
t('translation.exploration'),
t('translation.industrial'),
t('translation.trade'),
]);

watch(selectedLanguage, () => {
Muhaddil marked this conversation as resolved.
Show resolved Hide resolved
stats.value = [
t('translation.combat'),
t('translation.exploration'),
t('translation.industrial'),
t('translation.trade'),
];
});

const statValues = ref<number[]>(Array.from({ length: stats.value.length }, () => 0));

const expeditionCount = ref(0);
const isExpeditionCountValid = computed(() => isNumberInput(expeditionCount.value.toString()));
Expand Down Expand Up @@ -62,14 +85,14 @@ const progressClassName = computed(() => {
<template>
<header>
<NavBar />
<h1 class="text-center">Frigate Calculator</h1>
<h1 class="text-center">{{ t('translation.title') }}</h1>
</header>

<main>
<form @submit.prevent>
<fieldset>
<legend>
<span>Raw Frigate Stats</span>
<span>{{ t('translation.statsField') }}</span>
<HelpPopup input="stats" />
</legend>

Expand All @@ -80,12 +103,12 @@ const progressClassName = computed(() => {
:placeholder="stat"
/>
</div>
<p>Total Base Stats: {{ combinedStats }}</p>
<p>{{ t('translation.totalbaseStats') }} {{ combinedStats }}</p>
</fieldset>

<fieldset>
<legend>
<span>Traits (except Fuel & Duration)</span>
<span>{{ t('translation.traitsField') }}</span>
<HelpPopup input="traits" />
</legend>
<div class="trait-list">
Expand All @@ -100,28 +123,29 @@ const progressClassName = computed(() => {
class="add-trait-button"
@click="addTrait"
>
Add Trait
{{ t('translation.addtrait') }}
</button>
<p>Total Bonus Points: {{ combinedTraits }}</p>
<p>{{ t('translation.totalBonusPoints') }} {{ combinedTraits }}</p>
</fieldset>

<fieldset>
<legend>
<span>Amount of Expeditions</span>
<span>{{ t('translation.expAmmount') }}</span>
<HelpPopup input="expeditions" />
</legend>
<input
v-model.trim.number="expeditionCount"
:aria-invalid="!isExpeditionCountValid || undefined"
type="text"
placeholder="Expeditions"
:placeholder="t('translation.expeditions')"
/>
<p>Total Rank-Ups: {{ calculatedExpeditionLevel }}</p>

<p>{{ t('translation.totalRankUps') }} {{ calculatedExpeditionLevel }}</p>
</fieldset>
</form>

<p>
Frigate score (-5 – 14): <output class="text-bold">{{ calculatedBaseStat }}</output>
{{ t('translation.frigscore') }} <output class="text-bold">{{ calculatedBaseStat }}</output>
</p>

<progress
Expand All @@ -136,7 +160,7 @@ const progressClassName = computed(() => {

<footer>
<div class="credits text-center">
Forked from nms-frigate-calc by
{{ t('translation.forkedfrom') }}
<a
href="https://github.com/gander/"
target="_blank"
Expand All @@ -146,7 +170,7 @@ const progressClassName = computed(() => {
(<a
href="https://nms.gander.tools/"
target="_blank"
>Website</a
>{{ t('translation.website') }}</a
>
|
<a
Expand All @@ -157,20 +181,20 @@ const progressClassName = computed(() => {
</div>

<div class="sources">
<p>Formula sources:</p>
<p>{{ t('translation.formula') }}</p>
<ul>
<li>
<a
href="https://steamcommunity.com/sharedfiles/filedetails/?id=1505175794"
target="_blank"
>Frigate Buyer's Guide - How to Pick the Best Ships (and avoid "Lemons")</a
>{{ t('translation.buyersguide') }}</a
>
</li>
<li>
<a
href="https://www.reddit.com/r/NoMansSkyTheGame/comments/knjokc/a_guide_to_evaluating_frigate_stats/"
target="_blank"
>A Guide to Evaluating Frigate Stats</a
>{{ t('translation.guide') }}</a
>
</li>
</ul>
Expand Down
Loading
Loading