@zohodesk/i18n 1.0.0-beta.33 → 1.0.0-beta.34
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/README.md +4 -0
- package/es/index.js +1 -0
- package/es/utils/jsxTranslations.js +22 -12
- package/lib/index.js +8 -0
- package/lib/utils/jsxTranslations.js +23 -10
- package/package.json +1 -1
- package/src/index.js +1 -0
- package/src/utils/jsxTranslations.js +23 -11
package/README.md
CHANGED
package/es/index.js
CHANGED
|
@@ -8,4 +8,5 @@ export { default as FormatText } from "./components/FormatText";
|
|
|
8
8
|
export { default as PluralFormat } from "./components/PluralFormat";
|
|
9
9
|
export { default as DateTimeDiffFormat } from "./components/DateTimeDiffFormat";
|
|
10
10
|
export { default as UserTimeDiffFormat } from "./components/UserTimeDiffFormat";
|
|
11
|
+
export { placeComponentForTags } from "./utils/jsxTranslations";
|
|
11
12
|
export const getI18NValue = (i18n, key, values) => getI18NValue1(i18n)(key, values);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { unescapeUnicode } from "./index";
|
|
3
|
+
import { i18NProviderUtils } from "../components/I18NProvider";
|
|
3
4
|
export function splitMatchedExp(_ref) {
|
|
4
5
|
let {
|
|
5
6
|
expression,
|
|
@@ -165,6 +166,26 @@ export function prepareI18NFunc() {
|
|
|
165
166
|
stringPlaceHolders
|
|
166
167
|
});
|
|
167
168
|
}
|
|
169
|
+
|
|
170
|
+
function i18nMechanismForComponents(i18nValue, key) {
|
|
171
|
+
if (typeof i18nValue === 'string') {
|
|
172
|
+
i18nValue = unescapeUnicode(i18nValue);
|
|
173
|
+
const value = prepareI18NFunc({
|
|
174
|
+
i18nKey: i18nValue
|
|
175
|
+
});
|
|
176
|
+
window.loadI18nChunk && window.loadI18nChunk({
|
|
177
|
+
[key]: value
|
|
178
|
+
});
|
|
179
|
+
i18nValue = value;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return i18nValue;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export function placeComponentForTags(i18nValue) {
|
|
186
|
+
const value = i18NProviderUtils.getI18NComponent(i18nValue);
|
|
187
|
+
return i18nMechanismForComponents(value, value);
|
|
188
|
+
}
|
|
168
189
|
export function getI18NComponent(i18n) {
|
|
169
190
|
if (typeof i18n === 'undefined') {
|
|
170
191
|
return key => key;
|
|
@@ -177,17 +198,6 @@ export function getI18NComponent(i18n) {
|
|
|
177
198
|
return key;
|
|
178
199
|
}
|
|
179
200
|
|
|
180
|
-
|
|
181
|
-
i18nStr = unescapeUnicode(i18nStr);
|
|
182
|
-
const value = prepareI18NFunc({
|
|
183
|
-
i18nKey: i18nStr
|
|
184
|
-
});
|
|
185
|
-
window.loadI18nChunk && window.loadI18nChunk({
|
|
186
|
-
[key]: value
|
|
187
|
-
});
|
|
188
|
-
i18nStr = value;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
return i18nStr;
|
|
201
|
+
return i18nMechanismForComponents(i18nStr, key);
|
|
192
202
|
};
|
|
193
203
|
}
|
package/lib/index.js
CHANGED
|
@@ -150,6 +150,12 @@ Object.defineProperty(exports, "pad", {
|
|
|
150
150
|
return _utils.pad;
|
|
151
151
|
}
|
|
152
152
|
});
|
|
153
|
+
Object.defineProperty(exports, "placeComponentForTags", {
|
|
154
|
+
enumerable: true,
|
|
155
|
+
get: function get() {
|
|
156
|
+
return _jsxTranslations.placeComponentForTags;
|
|
157
|
+
}
|
|
158
|
+
});
|
|
153
159
|
Object.defineProperty(exports, "replaceI18NValuesWithRegex", {
|
|
154
160
|
enumerable: true,
|
|
155
161
|
get: function get() {
|
|
@@ -205,6 +211,8 @@ var _DateTimeDiffFormat = _interopRequireDefault(require("./components/DateTimeD
|
|
|
205
211
|
|
|
206
212
|
var _UserTimeDiffFormat = _interopRequireDefault(require("./components/UserTimeDiffFormat"));
|
|
207
213
|
|
|
214
|
+
var _jsxTranslations = require("./utils/jsxTranslations");
|
|
215
|
+
|
|
208
216
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
209
217
|
|
|
210
218
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.createElement = createElement;
|
|
7
7
|
exports.generateChildren = generateChildren;
|
|
8
8
|
exports.getI18NComponent = getI18NComponent;
|
|
9
|
+
exports.placeComponentForTags = placeComponentForTags;
|
|
9
10
|
exports.prepareI18NFunc = prepareI18NFunc;
|
|
10
11
|
exports.replaceWithComponentPlaceHolder = replaceWithComponentPlaceHolder;
|
|
11
12
|
exports.splitMatchedExp = splitMatchedExp;
|
|
@@ -14,6 +15,8 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
14
15
|
|
|
15
16
|
var _index = require("./index");
|
|
16
17
|
|
|
18
|
+
var _I18NProvider = require("../components/I18NProvider");
|
|
19
|
+
|
|
17
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
18
21
|
|
|
19
22
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -214,6 +217,25 @@ function prepareI18NFunc() {
|
|
|
214
217
|
});
|
|
215
218
|
}
|
|
216
219
|
|
|
220
|
+
function i18nMechanismForComponents(i18nValue, key) {
|
|
221
|
+
if (typeof i18nValue === 'string') {
|
|
222
|
+
i18nValue = (0, _index.unescapeUnicode)(i18nValue);
|
|
223
|
+
var value = prepareI18NFunc({
|
|
224
|
+
i18nKey: i18nValue
|
|
225
|
+
});
|
|
226
|
+
window.loadI18nChunk && window.loadI18nChunk(_defineProperty({}, key, value));
|
|
227
|
+
i18nValue = value;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return i18nValue;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function placeComponentForTags(i18nValue) {
|
|
234
|
+
var value = _I18NProvider.i18NProviderUtils.getI18NComponent(i18nValue);
|
|
235
|
+
|
|
236
|
+
return i18nMechanismForComponents(value, value);
|
|
237
|
+
}
|
|
238
|
+
|
|
217
239
|
function getI18NComponent(i18n) {
|
|
218
240
|
if (typeof i18n === 'undefined') {
|
|
219
241
|
return function (key) {
|
|
@@ -228,15 +250,6 @@ function getI18NComponent(i18n) {
|
|
|
228
250
|
return key;
|
|
229
251
|
}
|
|
230
252
|
|
|
231
|
-
|
|
232
|
-
i18nStr = (0, _index.unescapeUnicode)(i18nStr);
|
|
233
|
-
var value = prepareI18NFunc({
|
|
234
|
-
i18nKey: i18nStr
|
|
235
|
-
});
|
|
236
|
-
window.loadI18nChunk && window.loadI18nChunk(_defineProperty({}, key, value));
|
|
237
|
-
i18nStr = value;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
return i18nStr;
|
|
253
|
+
return i18nMechanismForComponents(i18nStr, key);
|
|
241
254
|
};
|
|
242
255
|
}
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -33,5 +33,6 @@ export { default as FormatText } from './components/FormatText';
|
|
|
33
33
|
export { default as PluralFormat } from './components/PluralFormat';
|
|
34
34
|
export { default as DateTimeDiffFormat } from './components/DateTimeDiffFormat';
|
|
35
35
|
export { default as UserTimeDiffFormat } from './components/UserTimeDiffFormat';
|
|
36
|
+
export { placeComponentForTags } from "./utils/jsxTranslations";
|
|
36
37
|
export const getI18NValue = (i18n, key, values) =>
|
|
37
38
|
getI18NValue1(i18n)(key, values);
|
|
@@ -2,6 +2,9 @@ import React from 'react';
|
|
|
2
2
|
import {
|
|
3
3
|
unescapeUnicode
|
|
4
4
|
} from './index';
|
|
5
|
+
import {
|
|
6
|
+
i18NProviderUtils
|
|
7
|
+
} from "../components/I18NProvider";
|
|
5
8
|
|
|
6
9
|
export function splitMatchedExp({
|
|
7
10
|
expression,
|
|
@@ -156,6 +159,25 @@ export function prepareI18NFunc({
|
|
|
156
159
|
});
|
|
157
160
|
}
|
|
158
161
|
|
|
162
|
+
function i18nMechanismForComponents(i18nValue, key) {
|
|
163
|
+
if(typeof i18nValue === 'string') {
|
|
164
|
+
i18nValue = unescapeUnicode(i18nValue);
|
|
165
|
+
const value = prepareI18NFunc({
|
|
166
|
+
i18nKey: i18nValue
|
|
167
|
+
});
|
|
168
|
+
window.loadI18nChunk && window.loadI18nChunk({
|
|
169
|
+
[key] : value
|
|
170
|
+
});
|
|
171
|
+
i18nValue = value;
|
|
172
|
+
}
|
|
173
|
+
return i18nValue;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export function placeComponentForTags(i18nValue) {
|
|
177
|
+
const value = i18NProviderUtils.getI18NComponent(i18nValue);
|
|
178
|
+
return i18nMechanismForComponents(value, value);
|
|
179
|
+
}
|
|
180
|
+
|
|
159
181
|
export function getI18NComponent(i18n) {
|
|
160
182
|
if(typeof i18n === 'undefined') {
|
|
161
183
|
return (key) => key;
|
|
@@ -165,16 +187,6 @@ export function getI18NComponent(i18n) {
|
|
|
165
187
|
if (i18nStr === undefined) {
|
|
166
188
|
return key;
|
|
167
189
|
}
|
|
168
|
-
|
|
169
|
-
i18nStr = unescapeUnicode(i18nStr);
|
|
170
|
-
const value = prepareI18NFunc({
|
|
171
|
-
i18nKey: i18nStr
|
|
172
|
-
});
|
|
173
|
-
window.loadI18nChunk && window.loadI18nChunk({
|
|
174
|
-
[key] : value
|
|
175
|
-
});
|
|
176
|
-
i18nStr = value;
|
|
177
|
-
}
|
|
178
|
-
return i18nStr;
|
|
190
|
+
return i18nMechanismForComponents(i18nStr, key);
|
|
179
191
|
}
|
|
180
192
|
}
|