@ckeditor/ckeditor5-utils 40.0.0 → 40.2.0
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 +26 -26
- package/LICENSE.md +3 -3
- package/package.json +1 -1
- package/src/abortabledebounce.d.ts +17 -0
- package/src/abortabledebounce.js +22 -0
- package/src/areconnectedthroughproperties.d.ts +11 -11
- package/src/areconnectedthroughproperties.js +73 -73
- package/src/ckeditorerror.d.ts +123 -123
- package/src/ckeditorerror.js +176 -176
- package/src/collection.d.ts +433 -427
- package/src/collection.js +583 -575
- package/src/comparearrays.d.ts +30 -30
- package/src/comparearrays.js +47 -47
- package/src/config.d.ts +163 -163
- package/src/config.js +163 -162
- package/src/count.d.ts +18 -18
- package/src/count.js +24 -24
- package/src/delay.d.ts +19 -19
- package/src/delay.js +26 -26
- package/src/diff.d.ts +31 -31
- package/src/diff.js +115 -115
- package/src/difftochanges.d.ts +59 -59
- package/src/difftochanges.js +79 -79
- package/src/dom/createelement.d.ts +57 -57
- package/src/dom/createelement.js +40 -40
- package/src/dom/emittermixin.d.ts +142 -142
- package/src/dom/emittermixin.js +239 -239
- package/src/dom/findclosestscrollableancestor.d.ts +11 -11
- package/src/dom/findclosestscrollableancestor.js +31 -31
- package/src/dom/getancestors.d.ts +17 -17
- package/src/dom/getancestors.js +27 -27
- package/src/dom/getborderwidths.d.ts +24 -24
- package/src/dom/getborderwidths.js +24 -24
- package/src/dom/getcommonancestor.d.ts +12 -12
- package/src/dom/getcommonancestor.js +25 -25
- package/src/dom/getdatafromelement.d.ts +14 -14
- package/src/dom/getdatafromelement.js +20 -20
- package/src/dom/getpositionedancestor.d.ts +10 -10
- package/src/dom/getpositionedancestor.js +22 -22
- package/src/dom/global.d.ts +32 -32
- package/src/dom/global.js +35 -35
- package/src/dom/indexof.d.ts +14 -14
- package/src/dom/indexof.js +21 -21
- package/src/dom/insertat.d.ts +15 -15
- package/src/dom/insertat.js +17 -17
- package/src/dom/iscomment.d.ts +11 -11
- package/src/dom/iscomment.js +14 -14
- package/src/dom/isnode.d.ts +11 -11
- package/src/dom/isnode.js +21 -21
- package/src/dom/isrange.d.ts +11 -11
- package/src/dom/isrange.js +13 -13
- package/src/dom/istext.d.ts +11 -11
- package/src/dom/istext.js +13 -13
- package/src/dom/isvalidattributename.d.ts +10 -10
- package/src/dom/isvalidattributename.js +22 -22
- package/src/dom/isvisible.d.ts +18 -18
- package/src/dom/isvisible.js +20 -20
- package/src/dom/iswindow.d.ts +11 -11
- package/src/dom/iswindow.js +22 -22
- package/src/dom/position.d.ts +211 -211
- package/src/dom/position.js +313 -313
- package/src/dom/rect.d.ts +195 -195
- package/src/dom/rect.js +474 -474
- package/src/dom/remove.d.ts +13 -13
- package/src/dom/remove.js +18 -18
- package/src/dom/resizeobserver.d.ts +74 -74
- package/src/dom/resizeobserver.js +126 -126
- package/src/dom/scroll.d.ts +73 -73
- package/src/dom/scroll.js +383 -383
- package/src/dom/setdatainelement.d.ts +14 -14
- package/src/dom/setdatainelement.js +20 -20
- package/src/dom/tounit.d.ts +22 -22
- package/src/dom/tounit.js +16 -16
- package/src/elementreplacer.d.ts +31 -31
- package/src/elementreplacer.js +43 -43
- package/src/emittermixin.d.ts +312 -312
- package/src/emittermixin.js +453 -453
- package/src/env.d.ts +117 -117
- package/src/env.js +122 -122
- package/src/eventinfo.d.ts +58 -58
- package/src/eventinfo.js +26 -26
- package/src/fastdiff.d.ts +112 -112
- package/src/fastdiff.js +248 -248
- package/src/first.d.ts +11 -11
- package/src/first.js +17 -17
- package/src/focustracker.d.ts +75 -75
- package/src/focustracker.js +95 -95
- package/src/index.d.ts +64 -61
- package/src/index.js +63 -60
- package/src/inserttopriorityarray.d.ts +30 -30
- package/src/inserttopriorityarray.js +21 -21
- package/src/isiterable.d.ts +14 -14
- package/src/isiterable.js +16 -16
- package/src/keyboard.d.ts +126 -126
- package/src/keyboard.js +221 -221
- package/src/keystrokehandler.d.ts +87 -87
- package/src/keystrokehandler.js +122 -122
- package/src/language.d.ts +17 -17
- package/src/language.js +19 -19
- package/src/locale.d.ts +120 -120
- package/src/locale.js +76 -76
- package/src/mapsequal.d.ts +15 -15
- package/src/mapsequal.js +27 -27
- package/src/mix.d.ts +85 -85
- package/src/mix.js +50 -50
- package/src/nth.d.ts +16 -16
- package/src/nth.js +24 -24
- package/src/objecttomap.d.ts +23 -23
- package/src/objecttomap.js +27 -27
- package/src/observablemixin.d.ts +560 -560
- package/src/observablemixin.js +580 -580
- package/src/priorities.d.ts +33 -33
- package/src/priorities.js +23 -23
- package/src/retry.d.ts +33 -0
- package/src/retry.js +47 -0
- package/src/splicearray.d.ts +26 -26
- package/src/splicearray.js +40 -40
- package/src/spy.d.ts +21 -21
- package/src/spy.js +22 -22
- package/src/toarray.d.ts +25 -25
- package/src/toarray.js +7 -7
- package/src/tomap.d.ts +19 -19
- package/src/tomap.js +29 -29
- package/src/translation-service.d.ts +168 -168
- package/src/translation-service.js +198 -198
- package/src/uid.d.ts +15 -15
- package/src/uid.js +57 -57
- package/src/unicode.d.ts +54 -54
- package/src/unicode.js +85 -85
- package/src/verifylicense.d.ts +15 -15
- package/src/verifylicense.js +87 -87
- package/src/version.d.ts +10 -10
- package/src/version.js +153 -153
- package/src/wait.d.ts +16 -0
- package/src/wait.js +29 -0
|
@@ -1,168 +1,168 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
declare global {
|
|
6
|
-
var CKEDITOR_TRANSLATIONS: {
|
|
7
|
-
[language: string]: {
|
|
8
|
-
dictionary: {
|
|
9
|
-
[messageId: string]: string | ReadonlyArray<string>;
|
|
10
|
-
};
|
|
11
|
-
getPluralForm?: (n: number) => number;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Adds translations to existing ones or overrides the existing translations. These translations will later
|
|
17
|
-
* be available for the {@link module:utils/locale~Locale#t `t()`} function.
|
|
18
|
-
*
|
|
19
|
-
* The `translations` is an object which consists of `messageId: translation` pairs. Note that the message ID can be
|
|
20
|
-
* either constructed from the message string or from the message ID if it was passed
|
|
21
|
-
* (this happens rarely and mostly for short messages or messages with placeholders).
|
|
22
|
-
* Since the editor displays only the message string, the message ID can be found either in the source code or in the
|
|
23
|
-
* built translations for another language.
|
|
24
|
-
*
|
|
25
|
-
* ```ts
|
|
26
|
-
* add( 'pl', {
|
|
27
|
-
* 'Cancel': 'Anuluj',
|
|
28
|
-
* 'IMAGE': 'obraz', // Note that the `IMAGE` comes from the message ID, while the string can be `image`.
|
|
29
|
-
* } );
|
|
30
|
-
* ```
|
|
31
|
-
*
|
|
32
|
-
* If the message is supposed to support various plural forms, make sure to provide an array with the singular form and all plural forms:
|
|
33
|
-
*
|
|
34
|
-
* ```ts
|
|
35
|
-
* add( 'pl', {
|
|
36
|
-
* 'Add space': [ 'Dodaj spację', 'Dodaj %0 spacje', 'Dodaj %0 spacji' ]
|
|
37
|
-
* } );
|
|
38
|
-
* ```
|
|
39
|
-
*
|
|
40
|
-
* You should also specify the third argument (the `getPluralForm()` function) that will be used to determine the plural form if no
|
|
41
|
-
* language file was loaded for that language. All language files coming from CKEditor 5 sources will have this option set, so
|
|
42
|
-
* these plural form rules will be reused by other translations added to the registered languages. The `getPluralForm()` function
|
|
43
|
-
* can return either a Boolean or a number.
|
|
44
|
-
*
|
|
45
|
-
* ```ts
|
|
46
|
-
* add( 'en', {
|
|
47
|
-
* // ... Translations.
|
|
48
|
-
* }, n => n !== 1 );
|
|
49
|
-
* add( 'pl', {
|
|
50
|
-
* // ... Translations.
|
|
51
|
-
* }, n => n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && ( n % 100 < 10 || n % 100 >= 20 ) ? 1 : 2 );
|
|
52
|
-
* ```
|
|
53
|
-
*
|
|
54
|
-
* All translations extend the global `window.CKEDITOR_TRANSLATIONS` object. An example of this object can be found below:
|
|
55
|
-
*
|
|
56
|
-
* ```ts
|
|
57
|
-
* {
|
|
58
|
-
* pl: {
|
|
59
|
-
* dictionary: {
|
|
60
|
-
* 'Cancel': 'Anuluj',
|
|
61
|
-
* 'Add space': [ 'Dodaj spację', 'Dodaj %0 spacje', 'Dodaj %0 spacji' ]
|
|
62
|
-
* },
|
|
63
|
-
* // A function that returns the plural form index.
|
|
64
|
-
* getPluralForm: n => n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && ( n % 100 < 10 || n % 100 >= 20 ) ? 1 : 2 );
|
|
65
|
-
* }
|
|
66
|
-
* // Other languages.
|
|
67
|
-
* }
|
|
68
|
-
* ```
|
|
69
|
-
*
|
|
70
|
-
* If you cannot import this function from this module (e.g. because you use a CKEditor 5 build), you can
|
|
71
|
-
* still add translations by extending the global `window.CKEDITOR_TRANSLATIONS` object by using a function like
|
|
72
|
-
* the one below:
|
|
73
|
-
*
|
|
74
|
-
* ```ts
|
|
75
|
-
* function addTranslations( language, translations, getPluralForm ) {
|
|
76
|
-
* if ( !global.window.CKEDITOR_TRANSLATIONS ) {
|
|
77
|
-
* global.window.CKEDITOR_TRANSLATIONS = {};
|
|
78
|
-
* }
|
|
79
|
-
|
|
80
|
-
* if ( !global.window.CKEDITOR_TRANSLATIONS[ language ] ) {
|
|
81
|
-
* global.window.CKEDITOR_TRANSLATIONS[ language ] = {};
|
|
82
|
-
* }
|
|
83
|
-
*
|
|
84
|
-
* const languageTranslations = global.window.CKEDITOR_TRANSLATIONS[ language ];
|
|
85
|
-
*
|
|
86
|
-
* languageTranslations.dictionary = languageTranslations.dictionary || {};
|
|
87
|
-
* languageTranslations.getPluralForm = getPluralForm || languageTranslations.getPluralForm;
|
|
88
|
-
*
|
|
89
|
-
* // Extend the dictionary for the given language.
|
|
90
|
-
* Object.assign( languageTranslations.dictionary, translations );
|
|
91
|
-
* }
|
|
92
|
-
* ```
|
|
93
|
-
*
|
|
94
|
-
* @param language Target language.
|
|
95
|
-
* @param translations An object with translations which will be added to the dictionary.
|
|
96
|
-
* For each message ID the value should be either a translation or an array of translations if the message
|
|
97
|
-
* should support plural forms.
|
|
98
|
-
* @param getPluralForm A function that returns the plural form index (a number).
|
|
99
|
-
*/
|
|
100
|
-
export declare function add(language: string, translations: {
|
|
101
|
-
readonly [messageId: string]: string | ReadonlyArray<string>;
|
|
102
|
-
}, getPluralForm?: (n: number) => number): void;
|
|
103
|
-
/**
|
|
104
|
-
* **Note:** This method is internal, use {@link module:utils/locale~Locale#t the `t()` function} instead to translate
|
|
105
|
-
* the editor UI parts.
|
|
106
|
-
*
|
|
107
|
-
* This function is responsible for translating messages to the specified language. It uses translations added perviously
|
|
108
|
-
* by {@link module:utils/translation-service~add} (a translations dictionary and the `getPluralForm()` function
|
|
109
|
-
* to provide accurate translations of plural forms).
|
|
110
|
-
*
|
|
111
|
-
* When no translation is defined in the dictionary or the dictionary does not exist, this function returns
|
|
112
|
-
* the original message string or the message plural depending on the number of elements.
|
|
113
|
-
*
|
|
114
|
-
* ```ts
|
|
115
|
-
* translate( 'pl', { string: 'Cancel' } ); // 'Cancel'
|
|
116
|
-
* ```
|
|
117
|
-
*
|
|
118
|
-
* The third optional argument is the number of elements, based on which the single form or one of the plural forms
|
|
119
|
-
* should be picked when the message is supposed to support various plural forms.
|
|
120
|
-
*
|
|
121
|
-
* ```ts
|
|
122
|
-
* translate( 'en', { string: 'Add a space', plural: 'Add %0 spaces' }, 1 ); // 'Add a space'
|
|
123
|
-
* translate( 'en', { string: 'Add a space', plural: 'Add %0 spaces' }, 3 ); // 'Add %0 spaces'
|
|
124
|
-
* ```
|
|
125
|
-
*
|
|
126
|
-
* The message should provide an ID using the `id` property when the message strings are not unique and their
|
|
127
|
-
* translations should be different.
|
|
128
|
-
*
|
|
129
|
-
* ```ts
|
|
130
|
-
* translate( 'en', { string: 'image', id: 'ADD_IMAGE' } );
|
|
131
|
-
* translate( 'en', { string: 'image', id: 'AN_IMAGE' } );
|
|
132
|
-
* ```
|
|
133
|
-
*
|
|
134
|
-
* @internal
|
|
135
|
-
* @param language Target language.
|
|
136
|
-
* @param message A message that will be translated.
|
|
137
|
-
* @param quantity The number of elements for which a plural form should be picked from the target language dictionary.
|
|
138
|
-
* @returns Translated sentence.
|
|
139
|
-
*/
|
|
140
|
-
export declare function _translate(language: string, message: Message, quantity?: number): string;
|
|
141
|
-
/**
|
|
142
|
-
* Clears dictionaries for test purposes.
|
|
143
|
-
*
|
|
144
|
-
* @internal
|
|
145
|
-
*/
|
|
146
|
-
export declare function _clear(): void;
|
|
147
|
-
/**
|
|
148
|
-
* The internationalization message interface. A message that implements this interface can be passed to the `t()` function
|
|
149
|
-
* to be translated to the target UI language.
|
|
150
|
-
*/
|
|
151
|
-
export interface Message {
|
|
152
|
-
/**
|
|
153
|
-
* The message string to translate. Acts as a default translation if the translation for a given language
|
|
154
|
-
* is not defined. When the message is supposed to support plural forms, the string should be the English singular form of the message.
|
|
155
|
-
*/
|
|
156
|
-
readonly string: string;
|
|
157
|
-
/**
|
|
158
|
-
* The message ID. If passed, the message ID is taken from this property instead of the `message.string`.
|
|
159
|
-
* This property is useful when various messages share the same message string, for example, the `editor` string in `in the editor`
|
|
160
|
-
* and `my editor` sentences.
|
|
161
|
-
*/
|
|
162
|
-
readonly id?: string;
|
|
163
|
-
/**
|
|
164
|
-
* The plural form of the message. This property should be skipped when a message is not supposed
|
|
165
|
-
* to support plural forms. Otherwise it should always be set to a string with the English plural form of the message.
|
|
166
|
-
*/
|
|
167
|
-
readonly plural?: string;
|
|
168
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
declare global {
|
|
6
|
+
var CKEDITOR_TRANSLATIONS: {
|
|
7
|
+
[language: string]: {
|
|
8
|
+
dictionary: {
|
|
9
|
+
[messageId: string]: string | ReadonlyArray<string>;
|
|
10
|
+
};
|
|
11
|
+
getPluralForm?: (n: number) => number;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Adds translations to existing ones or overrides the existing translations. These translations will later
|
|
17
|
+
* be available for the {@link module:utils/locale~Locale#t `t()`} function.
|
|
18
|
+
*
|
|
19
|
+
* The `translations` is an object which consists of `messageId: translation` pairs. Note that the message ID can be
|
|
20
|
+
* either constructed from the message string or from the message ID if it was passed
|
|
21
|
+
* (this happens rarely and mostly for short messages or messages with placeholders).
|
|
22
|
+
* Since the editor displays only the message string, the message ID can be found either in the source code or in the
|
|
23
|
+
* built translations for another language.
|
|
24
|
+
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* add( 'pl', {
|
|
27
|
+
* 'Cancel': 'Anuluj',
|
|
28
|
+
* 'IMAGE': 'obraz', // Note that the `IMAGE` comes from the message ID, while the string can be `image`.
|
|
29
|
+
* } );
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* If the message is supposed to support various plural forms, make sure to provide an array with the singular form and all plural forms:
|
|
33
|
+
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* add( 'pl', {
|
|
36
|
+
* 'Add space': [ 'Dodaj spację', 'Dodaj %0 spacje', 'Dodaj %0 spacji' ]
|
|
37
|
+
* } );
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* You should also specify the third argument (the `getPluralForm()` function) that will be used to determine the plural form if no
|
|
41
|
+
* language file was loaded for that language. All language files coming from CKEditor 5 sources will have this option set, so
|
|
42
|
+
* these plural form rules will be reused by other translations added to the registered languages. The `getPluralForm()` function
|
|
43
|
+
* can return either a Boolean or a number.
|
|
44
|
+
*
|
|
45
|
+
* ```ts
|
|
46
|
+
* add( 'en', {
|
|
47
|
+
* // ... Translations.
|
|
48
|
+
* }, n => n !== 1 );
|
|
49
|
+
* add( 'pl', {
|
|
50
|
+
* // ... Translations.
|
|
51
|
+
* }, n => n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && ( n % 100 < 10 || n % 100 >= 20 ) ? 1 : 2 );
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* All translations extend the global `window.CKEDITOR_TRANSLATIONS` object. An example of this object can be found below:
|
|
55
|
+
*
|
|
56
|
+
* ```ts
|
|
57
|
+
* {
|
|
58
|
+
* pl: {
|
|
59
|
+
* dictionary: {
|
|
60
|
+
* 'Cancel': 'Anuluj',
|
|
61
|
+
* 'Add space': [ 'Dodaj spację', 'Dodaj %0 spacje', 'Dodaj %0 spacji' ]
|
|
62
|
+
* },
|
|
63
|
+
* // A function that returns the plural form index.
|
|
64
|
+
* getPluralForm: n => n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && ( n % 100 < 10 || n % 100 >= 20 ) ? 1 : 2 );
|
|
65
|
+
* }
|
|
66
|
+
* // Other languages.
|
|
67
|
+
* }
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* If you cannot import this function from this module (e.g. because you use a CKEditor 5 build), you can
|
|
71
|
+
* still add translations by extending the global `window.CKEDITOR_TRANSLATIONS` object by using a function like
|
|
72
|
+
* the one below:
|
|
73
|
+
*
|
|
74
|
+
* ```ts
|
|
75
|
+
* function addTranslations( language, translations, getPluralForm ) {
|
|
76
|
+
* if ( !global.window.CKEDITOR_TRANSLATIONS ) {
|
|
77
|
+
* global.window.CKEDITOR_TRANSLATIONS = {};
|
|
78
|
+
* }
|
|
79
|
+
|
|
80
|
+
* if ( !global.window.CKEDITOR_TRANSLATIONS[ language ] ) {
|
|
81
|
+
* global.window.CKEDITOR_TRANSLATIONS[ language ] = {};
|
|
82
|
+
* }
|
|
83
|
+
*
|
|
84
|
+
* const languageTranslations = global.window.CKEDITOR_TRANSLATIONS[ language ];
|
|
85
|
+
*
|
|
86
|
+
* languageTranslations.dictionary = languageTranslations.dictionary || {};
|
|
87
|
+
* languageTranslations.getPluralForm = getPluralForm || languageTranslations.getPluralForm;
|
|
88
|
+
*
|
|
89
|
+
* // Extend the dictionary for the given language.
|
|
90
|
+
* Object.assign( languageTranslations.dictionary, translations );
|
|
91
|
+
* }
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* @param language Target language.
|
|
95
|
+
* @param translations An object with translations which will be added to the dictionary.
|
|
96
|
+
* For each message ID the value should be either a translation or an array of translations if the message
|
|
97
|
+
* should support plural forms.
|
|
98
|
+
* @param getPluralForm A function that returns the plural form index (a number).
|
|
99
|
+
*/
|
|
100
|
+
export declare function add(language: string, translations: {
|
|
101
|
+
readonly [messageId: string]: string | ReadonlyArray<string>;
|
|
102
|
+
}, getPluralForm?: (n: number) => number): void;
|
|
103
|
+
/**
|
|
104
|
+
* **Note:** This method is internal, use {@link module:utils/locale~Locale#t the `t()` function} instead to translate
|
|
105
|
+
* the editor UI parts.
|
|
106
|
+
*
|
|
107
|
+
* This function is responsible for translating messages to the specified language. It uses translations added perviously
|
|
108
|
+
* by {@link module:utils/translation-service~add} (a translations dictionary and the `getPluralForm()` function
|
|
109
|
+
* to provide accurate translations of plural forms).
|
|
110
|
+
*
|
|
111
|
+
* When no translation is defined in the dictionary or the dictionary does not exist, this function returns
|
|
112
|
+
* the original message string or the message plural depending on the number of elements.
|
|
113
|
+
*
|
|
114
|
+
* ```ts
|
|
115
|
+
* translate( 'pl', { string: 'Cancel' } ); // 'Cancel'
|
|
116
|
+
* ```
|
|
117
|
+
*
|
|
118
|
+
* The third optional argument is the number of elements, based on which the single form or one of the plural forms
|
|
119
|
+
* should be picked when the message is supposed to support various plural forms.
|
|
120
|
+
*
|
|
121
|
+
* ```ts
|
|
122
|
+
* translate( 'en', { string: 'Add a space', plural: 'Add %0 spaces' }, 1 ); // 'Add a space'
|
|
123
|
+
* translate( 'en', { string: 'Add a space', plural: 'Add %0 spaces' }, 3 ); // 'Add %0 spaces'
|
|
124
|
+
* ```
|
|
125
|
+
*
|
|
126
|
+
* The message should provide an ID using the `id` property when the message strings are not unique and their
|
|
127
|
+
* translations should be different.
|
|
128
|
+
*
|
|
129
|
+
* ```ts
|
|
130
|
+
* translate( 'en', { string: 'image', id: 'ADD_IMAGE' } );
|
|
131
|
+
* translate( 'en', { string: 'image', id: 'AN_IMAGE' } );
|
|
132
|
+
* ```
|
|
133
|
+
*
|
|
134
|
+
* @internal
|
|
135
|
+
* @param language Target language.
|
|
136
|
+
* @param message A message that will be translated.
|
|
137
|
+
* @param quantity The number of elements for which a plural form should be picked from the target language dictionary.
|
|
138
|
+
* @returns Translated sentence.
|
|
139
|
+
*/
|
|
140
|
+
export declare function _translate(language: string, message: Message, quantity?: number): string;
|
|
141
|
+
/**
|
|
142
|
+
* Clears dictionaries for test purposes.
|
|
143
|
+
*
|
|
144
|
+
* @internal
|
|
145
|
+
*/
|
|
146
|
+
export declare function _clear(): void;
|
|
147
|
+
/**
|
|
148
|
+
* The internationalization message interface. A message that implements this interface can be passed to the `t()` function
|
|
149
|
+
* to be translated to the target UI language.
|
|
150
|
+
*/
|
|
151
|
+
export interface Message {
|
|
152
|
+
/**
|
|
153
|
+
* The message string to translate. Acts as a default translation if the translation for a given language
|
|
154
|
+
* is not defined. When the message is supposed to support plural forms, the string should be the English singular form of the message.
|
|
155
|
+
*/
|
|
156
|
+
readonly string: string;
|
|
157
|
+
/**
|
|
158
|
+
* The message ID. If passed, the message ID is taken from this property instead of the `message.string`.
|
|
159
|
+
* This property is useful when various messages share the same message string, for example, the `editor` string in `in the editor`
|
|
160
|
+
* and `my editor` sentences.
|
|
161
|
+
*/
|
|
162
|
+
readonly id?: string;
|
|
163
|
+
/**
|
|
164
|
+
* The plural form of the message. This property should be skipped when a message is not supposed
|
|
165
|
+
* to support plural forms. Otherwise it should always be set to a string with the English plural form of the message.
|
|
166
|
+
*/
|
|
167
|
+
readonly plural?: string;
|
|
168
|
+
}
|