@vocab/core 1.2.0 → 1.2.1
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/LICENSE +21 -0
- package/dist/declarations/src/ValidationError.d.ts +5 -5
- package/dist/declarations/src/compile.d.ts +6 -6
- package/dist/declarations/src/config.d.ts +4 -4
- package/dist/declarations/src/generate-language.d.ts +5 -5
- package/dist/declarations/src/icu-handler.d.ts +2 -2
- package/dist/declarations/src/index.d.ts +6 -6
- package/dist/declarations/src/load-translations.d.ts +32 -32
- package/dist/declarations/src/logger.d.ts +3 -3
- package/dist/declarations/src/runtime.d.ts +3 -3
- package/dist/declarations/src/translation-file.d.ts +2 -2
- package/dist/declarations/src/utils.d.ts +26 -26
- package/dist/declarations/src/validate/index.d.ts +3 -3
- package/dist/vocab-core.cjs.dev.js +73 -180
- package/dist/vocab-core.cjs.prod.js +73 -180
- package/dist/vocab-core.esm.js +39 -146
- package/icu-handler/dist/vocab-core-icu-handler.cjs.dev.js +3 -6
- package/icu-handler/dist/vocab-core-icu-handler.cjs.prod.js +3 -6
- package/icu-handler/dist/vocab-core-icu-handler.esm.js +2 -5
- package/package.json +2 -2
- package/translation-file/dist/vocab-core-translation-file.cjs.dev.js +0 -8
- package/translation-file/dist/vocab-core-translation-file.cjs.prod.js +0 -8
- package/translation-file/dist/vocab-core-translation-file.esm.js +0 -8
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
### MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 SEEK
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare class ValidationError extends Error {
|
|
2
|
-
code: string;
|
|
3
|
-
rawMessage: string;
|
|
4
|
-
constructor(code: string, message: string);
|
|
5
|
-
}
|
|
1
|
+
export declare class ValidationError extends Error {
|
|
2
|
+
code: string;
|
|
3
|
+
rawMessage: string;
|
|
4
|
+
constructor(code: string, message: string);
|
|
5
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { LoadedTranslation, UserConfig } from '@vocab/types';
|
|
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
|
+
import { LoadedTranslation, UserConfig } from '@vocab/types';
|
|
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 +1,4 @@
|
|
|
1
|
-
import { UserConfig } from '@vocab/types';
|
|
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
|
+
import { UserConfig } from '@vocab/types';
|
|
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,5 +1,5 @@
|
|
|
1
|
-
import { MessageGenerator, TranslationsByKey } from '@vocab/types';
|
|
2
|
-
export declare function generateLanguageFromTranslations({ baseTranslations, generator, }: {
|
|
3
|
-
baseTranslations: TranslationsByKey<string>;
|
|
4
|
-
generator: MessageGenerator;
|
|
5
|
-
}): TranslationsByKey<string>;
|
|
1
|
+
import { MessageGenerator, TranslationsByKey } from '@vocab/types';
|
|
2
|
+
export declare function generateLanguageFromTranslations({ baseTranslations, generator, }: {
|
|
3
|
+
baseTranslations: TranslationsByKey<string>;
|
|
4
|
+
generator: MessageGenerator;
|
|
5
|
+
}): TranslationsByKey<string>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ParsedICUMessages, TranslationMessagesByKey } from '@vocab/types';
|
|
2
|
-
export declare const getParsedICUMessages: (m: TranslationMessagesByKey, locale: string) => ParsedICUMessages<any>;
|
|
1
|
+
import { ParsedICUMessages, TranslationMessagesByKey } from '@vocab/types';
|
|
2
|
+
export declare const getParsedICUMessages: (m: TranslationMessagesByKey, locale: string) => ParsedICUMessages<any>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { compile, watch } from './compile';
|
|
2
|
-
export { validate } from './validate';
|
|
3
|
-
export { resolveConfig, resolveConfigSync, validateConfig } from './config';
|
|
4
|
-
export { getAltLanguages, getAltLanguageFilePath, getDevLanguageFileFromTsFile, } from './utils';
|
|
5
|
-
export { getUniqueKey, loadAllTranslations, loadTranslation, } from './load-translations';
|
|
6
|
-
export type { TranslationFile } from '@vocab/types';
|
|
1
|
+
export { compile, watch } from './compile';
|
|
2
|
+
export { validate } from './validate';
|
|
3
|
+
export { resolveConfig, resolveConfigSync, validateConfig } from './config';
|
|
4
|
+
export { getAltLanguages, getAltLanguageFilePath, getDevLanguageFileFromTsFile, } from './utils';
|
|
5
|
+
export { getUniqueKey, loadAllTranslations, loadTranslation, } from './load-translations';
|
|
6
|
+
export type { TranslationFile } from '@vocab/types';
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import type { TranslationsByKey, UserConfig, LoadedTranslation, LanguageTarget } from '@vocab/types';
|
|
2
|
-
import { Fallback } from './utils';
|
|
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<string>;
|
|
8
|
-
export declare function getLanguageHierarchy({ languages, }: {
|
|
9
|
-
languages: Array<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<Array<LoadedTranslation>>;
|
|
1
|
+
import type { TranslationsByKey, UserConfig, LoadedTranslation, LanguageTarget } from '@vocab/types';
|
|
2
|
+
import { Fallback } from './utils';
|
|
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<string>;
|
|
8
|
+
export declare function getLanguageHierarchy({ languages, }: {
|
|
9
|
+
languages: Array<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<Array<LoadedTranslation>>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import debug from 'debug';
|
|
2
|
-
export declare const trace: debug.Debugger;
|
|
3
|
-
export declare const log: (...params: unknown[]) => void;
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
export declare const trace: debug.Debugger;
|
|
3
|
+
export declare const log: (...params: unknown[]) => void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { TranslationModule, TranslationMessagesByKey } from '@vocab/types';
|
|
2
|
-
export { createTranslationFile } from './translation-file';
|
|
3
|
-
export declare const createLanguage: (module: TranslationMessagesByKey) => TranslationModule<any>;
|
|
1
|
+
import { TranslationModule, TranslationMessagesByKey } from '@vocab/types';
|
|
2
|
+
export { createTranslationFile } from './translation-file';
|
|
3
|
+
export declare const createLanguage: (module: TranslationMessagesByKey) => TranslationModule<any>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TranslationModuleByLanguage, LanguageName, ParsedFormatFnByKey, TranslationFile } from '@vocab/types';
|
|
2
|
-
export declare function createTranslationFile<Language extends LanguageName, FormatFnByKey extends ParsedFormatFnByKey>(translationsByLanguage: TranslationModuleByLanguage<Language, FormatFnByKey>): TranslationFile<Language, FormatFnByKey>;
|
|
1
|
+
import { TranslationModuleByLanguage, LanguageName, ParsedFormatFnByKey, TranslationFile } from '@vocab/types';
|
|
2
|
+
export declare function createTranslationFile<Language extends LanguageName, FormatFnByKey extends ParsedFormatFnByKey>(translationsByLanguage: TranslationModuleByLanguage<Language, FormatFnByKey>): TranslationFile<Language, FormatFnByKey>;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import type { LanguageName, LanguageTarget, TranslationsByKey, TranslationMessagesByKey, UserConfig } from '@vocab/types';
|
|
2
|
-
export declare const defaultTranslationDirSuffix = ".vocab";
|
|
3
|
-
export declare const devTranslationFileName = "translations.json";
|
|
4
|
-
export
|
|
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: Array<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
|
+
import type { LanguageName, LanguageTarget, TranslationsByKey, TranslationMessagesByKey, UserConfig } from '@vocab/types';
|
|
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: Array<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 +1,3 @@
|
|
|
1
|
-
import { UserConfig, LoadedTranslation, LanguageName } from '@vocab/types';
|
|
2
|
-
export declare function findMissingKeys(loadedTranslation: LoadedTranslation, devLanguageName: LanguageName, altLanguages: Array<LanguageName>): readonly [boolean, Record<string, string[]>];
|
|
3
|
-
export declare function validate(config: UserConfig): Promise<boolean>;
|
|
1
|
+
import { UserConfig, LoadedTranslation, LanguageName } from '@vocab/types';
|
|
2
|
+
export declare function findMissingKeys(loadedTranslation: LoadedTranslation, devLanguageName: LanguageName, altLanguages: Array<LanguageName>): readonly [boolean, Record<string, string[]>];
|
|
3
|
+
export declare function validate(config: UserConfig): Promise<boolean>;
|