@spinajs/intl 2.0.179 → 2.0.181
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/lib/cjs/config/locales.d.ts +12 -12
- package/lib/cjs/config/locales.js +16 -16
- package/lib/cjs/index.browser.d.ts +1 -1
- package/lib/cjs/index.browser.js +17 -17
- package/lib/cjs/index.d.ts +115 -115
- package/lib/cjs/index.js +333 -333
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/index.node.d.ts +2 -2
- package/lib/cjs/index.node.js +18 -18
- package/lib/cjs/interfaces.d.ts +7 -7
- package/lib/cjs/interfaces.js +26 -26
- package/lib/cjs/interfaces.js.map +1 -1
- package/lib/cjs/sources.d.ts +7 -7
- package/lib/cjs/sources.js +110 -110
- package/lib/cjs/sources.js.map +1 -1
- package/lib/mjs/config/locales.d.ts +12 -12
- package/lib/mjs/config/locales.js +14 -14
- package/lib/mjs/index.browser.d.ts +1 -1
- package/lib/mjs/index.browser.js +1 -1
- package/lib/mjs/index.d.ts +115 -115
- package/lib/mjs/index.js +294 -294
- package/lib/mjs/index.js.map +1 -1
- package/lib/mjs/index.node.d.ts +2 -2
- package/lib/mjs/index.node.js +2 -2
- package/lib/mjs/interfaces.d.ts +7 -7
- package/lib/mjs/interfaces.js +22 -22
- package/lib/mjs/interfaces.js.map +1 -1
- package/lib/mjs/sources.d.ts +7 -7
- package/lib/mjs/sources.js +81 -81
- package/lib/mjs/sources.js.map +1 -1
- package/lib/tsconfig.cjs.tsbuildinfo +1 -1
- package/lib/tsconfig.mjs.tsbuildinfo +1 -1
- package/package.json +5 -5
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Localisation configuration, structure like in
|
|
3
|
-
* https://github.com/mashpie/i18n-node
|
|
4
|
-
*/
|
|
5
|
-
declare const config: {
|
|
6
|
-
intl: {
|
|
7
|
-
defaultLocale: string;
|
|
8
|
-
locales: string[];
|
|
9
|
-
queryParameter: string;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
export default config;
|
|
1
|
+
/**
|
|
2
|
+
* Localisation configuration, structure like in
|
|
3
|
+
* https://github.com/mashpie/i18n-node
|
|
4
|
+
*/
|
|
5
|
+
declare const config: {
|
|
6
|
+
intl: {
|
|
7
|
+
defaultLocale: string;
|
|
8
|
+
locales: string[];
|
|
9
|
+
queryParameter: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export default config;
|
|
13
13
|
//# sourceMappingURL=locales.d.ts.map
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Localisation configuration, structure like in
|
|
5
|
-
* https://github.com/mashpie/i18n-node
|
|
6
|
-
*/
|
|
7
|
-
const config = {
|
|
8
|
-
intl: {
|
|
9
|
-
defaultLocale: 'en',
|
|
10
|
-
// supported locales
|
|
11
|
-
locales: ['en'],
|
|
12
|
-
// query parameter to switch locale (ie. /home?lang=ch) - defaults to NULL
|
|
13
|
-
queryParameter: 'lang',
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
exports.default = config;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Localisation configuration, structure like in
|
|
5
|
+
* https://github.com/mashpie/i18n-node
|
|
6
|
+
*/
|
|
7
|
+
const config = {
|
|
8
|
+
intl: {
|
|
9
|
+
defaultLocale: 'en',
|
|
10
|
+
// supported locales
|
|
11
|
+
locales: ['en'],
|
|
12
|
+
// query parameter to switch locale (ie. /home?lang=ch) - defaults to NULL
|
|
13
|
+
queryParameter: 'lang',
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
exports.default = config;
|
|
17
17
|
//# sourceMappingURL=locales.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./index.js";
|
|
1
|
+
export * from "./index.js";
|
|
2
2
|
//# sourceMappingURL=index.browser.d.ts.map
|
package/lib/cjs/index.browser.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./index.js"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./index.js"), exports);
|
|
18
18
|
//# sourceMappingURL=index.browser.js.map
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -1,116 +1,116 @@
|
|
|
1
|
-
import { AsyncService } from '@spinajs/di';
|
|
2
|
-
import { Configuration } from '@spinajs/configuration-common';
|
|
3
|
-
import { Log } from '@spinajs/log-common';
|
|
4
|
-
export * from "./interfaces.js";
|
|
5
|
-
export interface IPhraseWithOptions {
|
|
6
|
-
phrase: string;
|
|
7
|
-
locale: string;
|
|
8
|
-
}
|
|
9
|
-
export interface IIntlAsyncStorage {
|
|
10
|
-
language?: string;
|
|
11
|
-
/**
|
|
12
|
-
* Even if we have detected language, sometimes we dont want to translate
|
|
13
|
-
*/
|
|
14
|
-
noTranslate?: boolean;
|
|
15
|
-
}
|
|
16
|
-
export declare abstract class Intl extends AsyncService {
|
|
17
|
-
private _currentLocale;
|
|
18
|
-
/**
|
|
19
|
-
* Currently selected locale
|
|
20
|
-
*/
|
|
21
|
-
get CurrentLocale(): string;
|
|
22
|
-
/**
|
|
23
|
-
* Currently selected locale
|
|
24
|
-
*/
|
|
25
|
-
set CurrentLocale(value: string);
|
|
26
|
-
/**
|
|
27
|
-
* Map with avaible translations, keyed by locale name
|
|
28
|
-
*/
|
|
29
|
-
Locales: {};
|
|
30
|
-
/**
|
|
31
|
-
* I18n localization function. Returns localized string.
|
|
32
|
-
* If no translation is avaible at current selected language, then fallback to
|
|
33
|
-
* default language, if still no translation exists, original text is returned
|
|
34
|
-
*
|
|
35
|
-
* @param text - text to localize.
|
|
36
|
-
* @param args - argument passed to formatted text
|
|
37
|
-
*/
|
|
38
|
-
abstract __(text: string | IPhraseWithOptions, ...args: any[]): string;
|
|
39
|
-
/**
|
|
40
|
-
* Plurals translation of a single phrase. Singular and plural forms will get added to locales if unknown.
|
|
41
|
-
* Returns translated parsed and substituted string based on last count parameter.
|
|
42
|
-
*
|
|
43
|
-
* @param text - text to localize
|
|
44
|
-
* @param count - number of items/things
|
|
45
|
-
* @example use like `__n("%s cats", 1) returns `1 cat`
|
|
46
|
-
*/
|
|
47
|
-
abstract __n(text: string | IPhraseWithOptions, count: number): string;
|
|
48
|
-
/**
|
|
49
|
-
* Returns a list of translations for a given phrase in each language.
|
|
50
|
-
*
|
|
51
|
-
* @param text - text to translate
|
|
52
|
-
*/
|
|
53
|
-
abstract __l(text: string): string[];
|
|
54
|
-
/**
|
|
55
|
-
* Returns a hashed list of translations for a given phrase in each language.
|
|
56
|
-
*
|
|
57
|
-
* @param text - text to translate
|
|
58
|
-
*/
|
|
59
|
-
abstract __h(text: string): any[];
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Basic internationalization support. Text phrases are read from json files specified
|
|
63
|
-
* in system.dirs.locales
|
|
64
|
-
*/
|
|
65
|
-
export declare class SpineJsInternationalizationFromJson extends Intl {
|
|
66
|
-
/**
|
|
67
|
-
* Map with avaible translations, keyed by locale name
|
|
68
|
-
*/
|
|
69
|
-
Locales: {};
|
|
70
|
-
/**
|
|
71
|
-
* Logger for this module
|
|
72
|
-
*/
|
|
73
|
-
protected Log: Log;
|
|
74
|
-
protected Configuration: Configuration;
|
|
75
|
-
resolve(): Promise<void>;
|
|
76
|
-
/**
|
|
77
|
-
* I18n localization function. Returns localized string.
|
|
78
|
-
* If no translation is avaible at current selected language, then fallback to
|
|
79
|
-
* default language, if still no translation exists, original text is returned
|
|
80
|
-
*
|
|
81
|
-
* @param text - text to localize.
|
|
82
|
-
* @param args - argument passed to formatted text
|
|
83
|
-
*/
|
|
84
|
-
__(text: string | IPhraseWithOptions, ...args: any[]): string;
|
|
85
|
-
/**
|
|
86
|
-
* Plurals translation of a single phrase.
|
|
87
|
-
* Returns translated, parsed and substituted string based on count parameter.
|
|
88
|
-
*
|
|
89
|
-
* @param text - text to localize
|
|
90
|
-
* @param count - number of items/things
|
|
91
|
-
* @example use like `__n("%s cats", 1) returns '1 cat'`
|
|
92
|
-
*/
|
|
93
|
-
__n(text: string | IPhraseWithOptions, count: number): string;
|
|
94
|
-
/**
|
|
95
|
-
* Returns a list of translations for a given phrase in each language.
|
|
96
|
-
*
|
|
97
|
-
* @param text - text to translate
|
|
98
|
-
*/
|
|
99
|
-
__l(text: string): string[];
|
|
100
|
-
/**
|
|
101
|
-
* Returns a hashed list of translations for a given phrase in each language.
|
|
102
|
-
*
|
|
103
|
-
* @param text - text to translate
|
|
104
|
-
*/
|
|
105
|
-
__h(text: string): any[];
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Helper function for translations ( eg. for use as in template rentering engines)
|
|
109
|
-
*/
|
|
110
|
-
export declare function __translate(lang: string): (text: string | IPhraseWithOptions, ...args: any[]) => string;
|
|
111
|
-
export declare function __translateNumber(lang: string): (text: string | IPhraseWithOptions, count: number) => string;
|
|
112
|
-
export declare function __translateL(text: string): string[];
|
|
113
|
-
export declare function __translateH(text: string): any[];
|
|
114
|
-
export declare function guessLanguage(lang?: string): string;
|
|
115
|
-
export declare function defaultLanguage(): string;
|
|
1
|
+
import { AsyncService } from '@spinajs/di';
|
|
2
|
+
import { Configuration } from '@spinajs/configuration-common';
|
|
3
|
+
import { Log } from '@spinajs/log-common';
|
|
4
|
+
export * from "./interfaces.js";
|
|
5
|
+
export interface IPhraseWithOptions {
|
|
6
|
+
phrase: string;
|
|
7
|
+
locale: string;
|
|
8
|
+
}
|
|
9
|
+
export interface IIntlAsyncStorage {
|
|
10
|
+
language?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Even if we have detected language, sometimes we dont want to translate
|
|
13
|
+
*/
|
|
14
|
+
noTranslate?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare abstract class Intl extends AsyncService {
|
|
17
|
+
private _currentLocale;
|
|
18
|
+
/**
|
|
19
|
+
* Currently selected locale
|
|
20
|
+
*/
|
|
21
|
+
get CurrentLocale(): string;
|
|
22
|
+
/**
|
|
23
|
+
* Currently selected locale
|
|
24
|
+
*/
|
|
25
|
+
set CurrentLocale(value: string);
|
|
26
|
+
/**
|
|
27
|
+
* Map with avaible translations, keyed by locale name
|
|
28
|
+
*/
|
|
29
|
+
Locales: {};
|
|
30
|
+
/**
|
|
31
|
+
* I18n localization function. Returns localized string.
|
|
32
|
+
* If no translation is avaible at current selected language, then fallback to
|
|
33
|
+
* default language, if still no translation exists, original text is returned
|
|
34
|
+
*
|
|
35
|
+
* @param text - text to localize.
|
|
36
|
+
* @param args - argument passed to formatted text
|
|
37
|
+
*/
|
|
38
|
+
abstract __(text: string | IPhraseWithOptions, ...args: any[]): string;
|
|
39
|
+
/**
|
|
40
|
+
* Plurals translation of a single phrase. Singular and plural forms will get added to locales if unknown.
|
|
41
|
+
* Returns translated parsed and substituted string based on last count parameter.
|
|
42
|
+
*
|
|
43
|
+
* @param text - text to localize
|
|
44
|
+
* @param count - number of items/things
|
|
45
|
+
* @example use like `__n("%s cats", 1) returns `1 cat`
|
|
46
|
+
*/
|
|
47
|
+
abstract __n(text: string | IPhraseWithOptions, count: number): string;
|
|
48
|
+
/**
|
|
49
|
+
* Returns a list of translations for a given phrase in each language.
|
|
50
|
+
*
|
|
51
|
+
* @param text - text to translate
|
|
52
|
+
*/
|
|
53
|
+
abstract __l(text: string): string[];
|
|
54
|
+
/**
|
|
55
|
+
* Returns a hashed list of translations for a given phrase in each language.
|
|
56
|
+
*
|
|
57
|
+
* @param text - text to translate
|
|
58
|
+
*/
|
|
59
|
+
abstract __h(text: string): any[];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Basic internationalization support. Text phrases are read from json files specified
|
|
63
|
+
* in system.dirs.locales
|
|
64
|
+
*/
|
|
65
|
+
export declare class SpineJsInternationalizationFromJson extends Intl {
|
|
66
|
+
/**
|
|
67
|
+
* Map with avaible translations, keyed by locale name
|
|
68
|
+
*/
|
|
69
|
+
Locales: {};
|
|
70
|
+
/**
|
|
71
|
+
* Logger for this module
|
|
72
|
+
*/
|
|
73
|
+
protected Log: Log;
|
|
74
|
+
protected Configuration: Configuration;
|
|
75
|
+
resolve(): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* I18n localization function. Returns localized string.
|
|
78
|
+
* If no translation is avaible at current selected language, then fallback to
|
|
79
|
+
* default language, if still no translation exists, original text is returned
|
|
80
|
+
*
|
|
81
|
+
* @param text - text to localize.
|
|
82
|
+
* @param args - argument passed to formatted text
|
|
83
|
+
*/
|
|
84
|
+
__(text: string | IPhraseWithOptions, ...args: any[]): string;
|
|
85
|
+
/**
|
|
86
|
+
* Plurals translation of a single phrase.
|
|
87
|
+
* Returns translated, parsed and substituted string based on count parameter.
|
|
88
|
+
*
|
|
89
|
+
* @param text - text to localize
|
|
90
|
+
* @param count - number of items/things
|
|
91
|
+
* @example use like `__n("%s cats", 1) returns '1 cat'`
|
|
92
|
+
*/
|
|
93
|
+
__n(text: string | IPhraseWithOptions, count: number): string;
|
|
94
|
+
/**
|
|
95
|
+
* Returns a list of translations for a given phrase in each language.
|
|
96
|
+
*
|
|
97
|
+
* @param text - text to translate
|
|
98
|
+
*/
|
|
99
|
+
__l(text: string): string[];
|
|
100
|
+
/**
|
|
101
|
+
* Returns a hashed list of translations for a given phrase in each language.
|
|
102
|
+
*
|
|
103
|
+
* @param text - text to translate
|
|
104
|
+
*/
|
|
105
|
+
__h(text: string): any[];
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Helper function for translations ( eg. for use as in template rentering engines)
|
|
109
|
+
*/
|
|
110
|
+
export declare function __translate(lang: string): (text: string | IPhraseWithOptions, ...args: any[]) => string;
|
|
111
|
+
export declare function __translateNumber(lang: string): (text: string | IPhraseWithOptions, count: number) => string;
|
|
112
|
+
export declare function __translateL(text: string): string[];
|
|
113
|
+
export declare function __translateH(text: string): any[];
|
|
114
|
+
export declare function guessLanguage(lang?: string): string;
|
|
115
|
+
export declare function defaultLanguage(): string;
|
|
116
116
|
//# sourceMappingURL=index.d.ts.map
|