@vocab/core 1.6.3 → 1.6.5-fix-messageformat-import-20250923004826
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-nOFOJqeH.js +30 -0
- package/dist/icu-handler-9mldObYa.js +29 -0
- package/dist/icu-handler-9mldObYa.js.map +1 -0
- package/dist/icu-handler-COUleaeZ.mjs +22 -0
- package/dist/icu-handler-COUleaeZ.mjs.map +1 -0
- package/dist/icu-handler.d.mts +7 -0
- package/dist/icu-handler.d.ts +7 -0
- package/dist/icu-handler.js +3 -0
- package/dist/icu-handler.mjs +3 -0
- package/dist/index.d.mts +53 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.js +679 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +660 -0
- package/dist/index.mjs.map +1 -0
- package/dist/runtime.d.mts +8 -0
- package/dist/runtime.d.ts +8 -0
- package/dist/runtime.js +13 -0
- package/dist/runtime.js.map +1 -0
- package/dist/runtime.mjs +12 -0
- package/dist/runtime.mjs.map +1 -0
- package/dist/translation-file-BEIJ1-3N.js +34 -0
- package/dist/translation-file-BEIJ1-3N.js.map +1 -0
- package/dist/translation-file-CAOIsAU9.d.mts +7 -0
- package/dist/translation-file-DQOiWtfV.d.ts +7 -0
- package/dist/translation-file-Dn19n2oY.mjs +28 -0
- package/dist/translation-file-Dn19n2oY.mjs.map +1 -0
- package/dist/translation-file.d.mts +3 -0
- package/dist/translation-file.d.ts +3 -0
- package/dist/translation-file.js +3 -0
- package/dist/translation-file.mjs +3 -0
- package/dist/types-DFxEF4pq.d.mts +146 -0
- package/dist/types-Di9uIscO.d.ts +146 -0
- package/package.json +17 -28
- package/README.md +0 -724
- package/dist/declarations/src/compile.d.ts +0 -6
- package/dist/declarations/src/config.d.ts +0 -4
- package/dist/declarations/src/icu-handler.d.ts +0 -2
- package/dist/declarations/src/index.d.ts +0 -6
- package/dist/declarations/src/load-translations.d.ts +0 -32
- package/dist/declarations/src/runtime.d.ts +0 -3
- package/dist/declarations/src/translation-file.d.ts +0 -2
- package/dist/declarations/src/types.d.ts +0 -143
- package/dist/declarations/src/utils.d.ts +0 -26
- package/dist/declarations/src/validate/index.d.ts +0 -3
- package/dist/vocab-core.cjs.d.ts +0 -2
- package/dist/vocab-core.cjs.dev.js +0 -893
- package/dist/vocab-core.cjs.js +0 -7
- package/dist/vocab-core.cjs.prod.js +0 -893
- package/dist/vocab-core.esm.js +0 -866
- package/icu-handler/dist/vocab-core-icu-handler.cjs.d.ts +0 -2
- package/icu-handler/dist/vocab-core-icu-handler.cjs.dev.js +0 -31
- package/icu-handler/dist/vocab-core-icu-handler.cjs.js +0 -7
- package/icu-handler/dist/vocab-core-icu-handler.cjs.prod.js +0 -31
- package/icu-handler/dist/vocab-core-icu-handler.esm.js +0 -23
- package/icu-handler/package.json +0 -4
- package/runtime/dist/vocab-core-runtime.cjs.d.ts +0 -2
- package/runtime/dist/vocab-core-runtime.cjs.dev.js +0 -15
- package/runtime/dist/vocab-core-runtime.cjs.js +0 -7
- package/runtime/dist/vocab-core-runtime.cjs.prod.js +0 -15
- package/runtime/dist/vocab-core-runtime.esm.js +0 -10
- package/runtime/package.json +0 -4
- package/translation-file/dist/vocab-core-translation-file.cjs.d.ts +0 -2
- package/translation-file/dist/vocab-core-translation-file.cjs.dev.js +0 -35
- package/translation-file/dist/vocab-core-translation-file.cjs.js +0 -7
- package/translation-file/dist/vocab-core-translation-file.cjs.prod.js +0 -35
- package/translation-file/dist/vocab-core-translation-file.esm.js +0 -31
- package/translation-file/package.json +0 -4
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { LoadedTranslation, UserConfig } from "./types.js";
|
|
2
|
-
export declare function generateRuntime(loadedTranslation: LoadedTranslation): Promise<void>;
|
|
3
|
-
export declare function watch(config: UserConfig): () => Promise<void>;
|
|
4
|
-
export declare function compile({ watch: shouldWatch }: {
|
|
5
|
-
watch?: boolean | undefined;
|
|
6
|
-
} | undefined, config: UserConfig): Promise<(() => Promise<void>) | undefined>;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { UserConfig } from "./types.js";
|
|
2
|
-
export declare function validateConfig(c: UserConfig): boolean;
|
|
3
|
-
export declare function resolveConfig(customConfigFilePath?: string): Promise<UserConfig | null>;
|
|
4
|
-
export declare function resolveConfigSync(customConfigFilePath?: string): UserConfig | null;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { compile, watch } from "./compile.js";
|
|
2
|
-
export { validate } from "./validate/index.js";
|
|
3
|
-
export { resolveConfig, resolveConfigSync, validateConfig } from "./config.js";
|
|
4
|
-
export { getAltLanguages, getAltLanguageFilePath, getDevLanguageFileFromTsFile, } from "./utils.js";
|
|
5
|
-
export { getUniqueKey, loadAllTranslations, loadTranslation, } from "./load-translations.js";
|
|
6
|
-
export type * from "./types.js";
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { TranslationsByKey, UserConfig, LoadedTranslation, LanguageTarget } from "./types.js";
|
|
2
|
-
import { type Fallback } from "./utils.js";
|
|
3
|
-
export declare function getUniqueKey(key: string, namespace: string): string;
|
|
4
|
-
export declare function mergeWithDevLanguageTranslation({ translation, devTranslation, }: {
|
|
5
|
-
translation: TranslationsByKey;
|
|
6
|
-
devTranslation: TranslationsByKey;
|
|
7
|
-
}): TranslationsByKey;
|
|
8
|
-
export declare function getLanguageHierarchy({ languages, }: {
|
|
9
|
-
languages: LanguageTarget[];
|
|
10
|
-
}): Map<string, string[]>;
|
|
11
|
-
export declare function getFallbackLanguageOrder({ languages, languageName, devLanguage, fallbacks, }: {
|
|
12
|
-
languages: LanguageTarget[];
|
|
13
|
-
languageName: string;
|
|
14
|
-
devLanguage: string;
|
|
15
|
-
fallbacks: Fallback;
|
|
16
|
-
}): string[];
|
|
17
|
-
export declare function loadAltLanguageFile({ filePath, languageName, devTranslation, fallbacks, }: {
|
|
18
|
-
filePath: string;
|
|
19
|
-
languageName: string;
|
|
20
|
-
devTranslation: TranslationsByKey;
|
|
21
|
-
fallbacks: Fallback;
|
|
22
|
-
}, { devLanguage, languages }: UserConfig): TranslationsByKey;
|
|
23
|
-
export declare function loadTranslation({ filePath, fallbacks, withTags, }: {
|
|
24
|
-
filePath: string;
|
|
25
|
-
fallbacks: Fallback;
|
|
26
|
-
withTags?: boolean;
|
|
27
|
-
}, userConfig: UserConfig): LoadedTranslation;
|
|
28
|
-
export declare function loadAllTranslations({ fallbacks, includeNodeModules, withTags, }: {
|
|
29
|
-
fallbacks: Fallback;
|
|
30
|
-
includeNodeModules: boolean;
|
|
31
|
-
withTags?: boolean;
|
|
32
|
-
}, config: UserConfig): Promise<LoadedTranslation[]>;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import type { TranslationModuleByLanguage, LanguageName, ParsedFormatFnByKey, TranslationFile } from "./types.js";
|
|
2
|
-
export declare function createTranslationFile<Language extends LanguageName, FormatFnByKey extends ParsedFormatFnByKey>(translationsByLanguage: TranslationModuleByLanguage<Language, FormatFnByKey>): TranslationFile<Language, FormatFnByKey>;
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
export type { FormatXMLElementFn } from 'intl-messageformat';
|
|
2
|
-
export type LanguageName = string;
|
|
3
|
-
export type TranslationKey = string;
|
|
4
|
-
export type TranslationMessage = string;
|
|
5
|
-
export type ParsedFormatFn = (parts: any) => any;
|
|
6
|
-
export type ParsedFormatFnByKey = Record<string, ParsedFormatFn>;
|
|
7
|
-
/**
|
|
8
|
-
* Equivalent to the `string` type, but tricks TypeScript into prodiving
|
|
9
|
-
* suggestions for string literals passed into the `Suggestions` generic parameter
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* type AnyAnimal = StringWithSuggestions<"cat" | "dog">;
|
|
13
|
-
* // Suggests cat and dog, but accepts any string
|
|
14
|
-
* const animal: AnyAnimal = "";
|
|
15
|
-
*/
|
|
16
|
-
export type StringWithSuggestions<Suggestions extends string> = Suggestions | Omit<string, Suggestions>;
|
|
17
|
-
/**
|
|
18
|
-
* ParsedICUMessage A strictly typed formatter from intl-messageformat
|
|
19
|
-
*/
|
|
20
|
-
interface ParsedICUMessage<FormatFn extends ParsedFormatFn> {
|
|
21
|
-
format: FormatFn;
|
|
22
|
-
}
|
|
23
|
-
export type ParsedICUMessages<FormatFnByKey extends ParsedFormatFnByKey> = {
|
|
24
|
-
[key in keyof FormatFnByKey]: ParsedICUMessage<FormatFnByKey[key]>;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* TranslationModule is a wrapper around a potentially asynchronously loaded set of ParsedICUMessages
|
|
28
|
-
*/
|
|
29
|
-
export type TranslationModule<FormatFnByKey extends ParsedFormatFnByKey> = {
|
|
30
|
-
getValue: (locale: string) => ParsedICUMessages<FormatFnByKey> | undefined;
|
|
31
|
-
load: () => Promise<void>;
|
|
32
|
-
};
|
|
33
|
-
export type TranslationModuleByLanguage<Language extends LanguageName, FormatFnByKey extends ParsedFormatFnByKey> = Record<Language, TranslationModule<FormatFnByKey>>;
|
|
34
|
-
/**
|
|
35
|
-
* TranslationFile contains a record of TranslationModules per language, exposing a set of methods to load and return the module by language
|
|
36
|
-
*/
|
|
37
|
-
export type TranslationFile<Language extends LanguageName, FormatFnByKey extends ParsedFormatFnByKey> = {
|
|
38
|
-
/**
|
|
39
|
-
* Retrieve messages. If not loaded, will attempt to load messages and resolve once complete.
|
|
40
|
-
*/
|
|
41
|
-
getMessages: (language: Language, locale?: string) => Promise<ParsedICUMessages<FormatFnByKey>>;
|
|
42
|
-
/**
|
|
43
|
-
* Retrieve already loaded messages. Will return null if no messages have been loaded.
|
|
44
|
-
*/
|
|
45
|
-
getLoadedMessages: (language: Language, locale?: string) => ParsedICUMessages<FormatFnByKey> | null;
|
|
46
|
-
/**
|
|
47
|
-
* Load messages for the given language. Resolving once complete.
|
|
48
|
-
*/
|
|
49
|
-
load: (language: Language) => Promise<void>;
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* A utility type to get the union of all translation keys from a translation file
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* // translations.json
|
|
56
|
-
* {
|
|
57
|
-
* "Hello": {
|
|
58
|
-
* "message": "Hello",
|
|
59
|
-
* },
|
|
60
|
-
* "Goodbye": {
|
|
61
|
-
* "message": "Goodbye",
|
|
62
|
-
* },
|
|
63
|
-
* }
|
|
64
|
-
*
|
|
65
|
-
* // myFile.ts
|
|
66
|
-
* import { TranslationKeys } from '@vocab/core';
|
|
67
|
-
* import translations from './.vocab';
|
|
68
|
-
*
|
|
69
|
-
* // 'Hello' | 'Goodbye'
|
|
70
|
-
* type TheTranslationKeys = TranslationKeys<typeof translations>;
|
|
71
|
-
*
|
|
72
|
-
* @example
|
|
73
|
-
* import { TranslationKeys } from '@vocab/core';
|
|
74
|
-
* import fooTranslations from './foo.vocab';
|
|
75
|
-
* import barTranslations from './bar.vocab';
|
|
76
|
-
*
|
|
77
|
-
* // It even works with multiple translation files
|
|
78
|
-
* type FooBarTranslationKeys = TranslationKeys<typeof fooTranslations | typeof barTranslations>;
|
|
79
|
-
*/
|
|
80
|
-
export type TranslationKeys<Translations extends TranslationFile<any, ParsedFormatFnByKey>> = Translations extends unknown ? keyof Awaited<ReturnType<Translations['getMessages']>> : never;
|
|
81
|
-
export interface LanguageTarget {
|
|
82
|
-
name: LanguageName;
|
|
83
|
-
extends?: LanguageName;
|
|
84
|
-
}
|
|
85
|
-
export interface MessageGenerator {
|
|
86
|
-
transformElement?: (element: string) => string;
|
|
87
|
-
transformMessage?: (message: string) => string;
|
|
88
|
-
}
|
|
89
|
-
export interface GeneratedLanguageTarget {
|
|
90
|
-
name: LanguageName;
|
|
91
|
-
extends?: LanguageName;
|
|
92
|
-
generator: MessageGenerator;
|
|
93
|
-
}
|
|
94
|
-
export interface UserConfig {
|
|
95
|
-
/**
|
|
96
|
-
* The root directory to compile and validate translations
|
|
97
|
-
*/
|
|
98
|
-
projectRoot?: string;
|
|
99
|
-
/**
|
|
100
|
-
* The language used in translations.json
|
|
101
|
-
*/
|
|
102
|
-
devLanguage: LanguageName;
|
|
103
|
-
/**
|
|
104
|
-
* An array of languages to build for
|
|
105
|
-
*/
|
|
106
|
-
languages: LanguageTarget[];
|
|
107
|
-
/**
|
|
108
|
-
* An array of languages to generate from existing translations
|
|
109
|
-
*/
|
|
110
|
-
generatedLanguages?: GeneratedLanguageTarget[];
|
|
111
|
-
/**
|
|
112
|
-
* A custom suffix to name vocab translation directories
|
|
113
|
-
*/
|
|
114
|
-
translationsDirectorySuffix?: string;
|
|
115
|
-
/**
|
|
116
|
-
* An array of glob paths to ignore from compilation and validation
|
|
117
|
-
*/
|
|
118
|
-
ignore?: string[];
|
|
119
|
-
}
|
|
120
|
-
export type Tags = string[];
|
|
121
|
-
export interface TranslationFileMetadata {
|
|
122
|
-
tags?: Tags;
|
|
123
|
-
}
|
|
124
|
-
export interface TranslationData {
|
|
125
|
-
message: TranslationMessage;
|
|
126
|
-
description?: string;
|
|
127
|
-
tags?: Tags;
|
|
128
|
-
globalKey?: string;
|
|
129
|
-
}
|
|
130
|
-
export type TranslationsByKey<Key extends TranslationKey = string> = Record<Key, TranslationData>;
|
|
131
|
-
export type TranslationFileContents = TranslationsByKey & {
|
|
132
|
-
_meta?: TranslationFileMetadata;
|
|
133
|
-
};
|
|
134
|
-
export type TranslationMessagesByKey<Key extends TranslationKey = string> = Record<Key, TranslationMessage>;
|
|
135
|
-
export type TranslationsByLanguage<Key extends TranslationKey = string> = Record<LanguageName, TranslationsByKey<Key>>;
|
|
136
|
-
export type LoadedTranslation<Key extends TranslationKey = string> = {
|
|
137
|
-
namespace: string;
|
|
138
|
-
keys: Key[];
|
|
139
|
-
filePath: string;
|
|
140
|
-
relativePath: string;
|
|
141
|
-
languages: TranslationsByLanguage<Key>;
|
|
142
|
-
metadata: TranslationFileMetadata;
|
|
143
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { LanguageName, LanguageTarget, TranslationsByKey, TranslationMessagesByKey, UserConfig } from "./types.js";
|
|
2
|
-
export declare const defaultTranslationDirSuffix = ".vocab";
|
|
3
|
-
export declare const devTranslationFileName = "translations.json";
|
|
4
|
-
export type Fallback = 'none' | 'valid' | 'all';
|
|
5
|
-
export declare function isDevLanguageFile(filePath: string): boolean;
|
|
6
|
-
export declare function isAltLanguageFile(filePath: string): boolean;
|
|
7
|
-
export declare function isTranslationDirectory(filePath: string, { translationsDirectorySuffix, }: {
|
|
8
|
-
translationsDirectorySuffix?: string;
|
|
9
|
-
}): boolean;
|
|
10
|
-
export declare function getTranslationFolderGlob({ translationsDirectorySuffix, }: {
|
|
11
|
-
translationsDirectorySuffix?: string;
|
|
12
|
-
}): string;
|
|
13
|
-
export declare function getDevTranslationFileGlob({ translationsDirectorySuffix, }: {
|
|
14
|
-
translationsDirectorySuffix?: string;
|
|
15
|
-
}): string;
|
|
16
|
-
export declare function getAltTranslationFileGlob(config: UserConfig): string;
|
|
17
|
-
export declare function getAltLanguages({ devLanguage, languages, }: {
|
|
18
|
-
devLanguage: LanguageName;
|
|
19
|
-
languages: LanguageTarget[];
|
|
20
|
-
}): string[];
|
|
21
|
-
export declare function getDevLanguageFileFromTsFile(tsFilePath: string): string;
|
|
22
|
-
export declare function getDevLanguageFileFromAltLanguageFile(altLanguageFilePath: string): string;
|
|
23
|
-
export declare function getTSFileFromDevLanguageFile(devLanguageFilePath: string): string;
|
|
24
|
-
export declare function getAltLanguageFilePath(devLanguageFilePath: string, language: string): string;
|
|
25
|
-
export declare function mapValues<Key extends string, OriginalValue, ReturnValue>(obj: Record<Key, OriginalValue>, func: (val: OriginalValue) => ReturnValue): TranslationMessagesByKey<Key>;
|
|
26
|
-
export declare function getTranslationMessages<Key extends string>(translations: TranslationsByKey<Key>): TranslationMessagesByKey<Key>;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { UserConfig, LoadedTranslation, LanguageName } from "../types.js";
|
|
2
|
-
export declare function findMissingKeys(loadedTranslation: LoadedTranslation, devLanguageName: LanguageName, altLanguages: LanguageName[]): readonly [boolean, Record<string, string[]>];
|
|
3
|
-
export declare function validate(config: UserConfig): Promise<boolean>;
|
package/dist/vocab-core.cjs.d.ts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export * from "./declarations/src/index";
|
|
2
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidm9jYWItY29yZS5janMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4vZGVjbGFyYXRpb25zL3NyYy9pbmRleC5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBIn0=
|