@itwin/core-i18n 3.5.0-dev.8 → 3.5.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/CHANGELOG.md CHANGED
@@ -1,6 +1,77 @@
1
1
  # Change Log - @itwin/core-i18n
2
2
 
3
- This log was last generated on Thu, 01 Sep 2022 14:37:22 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 15 Dec 2022 16:38:28 GMT and should not be manually modified.
4
+
5
+ ## 3.5.1
6
+ Thu, 15 Dec 2022 16:38:28 GMT
7
+
8
+ _Version update only_
9
+
10
+ ## 3.5.0
11
+ Wed, 07 Dec 2022 19:12:37 GMT
12
+
13
+ ### Updates
14
+
15
+ - add i18n tests
16
+
17
+ ## 3.4.7
18
+ Wed, 30 Nov 2022 14:28:19 GMT
19
+
20
+ _Version update only_
21
+
22
+ ## 3.4.6
23
+ Tue, 22 Nov 2022 14:24:19 GMT
24
+
25
+ _Version update only_
26
+
27
+ ## 3.4.5
28
+ Thu, 17 Nov 2022 21:32:50 GMT
29
+
30
+ _Version update only_
31
+
32
+ ## 3.4.4
33
+ Thu, 10 Nov 2022 19:32:17 GMT
34
+
35
+ _Version update only_
36
+
37
+ ## 3.4.3
38
+ Fri, 28 Oct 2022 13:34:58 GMT
39
+
40
+ _Version update only_
41
+
42
+ ## 3.4.2
43
+ Mon, 24 Oct 2022 13:23:45 GMT
44
+
45
+ _Version update only_
46
+
47
+ ## 3.4.1
48
+ Mon, 17 Oct 2022 20:06:51 GMT
49
+
50
+ _Version update only_
51
+
52
+ ## 3.4.0
53
+ Thu, 13 Oct 2022 20:24:47 GMT
54
+
55
+ ### Updates
56
+
57
+ - Add webpack:test to build:ci
58
+ - Replace deprecated i18next-xhr-backend with i18next-http-backend, and add some ITwinLocalization tests
59
+ - Updated Node types declaration to support latest v16
60
+
61
+ ## 3.3.5
62
+ Tue, 27 Sep 2022 11:50:59 GMT
63
+
64
+ _Version update only_
65
+
66
+ ## 3.3.4
67
+ Thu, 08 Sep 2022 19:00:05 GMT
68
+
69
+ _Version update only_
70
+
71
+ ## 3.3.3
72
+ Tue, 06 Sep 2022 20:54:19 GMT
73
+
74
+ _Version update only_
4
75
 
5
76
  ## 3.3.2
6
77
  Thu, 01 Sep 2022 14:37:22 GMT
@@ -1,99 +1,100 @@
1
- /** @packageDocumentation
2
- * @module Localization
3
- */
4
- import { i18n, InitOptions, Module, TOptionsBase } from "i18next";
5
- import { DetectorOptions } from "i18next-browser-languagedetector";
6
- import { BackendOptions } from "i18next-http-backend";
7
- import type { Localization } from "@itwin/core-common";
8
- /** Options for ITwinLocalization
9
- * @public
10
- */
11
- export interface LocalizationOptions {
12
- urlTemplate?: string;
13
- backendPlugin?: Module;
14
- detectorPlugin?: Module;
15
- initOptions?: InitOptions;
16
- backendHttpOptions?: BackendOptions;
17
- detectorOptions?: DetectorOptions;
18
- }
19
- /** Supplies localizations for iTwin.js
20
- * @note this class uses the [i18next](https://www.i18next.com/) package.
21
- * @public
22
- */
23
- export declare class ITwinLocalization implements Localization {
24
- i18next: i18n;
25
- private readonly _initOptions;
26
- private readonly _backendOptions;
27
- private readonly _detectionOptions;
28
- private readonly _namespaces;
29
- constructor(options?: LocalizationOptions);
30
- initialize(namespaces: string[]): Promise<void>;
31
- /** Replace all instances of `%{key}` within a string with the translations of those keys.
32
- * For example:
33
- * ``` ts
34
- * "MyKeys": {
35
- * "Key1": "First value",
36
- * "Key2": "Second value"
37
- * }
38
- * ```
39
- *
40
- * ``` ts
41
- * i18.translateKeys("string with %{MyKeys.Key1} followed by %{MyKeys.Key2}!"") // returns "string with First Value followed by Second Value!"
42
- * ```
43
- * @param line The input line, potentially containing %{keys}.
44
- * @returns The line with all %{keys} translated
45
- * @public
46
- */
47
- getLocalizedKeys(line: string): string;
48
- /** Return the translated value of a key.
49
- * @param key - the key that matches a property in the JSON localization file.
50
- * @note The key includes the namespace, which identifies the particular localization file that contains the property,
51
- * followed by a colon, followed by the property in the JSON file.
52
- * For example:
53
- * ``` ts
54
- * const dataString: string = IModelApp.localization.getLocalizedString("iModelJs:BackgroundMap.BingDataAttribution");
55
- * ```
56
- * assigns to dataString the string with property BackgroundMap.BingDataAttribution from the iModelJs.json localization file.
57
- * @returns The string corresponding to the first key that resolves.
58
- * @throws Error if no keys resolve to a string.
59
- * @public
60
- */
61
- getLocalizedString(key: string | string[], options?: TOptionsBase): string;
62
- /** Similar to `getLocalizedString` but the namespace is a separate param and the key does not include the namespace.
63
- * @param namespace - the namespace that identifies the particular localization file that contains the property.
64
- * @param key - the key that matches a property in the JSON localization file.
65
- * @returns The string corresponding to the first key that resolves.
66
- * @throws Error if no keys resolve to a string.
67
- * @internal
68
- */
69
- getLocalizedStringWithNamespace(namespace: string, key: string | string[], options?: TOptionsBase): string;
70
- /** Gets the English translation.
71
- * @param namespace - the namespace that identifies the particular localization file that contains the property.
72
- * @param key - the key that matches a property in the JSON localization file.
73
- * @returns The string corresponding to the first key that resolves.
74
- * @throws Error if no keys resolve to a string.
75
- * @internal
76
- */
77
- getEnglishString(namespace: string, key: string | string[], options?: TOptionsBase): string;
78
- /** Get the promise for an already registered Namespace.
79
- * @param name - the name of the namespace
80
- * @public
81
- */
82
- getNamespacePromise(name: string): Promise<void> | undefined;
83
- /** @internal */
84
- getLanguageList(): readonly string[];
85
- /** override the language detected in the browser */
86
- changeLanguage(language: string): Promise<void>;
87
- /** Register a new Namespace and return it. If the namespace is already registered, it will be returned.
88
- * @param name - the name of the namespace, which is the base name of the JSON file that contains the localization properties.
89
- * @note - The registerNamespace method starts fetching the appropriate version of the JSON localization file from the server,
90
- * based on the current locale. To make sure that fetch is complete before performing translations from this namespace, await
91
- * fulfillment of the readPromise Promise property of the returned LocalizationNamespace.
92
- * @see [Localization in iTwin.js]($docs/learning/frontend/Localization.md)
93
- * @public
94
- */
95
- registerNamespace(name: string): Promise<void>;
96
- /** @internal */
97
- unregisterNamespace(name: string): void;
98
- }
1
+ /** @packageDocumentation
2
+ * @module Localization
3
+ */
4
+ import { i18n, InitOptions, Module, TOptionsBase } from "i18next";
5
+ import { DetectorOptions } from "i18next-browser-languagedetector";
6
+ import { BackendOptions } from "i18next-http-backend";
7
+ import type { Localization } from "@itwin/core-common";
8
+ /** Options for ITwinLocalization
9
+ * @public
10
+ */
11
+ export interface LocalizationOptions {
12
+ urlTemplate?: string;
13
+ backendPlugin?: Module;
14
+ detectorPlugin?: Module;
15
+ initOptions?: InitOptions;
16
+ backendHttpOptions?: BackendOptions;
17
+ detectorOptions?: DetectorOptions;
18
+ }
19
+ /** Supplies localizations for iTwin.js
20
+ * @note this class uses the [i18next](https://www.i18next.com/) package.
21
+ * @public
22
+ */
23
+ export declare class ITwinLocalization implements Localization {
24
+ i18next: i18n;
25
+ private readonly _initOptions;
26
+ private readonly _backendOptions;
27
+ private readonly _detectionOptions;
28
+ private readonly _namespaces;
29
+ constructor(options?: LocalizationOptions);
30
+ initialize(namespaces: string[]): Promise<void>;
31
+ /** Replace all instances of `%{key}` within a string with the translations of those keys.
32
+ * For example:
33
+ * ``` ts
34
+ * "MyKeys": {
35
+ * "Key1": "First value",
36
+ * "Key2": "Second value"
37
+ * }
38
+ * ```
39
+ *
40
+ * ``` ts
41
+ * i18.translateKeys("string with %{MyKeys.Key1} followed by %{MyKeys.Key2}!"") // returns "string with First Value followed by Second Value!"
42
+ * ```
43
+ * @param line The input line, potentially containing %{keys}.
44
+ * @returns The line with all %{keys} translated
45
+ * @public
46
+ */
47
+ getLocalizedKeys(line: string): string;
48
+ /** Return the translated value of a key.
49
+ * @param key - the key that matches a property in the JSON localization file.
50
+ * @note The key includes the namespace, which identifies the particular localization file that contains the property,
51
+ * followed by a colon, followed by the property in the JSON file.
52
+ * For example:
53
+ * ``` ts
54
+ * const dataString: string = IModelApp.localization.getLocalizedString("iModelJs:BackgroundMap.BingDataAttribution");
55
+ * ```
56
+ * assigns to dataString the string with property BackgroundMap.BingDataAttribution from the iModelJs.json localization file.
57
+ * @returns The string corresponding to the first key that resolves.
58
+ * @throws Error if no keys resolve to a string.
59
+ * @public
60
+ */
61
+ getLocalizedString(key: string | string[], options?: TOptionsBase): string;
62
+ /** Similar to `getLocalizedString` but the default namespace is a separate parameter and the key does not need
63
+ * to include a namespace. If a key includes a namespace, that namespace will be used for interpolating that key.
64
+ * @param namespace - the namespace that identifies the particular localization file that contains the property.
65
+ * @param key - the key that matches a property in the JSON localization file.
66
+ * @returns The string corresponding to the first key that resolves.
67
+ * @throws Error if no keys resolve to a string.
68
+ * @internal
69
+ */
70
+ getLocalizedStringWithNamespace(namespace: string, key: string | string[], options?: TOptionsBase): string;
71
+ /** Gets the English translation.
72
+ * @param namespace - the namespace that identifies the particular localization file that contains the property.
73
+ * @param key - the key that matches a property in the JSON localization file.
74
+ * @returns The string corresponding to the first key that resolves.
75
+ * @throws Error if no keys resolve to a string.
76
+ * @internal
77
+ */
78
+ getEnglishString(namespace: string, key: string | string[], options?: TOptionsBase): string;
79
+ /** Get the promise for an already registered Namespace.
80
+ * @param name - the name of the namespace
81
+ * @public
82
+ */
83
+ getNamespacePromise(name: string): Promise<void> | undefined;
84
+ /** @internal */
85
+ getLanguageList(): readonly string[];
86
+ /** override the language detected in the browser */
87
+ changeLanguage(language: string): Promise<void>;
88
+ /** Register a new Namespace and return it. If the namespace is already registered, it will be returned.
89
+ * @param name - the name of the namespace, which is the base name of the JSON file that contains the localization properties.
90
+ * @note - The registerNamespace method starts fetching the appropriate version of the JSON localization file from the server,
91
+ * based on the current locale. To make sure that fetch is complete before performing translations from this namespace, await
92
+ * fulfillment of the readPromise Promise property of the returned LocalizationNamespace.
93
+ * @see [Localization in iTwin.js]($docs/learning/frontend/Localization.md)
94
+ * @public
95
+ */
96
+ registerNamespace(name: string): Promise<void>;
97
+ /** @internal */
98
+ unregisterNamespace(name: string): void;
99
+ }
99
100
  //# sourceMappingURL=ITwinLocalization.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ITwinLocalization.d.ts","sourceRoot":"","sources":["../../src/ITwinLocalization.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