forked from gander-tools/nms-frigate-calc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from NMSCD/dev
add i18n; bump deps
- Loading branch information
Showing
16 changed files
with
1,137 additions
and
481 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
<script setup lang="ts"> | ||
import { useDark, useToggle } from '@vueuse/core'; | ||
import { useI18n } from '@/hooks/useI18n'; | ||
const { t } = useI18n(); | ||
const isDark = useDark({ attribute: 'data-theme' }); | ||
const toggleDark = useToggle(isDark); | ||
</script> | ||
|
||
<template> | ||
<button @click="toggleDark()">Switch Theme</button> | ||
<button @click="toggleDark()">{{ t('translation.switchtheme') }}</button> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { i18n, messages } from '@/i18n'; | ||
|
||
type Join<FirstType, SecondType> = FirstType extends string | number | ||
? SecondType extends string | number | ||
? `${FirstType}${'' extends SecondType ? '' : '.'}${SecondType}` | ||
: never | ||
: never; | ||
|
||
/** | ||
* Helper type that transforms an object tree into a union type of all possibles leaves. | ||
*/ | ||
type Leaves<ObjectType> = | ||
ObjectType extends Record<string, unknown> | ||
? // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
{ [Key in keyof ObjectType]-?: Join<Key, Leaves<ObjectType[Key]>> }[keyof ObjectType] | ||
: ''; | ||
|
||
export type I18NLeaves = Leaves<(typeof messages)['Español']>; | ||
|
||
// This function adds type safety to the i18n t function. | ||
export function useI18n() { | ||
// eslint-disable-next-line @typescript-eslint/unbound-method | ||
const { t, te, d, n, tm, rt, ...globalApi } = i18n.global; | ||
|
||
type RemoveFirstFromTuple<T extends unknown[]> = ((...b: T) => void) extends (...b: infer I) => void ? I : []; | ||
|
||
const typedT = t as (...args: [I18NLeaves, ...Partial<RemoveFirstFromTuple<Parameters<typeof t>>>]) => string; | ||
|
||
return { | ||
t: typedT.bind(i18n), | ||
d: d.bind(i18n), | ||
te: te.bind(i18n), | ||
tm: tm.bind(i18n), | ||
rt: rt.bind(i18n), | ||
n: n.bind(i18n), | ||
...globalApi, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import translation from './translation'; | ||
|
||
export default { | ||
translation, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
export default { | ||
viewother: 'View other pages', | ||
switchtheme: 'Switch Theme', | ||
title: 'Frigate Calculator', | ||
statsField: 'Raw Frigate Stats', | ||
traitsField: 'Traits (except Fuel & Duration)', | ||
combat: 'Combat', | ||
exploration: 'Exploration', | ||
industrial: 'Industrial', | ||
trade: 'Trade', | ||
totalbaseStats: 'Total Base Stats:', | ||
expAmmount: 'Amount of Expeditions', | ||
totalRankUps: 'Total Rank-Ups:', | ||
expeditions: 'Expeditions', | ||
addtrait: 'Add Trait', | ||
traitvalue: 'Trait Value', | ||
totalBonusPoints: 'Total Bonus Points:', | ||
frigscore: 'Frigate score (-5 – 14):', | ||
forkedfrom: 'Forked from nms-frigate-calc by', | ||
website: 'Website', | ||
guide: 'A Guide to Evaluating Frigate Stats', | ||
formula: 'Formula sources:', | ||
buyersguide: 'Frigate Buyer\'s Guide - How to Pick the Best Ships (and avoid "Lemons")', | ||
help: 'Help', | ||
close: 'Close', | ||
wheretofind: 'Where to find', | ||
stats: 'Stats', | ||
traits: 'Traits', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import translation from './translation'; | ||
|
||
export default { | ||
translation, | ||
}; |
Oops, something went wrong.