@tolgee/core 5.8.4-prerelease.f5f66c17.0 → 5.8.5
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/tolgee.cjs.js +6 -10
- package/dist/tolgee.cjs.js.map +1 -1
- package/dist/tolgee.cjs.min.js +1 -1
- package/dist/tolgee.cjs.min.js.map +1 -1
- package/dist/tolgee.esm.js +6 -10
- package/dist/tolgee.esm.js.map +1 -1
- package/dist/tolgee.esm.min.js +1 -1
- package/dist/tolgee.esm.min.js.map +1 -1
- package/dist/tolgee.esm.min.mjs +1 -1
- package/dist/tolgee.esm.min.mjs.map +1 -1
- package/dist/tolgee.esm.mjs +6 -10
- package/dist/tolgee.esm.mjs.map +1 -1
- package/dist/tolgee.umd.js +6 -10
- package/dist/tolgee.umd.js.map +1 -1
- package/dist/tolgee.umd.min.js +1 -1
- package/dist/tolgee.umd.min.js.map +1 -1
- package/lib/helpers.d.ts +1 -1
- package/package.json +2 -2
- package/src/Controller/Controller.ts +1 -8
- package/src/helpers.ts +10 -2
package/lib/helpers.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FallbackGeneral, FallbackLanguageOption } from './types';
|
|
2
2
|
export declare function isPromise(value: any): boolean;
|
|
3
3
|
export declare function valueOrPromise<T, R>(value: T | Promise<T>, callback: (value: T) => R): R | Promise<R>;
|
|
4
|
-
export declare function missingOptionError(option: string): string;
|
|
4
|
+
export declare function missingOptionError(option: string | string[]): string;
|
|
5
5
|
export declare function isObject(item: any): boolean;
|
|
6
6
|
export declare function getFallback(value: FallbackGeneral): string[] | undefined;
|
|
7
7
|
export declare function getFallbackArray(value: FallbackGeneral): string[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tolgee/core",
|
|
3
|
-
"version": "5.8.
|
|
3
|
+
"version": "5.8.5",
|
|
4
4
|
"description": "Library providing ability to translate messages directly in context of developed application.",
|
|
5
5
|
"main": "./dist/tolgee.cjs.js",
|
|
6
6
|
"module": "./dist/tolgee.esm.js",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"access": "public"
|
|
69
69
|
},
|
|
70
70
|
"sideEffects": false,
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "8f1a59fe553947f4df4340286ab2994bce74db12"
|
|
72
72
|
}
|
|
@@ -169,9 +169,6 @@ export function Controller({ options }: StateServiceProps) {
|
|
|
169
169
|
if (existingLanguage) {
|
|
170
170
|
return;
|
|
171
171
|
}
|
|
172
|
-
if (!state.getInitialOptions().defaultLanguage) {
|
|
173
|
-
throw new Error(missingOptionError('defaultLanguage'));
|
|
174
|
-
}
|
|
175
172
|
const languageOrPromise = pluginService.getInitialLanguage();
|
|
176
173
|
return valueOrPromise(languageOrPromise, (lang) => {
|
|
177
174
|
const language =
|
|
@@ -191,11 +188,7 @@ export function Controller({ options }: StateServiceProps) {
|
|
|
191
188
|
}
|
|
192
189
|
}
|
|
193
190
|
if (!state.getLanguage() && !state.getInitialOptions().defaultLanguage) {
|
|
194
|
-
|
|
195
|
-
throw new Error(missingOptionError('defaultLanguage'));
|
|
196
|
-
} else {
|
|
197
|
-
throw new Error(missingOptionError('language'));
|
|
198
|
-
}
|
|
191
|
+
throw new Error(missingOptionError(['defaultLanguage', 'language']));
|
|
199
192
|
}
|
|
200
193
|
}
|
|
201
194
|
|
package/src/helpers.ts
CHANGED
|
@@ -19,8 +19,16 @@ export function valueOrPromise<T, R>(
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export function missingOptionError(option: string) {
|
|
23
|
-
|
|
22
|
+
export function missingOptionError(option: string | string[]) {
|
|
23
|
+
const options = (Array.isArray(option) ? option : [option]).map(
|
|
24
|
+
(val) => `'${val}'`
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const lastPart = options.slice(-2).join(' or ');
|
|
28
|
+
const firstPart = options.slice(0, -2);
|
|
29
|
+
const stringifiedOptions = [...firstPart, lastPart].join(', ');
|
|
30
|
+
|
|
31
|
+
return `Tolgee: You need to specify ${stringifiedOptions} option`;
|
|
24
32
|
}
|
|
25
33
|
|
|
26
34
|
export function isObject(item: any) {
|