fix(i18n): re-fix types

Signed-off-by: Fernando Fernández <ferferga@hotmail.com>
This commit is contained in:
Fernando Fernández
2025-05-07 15:17:57 +02:00
parent 5e0bae0812
commit 58404e1fce
12 changed files with 61 additions and 45 deletions
+6 -1
View File
@@ -17,11 +17,16 @@
"i18n-ally.keystyle": "flat",
"i18n-ally.sortKeys": true,
"i18n-ally.sourceLanguage": "en",
"i18n-ally.includeSubfolders": false,
"i18n-ally.fullReloadOnChanged": true,
"i18n-ally.extract.autoDetect": true,
"i18n-ally.annotations": false,
"i18n-ally.localesPaths": [
"packages/i18n/strings"
],
"i18n-ally.enabledFrameworks": [
"vue"
"i18next",
"vue-sfc"
],
"eslint.validate": [
"vue",
+1
View File
@@ -8,6 +8,7 @@
],
"types": [
"axios",
"@jellyfin-vue/i18n",
"unplugin-vue-router/client",
"vite/client",
"vuetify",
+2
View File
@@ -81,6 +81,7 @@
"@storybook/blocks": "*",
"@storybook/vue3": "*",
"@storybook/vue3-vite": "*",
"@vue/shared": "*",
"storybook": "*",
"type-fest": "*",
"vite": "*"
@@ -13735,6 +13736,7 @@
"@jellyfin-vue/configs": "*"
},
"peerDependencies": {
"@jellyfin-vue/i18n": "*",
"@vueuse/core": "*",
"comlink": "*",
"i18next-vue": "*",
+2
View File
@@ -0,0 +1,2 @@
import './types/i18next.d.ts';
import './types/virtual-modules.d.ts';
+5 -2
View File
@@ -2,11 +2,14 @@
"name": "@jellyfin-vue/i18n",
"type": "module",
"description": "All internacionalization files for Jellyfin Vue",
"types": "./types.d.ts",
"exports": {
".": "./src/index.ts",
".": {
"import": "./src/index.ts",
"types": "./index.d.ts"
},
"./vite": "./src/vite.ts"
},
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint . --fix",
+6 -6
View File
@@ -16,13 +16,13 @@ await i18next
type: 'backend',
init: NOOP,
read: (language, _, done) => {
const promise = resources[language] as Promise<Record<string, string>>;
const loadFn = resources[language];
void (async () => {
const data = await promise;
done(undefined, data);
})();
if (loadFn) {
void (async () => done(undefined, await loadFn()))();
} else {
done(new Error(`Language ${language} not found`), {});
}
}
} satisfies BackendModule)
.init({
+2 -2
View File
@@ -14,8 +14,8 @@
"coverage"
],
"include": [
"*.d.ts",
"*.ts",
"**/*.d.ts",
"**/*.ts",
"src/*.ts",
"**/*.json"
],
-34
View File
@@ -1,34 +0,0 @@
import type en from './strings/en.json';
type Resources = Record<string, () => Promise<typeof en>>;
declare module 'i18next' {
interface CustomTypeOptions {
resources: Resources;
strictKeyChecks: true;
}
}
declare module 'virtual:locales/date-fns' {
import * as locales from 'date-fns/locale';
export = locales;
}
declare module 'virtual:locales/vuetify' {
import type * as locales from 'vuetify/locale';
const typeWithoutRtl: Omit<typeof locales, 'defaultRtl'>;
export = typeWithoutRtl;
}
declare module 'virtual:i18next/resources' {
export const resources: Resources;
}
/**
* This is important: https://stackoverflow.com/a/64189046
* https://www.typescriptlang.org/docs/handbook/modules.html
*/
export { };
+16
View File
@@ -0,0 +1,16 @@
import type en from '../strings/en.json';
export type LanguageKeys = typeof en;
declare module 'i18next' {
interface CustomTypeOptions {
resources: Record<string, LanguageKeys>;
strictKeyChecks: true;
}
}
/**
* This is important: https://stackoverflow.com/a/64189046
* https://www.typescriptlang.org/docs/handbook/modules.html
*/
export { };
+19
View File
@@ -0,0 +1,19 @@
declare module 'virtual:locales/date-fns' {
import * as locales from 'date-fns/locale';
export = locales;
}
declare module 'virtual:locales/vuetify' {
import type * as locales from 'vuetify/locale';
const typeWithoutRtl: BetterOmit<typeof locales, 'defaultRtl'>;
export = typeWithoutRtl;
}
declare module 'virtual:i18next/resources' {
import type { LanguageKeys } from './types/i18next';
export const resources: Record<string, () => Promise<Record<LanguageKeys, string>>>;
}
+1
View File
@@ -26,6 +26,7 @@
"@jellyfin-vue/configs": "*"
},
"peerDependencies": {
"@jellyfin-vue/i18n": "*",
"@vueuse/core": "*",
"comlink": "*",
"i18next-vue": "*",
+1
View File
@@ -7,6 +7,7 @@
"DOM"
],
"types": [
"@jellyfin-vue/i18n",
"vite/client",
"vue"
]