i18n: extract remaining

This commit is contained in:
ShareVB committed 2026-11-29 21:06:45 +01:00
1 parent 9bc5d66211
commit 2b77e593cd
6 files changed
+160 -62

No files matched your search

@@ -39,29 +39,39 @@ function calculateStuff() {
try {
if (options.time && options.length && options.pace) {
throw new Error('Only two of "time", "length" and "pace" may be provided at any time');
throw new Error(
t('tools.running-pace-calculator.texts.only-two-of-time-length-and-pace-may-be-provided-at-any-time'),
);
} else if (options.time && options.pace) {
if (options.speed) {
throw new Error('Speed is only valid when (only) pace is given or calculated');
throw new Error(
t('tools.running-pace-calculator.texts.speed-is-only-valid-when-only-pace-is-given-or-calculated'),
);
}
resultType.value = 'Length';
resultType.value = t('tools.token-generator.length');
result.value = `${runPace.calculateLength(options)}`;
} else if (options.time && options.length) {
const label = options.speed ? 'Speed' : 'Pace';
const label = options.speed
? t('tools.running-pace-calculator.texts.speed')
: t('tools.running-pace-calculator.texts.pace');
resultType.value = label;
result.value = `${runPace.calculatePace(options)}`;
} else if (options.pace && options.length) {
if (options.speed) {
throw new Error('Speed is only valid when (only) pace is given or calculated');
throw new Error(
t('tools.running-pace-calculator.texts.speed-is-only-valid-when-only-pace-is-given-or-calculated-0'),
);
}
resultType.value = 'Time';
resultType.value = t('tools.ttl-calculator.texts.label-time');
result.value = `${runPace.calculateTime(options)}`;
} else if (options.pace && options.speed) {
resultType.value = 'Speed';
resultType.value = t('tools.running-pace-calculator.texts.speed-0');
result.value = `${runPace.paceToSpeed(options)}`;
} else {
throw new Error(
'Two of "time", "length" and "pace" must be provided.\nSpeed is only valid when pace is given or calculated.',
t(
'tools.running-pace-calculator.texts.two-of-time-length-and-pace-must-be-provided-nspeed-is-only-valid-when-pace-is-given-or-calculated',
),
);
}
} catch (e: any) {
@@ -82,8 +92,12 @@ function calculateStuff() {
<NButton size="small" @click="length = '1km'">1km</NButton>
<NButton size="small" @click="length = '5km'">5km</NButton>
<NButton size="small" @click="length = '10km'">10km</NButton>
<NButton size="small" @click="length = '21.0975km'">Half Marathon</NButton>
<NButton size="small" @click="length = '42.195km'">Marathon</NButton>
<NButton size="small" @click="length = '21.0975km'">{{
$t('tools.running-pace-calculator.texts.half-marathon')
}}</NButton>
<NButton size="small" @click="length = '42.195km'">{{
$t('tools.running-pace-calculator.texts.marathon')
}}</NButton>
<NButton size="small" @click="length = '50km'">50km</NButton>
</n-space>
</NFormItem>
@@ -139,7 +153,11 @@ function calculateStuff() {
</c-alert>
<c-card v-if="result" :title="t('tools.running-pace-calculator.texts.title-result')">
<input-copyable :label="`${resultType}:`" label-position="left" :value="result" />
<input-copyable
:label="$t('tools.running-pace-calculator.texts.resulttype', [resultType])"
label-position="left"
:value="result"
/>
</c-card>
</div>
</template>
+3 -2
View File
@@ -1,9 +1,10 @@
import { translate as t } from '@/plugins/i18n.plugin';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Running Pace Planner',
name: t('tools.running-planner.title'),
path: '/running-planner',
description: 'Running pace planner tool to help you plan your running pace and training schedule.',
description: t('tools.running-planner.description'),
keywords: ['running', 'pace', 'marathon', 'planner'],
component: () => import('./running-planner.vue'),
icon: defineAsyncComponent(() => import('@vicons/tabler/es/Run')),
+38 -33
View File
@@ -2,19 +2,19 @@
<div>
<n-grid :cols="24" :x-gap="16">
<n-grid-item :span="6">
<n-form-item label="Unit:" label-placement="left">
<n-form-item :label="t('tools.running-planner.texts.label-unit')" label-placement="left">
<n-select v-model:value="unit" :options="unitOptions" />
</n-form-item>
</n-grid-item>
<n-grid-item :span="10">
<n-form-item label="Race:" label-placement="left">
<n-form-item :label="t('tools.running-planner.texts.label-race')" label-placement="left">
<n-select :value="selectedRace" :options="raceOptions" clearable @update:value="onRaceSelect" />
</n-form-item>
</n-grid-item>
<n-grid-item :span="8">
<n-form-item :label="`Distance (${unit}):`" label-placement="left">
<n-form-item :label="$t('tools.running-planner.texts.distance-unit', [unit])" label-placement="left">
<n-input-number v-model:value="distance" :min="1" :max="100" :step="0.1" style="width: 100%" />
</n-form-item>
</n-grid-item>
@@ -22,12 +22,12 @@
<n-grid :cols="24" :x-gap="16">
<n-grid-item :span="12">
<n-form-item :label="`Pace (${unitLabel}):`" label-placement="left">
<n-form-item :label="$t('tools.running-planner.texts.pace-unitlabel', [unitLabel])" label-placement="left">
<n-grid :cols="2" :x-gap="8">
<n-grid-item>
<n-input-number
v-model:value="paceMinutes"
placeholder="Minutes"
:placeholder="t('tools.running-planner.texts.placeholder-minutes')"
:min="0"
:max="30"
style="width: 100%"
@@ -37,7 +37,7 @@
<n-grid-item>
<n-input-number
v-model:value="paceSeconds"
placeholder="Seconds"
:placeholder="t('tools.running-planner.texts.placeholder-seconds')"
:min="0"
:max="59"
style="width: 100%"
@@ -48,7 +48,7 @@
</n-grid-item>
<n-grid-item :span="12">
<n-form-item label="Checkpoints:" label-placement="left">
<n-form-item :label="t('tools.running-planner.texts.label-checkpoints')" label-placement="left">
<n-select v-model:value="splitInterval" :options="intervalOptions" />
</n-form-item>
</n-grid-item>
@@ -63,22 +63,27 @@
<n-card>
<n-grid :cols="2">
<n-grid-item>
<n-statistic label="Race" :value="distanceName" />
<n-statistic :label="t('tools.running-planner.texts.label-race')" :value="distanceName" />
</n-grid-item>
<n-grid-item>
<n-statistic label="Estimated Finish Time" :value="estimatedFinishTime" />
<n-statistic
:label="t('tools.running-planner.texts.label-estimated-finish-time')"
:value="estimatedFinishTime"
/>
</n-grid-item>
</n-grid>
</n-card>
<n-card title="Projected Checkpoints">
<n-card :title="t('tools.running-planner.texts.title-projected-checkpoints')">
<n-data-table :columns="columns" :data="rows" :pagination="{ pageSize: 20 }" :bordered="false" />
</n-card>
</div>
</template>
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
const { t } = useI18n();
import { computed, h, ref } from 'vue';
import { NTag, type DataTableColumns } from 'naive-ui';
@@ -99,63 +104,63 @@ const selectedRace = ref<string | null>('marathon');
const unitOptions = [
{
label: 'Kilometers',
label: t('tools.running-planner.texts.label-kilometers'),
value: 'km',
},
{
label: 'Miles',
label: t('tools.running-planner.texts.label-miles'),
value: 'mi',
},
];
const racePresets = [
{
label: '5K',
label: t('tools.running-planner.texts.label-5k'),
value: '5k',
distanceKm: 5,
},
{
label: '10K',
label: t('tools.running-planner.texts.label-10k'),
value: '10k',
distanceKm: 10,
},
{
label: '15K',
label: t('tools.running-planner.texts.label-15k'),
value: '15k',
distanceKm: 15,
},
{
label: '10 Mile',
label: t('tools.running-planner.texts.label-10-mile'),
value: '10mile',
distanceKm: 16.09344,
},
{
label: '20K',
label: t('tools.running-planner.texts.label-20k'),
value: '20k',
distanceKm: 20,
},
{
label: 'Half Marathon',
label: t('tools.running-planner.texts.label-half-marathon'),
value: 'half',
distanceKm: 21.0975,
},
{
label: '25K',
label: t('tools.running-planner.texts.label-25k'),
value: '25k',
distanceKm: 25,
},
{
label: '30K',
label: t('tools.running-planner.texts.label-30k'),
value: '30k',
distanceKm: 30,
},
{
label: 'Marathon',
label: t('tools.running-planner.texts.label-marathon'),
value: 'marathon',
distanceKm: 42.195,
},
{
label: '50K Ultra',
label: t('tools.running-planner.texts.label-50k-ultra'),
value: '50k',
distanceKm: 50,
},
@@ -215,33 +220,33 @@ const intervalOptions = computed(() => {
return unit.value === 'km'
? [
{
label: 'Every 1 km',
label: t('tools.running-planner.texts.label-every-1-km'),
value: 1,
},
{
label: 'Every 2 km',
label: t('tools.running-planner.texts.label-every-2-km'),
value: 2,
},
{
label: 'Every 5 km',
label: t('tools.running-planner.texts.label-every-5-km'),
value: 5,
},
{
label: 'Every 10 km',
label: t('tools.running-planner.texts.label-every-10-km'),
value: 10,
},
]
: [
{
label: 'Every 1 mile',
label: t('tools.running-planner.texts.label-every-1-mile'),
value: 1,
},
{
label: 'Every 2 miles',
label: t('tools.running-planner.texts.label-every-2-miles'),
value: 2,
},
{
label: 'Every 5 miles',
label: t('tools.running-planner.texts.label-every-5-miles'),
value: 5,
},
];
@@ -254,7 +259,7 @@ const distanceName = computed(() => {
const found = racePresets.find((race) => Math.abs(race.distanceKm - currentKm) < 0.1);
return found?.label ?? 'Custom Distance';
return found?.label ?? t('tools.running-planner.texts.custom-distance');
});
const paceVariants = computed(() => [
@@ -270,7 +275,7 @@ const paceVariants = computed(() => [
},
{
key: 'target',
title: 'Target',
title: t('tools.running-planner.texts.target'),
seconds: paceInSeconds.value,
},
{
@@ -324,7 +329,7 @@ const rows = computed(() => {
const columns = computed<DataTableColumns<any>>(() => {
const result: DataTableColumns<any> = [
{
title: `Distance (${unit.value})`,
title: t('tools.running-planner.texts.distance-unit-value', [unit.value]),
key: 'distance',
width: 160,
fixed: 'left',
@@ -349,7 +354,7 @@ const columns = computed<DataTableColumns<any>>(() => {
paceVariants.value.forEach((variant) => {
result.push({
title:
variant.title === 'Target'
variant.title === t('tools.running-planner.texts.target-0')
? paceToLabel(variant.seconds)
: `${variant.title} (${paceToLabel(variant.seconds)})`,
key: variant.key,
+3 -2
View File
@@ -1,9 +1,10 @@
import { translate as t } from '@/plugins/i18n.plugin';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'SSH Key Format Converter',
name: t('tools.ssh-key-converter.title'),
path: '/ssh-key-converter',
description: 'Convert SSH keys between different formats',
description: t('tools.ssh-key-converter.description'),
keywords: ['ssh', 'key', 'rfc4716', 'pkcs1', 'pem', 'pkcs8', 'converter'],
component: () => import('./ssh-key-converter.vue'),
icon: defineAsyncComponent(() => import('@vicons/tabler/es/ShieldChevron')),
@@ -2,33 +2,40 @@
<div>
<n-grid :cols="2" :x-gap="12">
<n-gi>
<n-form-item label="Source Format">
<n-form-item :label="t('tools.ssh-key-converter.texts.label-source-format')">
<n-select v-model:value="sourceFormat" :options="sourceOptions" />
</n-form-item>
</n-gi>
<n-gi>
<n-form-item label="Target Format">
<n-form-item :label="t('tools.ssh-key-converter.texts.label-target-format')">
<n-select v-model:value="targetFormat" :options="targetOptions" />
</n-form-item>
</n-gi>
</n-grid>
<n-form-item label="Input Key" label-placement="top">
<n-input v-model:value="inputKey" type="textarea" :rows="12" placeholder="Paste SSH key here..." />
<n-form-item :label="t('tools.ssh-key-converter.texts.label-input-key')" label-placement="top">
<n-input
v-model:value="inputKey"
type="textarea"
:rows="12"
:placeholder="t('tools.ssh-key-converter.texts.placeholder-paste-ssh-key-here')"
/>
</n-form-item>
<n-alert v-if="error" type="error">
{{ error }}
</n-alert>
<n-card v-if="outputKey" title="Output Key" type="info" size="small" mb-1>
<n-card v-if="outputKey" :title="t('tools.ssh-key-converter.texts.title-output-key')" type="info" size="small" mb-1>
<textarea-copyable :value="outputKey" readonly />
</n-card>
</div>
</template>
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
const { t } = useI18n();
import sshpk from 'sshpk';
import { detectFormat, openSSHToRFC4716, rfc4716ToOpenSSH, type KeyFormat } from './ssh-key-converter.service';
import { useQueryParamOrStorage } from '@/composable/queryParams';
@@ -44,18 +51,18 @@ const targetFormat = useQueryParamOrStorage<KeyFormat>({
});
const sourceOptions = [
{ label: 'Auto Detect', value: 'auto' },
{ label: 'OpenSSH', value: 'ssh' },
{ label: 'RFC4716', value: 'rfc4716' },
{ label: 'PEM', value: 'pem' },
{ label: 'PKCS8', value: 'pkcs8' },
{ label: t('tools.ssh-key-converter.texts.label-auto-detect'), value: 'auto' },
{ label: t('tools.ssh-key-converter.texts.label-openssh'), value: 'ssh' },
{ label: t('tools.ssh-key-converter.texts.label-rfc4716'), value: 'rfc4716' },
{ label: t('tools.ssh-key-converter.texts.label-pem'), value: 'pem' },
{ label: t('tools.ssh-key-converter.texts.label-pkcs8'), value: 'pkcs8' },
];
const targetOptions = [
{ label: 'OpenSSH', value: 'ssh' },
{ label: 'RFC4716', value: 'rfc4716' },
{ label: 'PEM', value: 'pem' },
{ label: 'PKCS8', value: 'pkcs8' },
{ label: t('tools.ssh-key-converter.texts.label-openssh'), value: 'ssh' },
{ label: t('tools.ssh-key-converter.texts.label-rfc4716'), value: 'rfc4716' },
{ label: t('tools.ssh-key-converter.texts.label-pem'), value: 'pem' },
{ label: t('tools.ssh-key-converter.texts.label-pkcs8'), value: 'pkcs8' },
];
function parseKey(key: string, format: KeyFormat) {