@transifex/native 7.1.1 → 7.1.3
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/browser.native.js +1 -1
- package/dist/browser.native.js.map +1 -1
- package/dist/node.native.d.ts +3 -3
- package/dist/node.native.js +1 -1
- package/dist/node.native.js.map +1 -1
- package/package.json +2 -2
- package/src/TxNative.js +1 -1
- package/src/index.d.ts +3 -3
- package/src/policies/PseudoTranslationPolicy.js +1 -1
- package/src/policies/SourceStringPolicy.js +1 -1
- package/src/renderers/MessageFormatRenderer.js +7 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transifex/native",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.3",
|
|
4
4
|
"description": "i18n framework using Transifex Native",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"transifex",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"webpack-cli": "^5.1.4"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@messageformat/core": "^3.3.0",
|
|
57
56
|
"cross-fetch": "^4.0.0",
|
|
57
|
+
"intl-messageformat": "^10.5.14",
|
|
58
58
|
"md5": "^2.3.0"
|
|
59
59
|
}
|
|
60
60
|
}
|
package/src/TxNative.js
CHANGED
|
@@ -151,7 +151,7 @@ export default class TxNative {
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
if (isMissing && locale) {
|
|
154
|
-
translation = this.missingPolicy.handle(translation, locale);
|
|
154
|
+
translation = this.missingPolicy.handle(translation, locale, params);
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
if (!isString(translation)) translation = `${translation}`;
|
package/src/index.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ declare module '@transifex/native' {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
interface ITranslationPolicy {
|
|
49
|
-
handle(sourceString: string, localeCode: string): string;
|
|
49
|
+
handle(sourceString: string, localeCode: string, params: ITranslateParams): string;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
interface IErrorPolicy {
|
|
@@ -124,7 +124,7 @@ declare module '@transifex/native' {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
export class PseudoTranslationPolicy implements ITranslationPolicy {
|
|
127
|
-
handle(sourceString: string, _localeCode: string): string;
|
|
127
|
+
handle(sourceString: string, _localeCode: string, _params: ITranslateParams): string;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
export class SourceErrorPolicy implements IErrorPolicy {
|
|
@@ -132,7 +132,7 @@ declare module '@transifex/native' {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
export class SourceStringPolicy implements ITranslationPolicy {
|
|
135
|
-
handle(sourceString: string, _localeCode: string): string;
|
|
135
|
+
handle(sourceString: string, _localeCode: string, _params: ITranslateParams): string;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
export class ThrowErrorPolicy implements IErrorPolicy {
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
/* eslint-disable class-methods-use-this */
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
// object to cache MessageFormat classes related to
|
|
5
|
-
// specific locales
|
|
6
|
-
const MF = {};
|
|
2
|
+
import IntlMessageFormat from 'intl-messageformat';
|
|
7
3
|
|
|
8
4
|
/**
|
|
9
5
|
* MessageFormat renderer
|
|
@@ -16,18 +12,12 @@ export default class MessageFormatRenderer {
|
|
|
16
12
|
// construct a MessageFormat class based on locale
|
|
17
13
|
// to make dates and other content localizable
|
|
18
14
|
const locale = ((localeCode || '').split('_'))[0];
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
} catch (err) {
|
|
25
|
-
MF[locale] = new MessageFormat('*', {
|
|
26
|
-
strictPluralKeys: false,
|
|
27
|
-
});
|
|
28
|
-
}
|
|
15
|
+
let msg;
|
|
16
|
+
try {
|
|
17
|
+
msg = new IntlMessageFormat(sourceString, locale, undefined, { ignoreTag: true });
|
|
18
|
+
} catch (err) {
|
|
19
|
+
msg = new IntlMessageFormat(sourceString, undefined, undefined, { ignoreTag: true });
|
|
29
20
|
}
|
|
30
|
-
|
|
31
|
-
return msg(params);
|
|
21
|
+
return msg.format(params);
|
|
32
22
|
}
|
|
33
23
|
}
|