@zohodesk/client_build_tool 0.0.11-exp.12 → 0.0.11-exp.13
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/schemas/defaultConfigValues.js +1 -0
- package/lib/schemas/defaultConfigValuesOnly.js +1 -0
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexPlugin.js +20 -16
- package/lib/shared/bundler/webpack/loaderConfigs/i18nIdReplaceLoaderConfig.js +1 -0
- package/lib/shared/bundler/webpack/loaders/i18nIdReplaceLoader.js +2 -0
- package/package.json +1 -1
|
@@ -176,6 +176,7 @@ var _default = {
|
|
|
176
176
|
},
|
|
177
177
|
i18nIndexing: {
|
|
178
178
|
enable: false,
|
|
179
|
+
devMode: false,
|
|
179
180
|
jsResourcePath: './deskapp/properties/JSResources.properties',
|
|
180
181
|
propertiesFolderPath: './deskapp/properties',
|
|
181
182
|
numericMapPath: './deskapp/properties/i18n-numeric-map.json',
|
|
@@ -99,6 +99,7 @@ var _default = {
|
|
|
99
99
|
},
|
|
100
100
|
i18nIndexing: {
|
|
101
101
|
enable: false,
|
|
102
|
+
devMode: false,
|
|
102
103
|
jsResourcePath: './deskapp/properties/JSResources.properties',
|
|
103
104
|
propertiesFolderPath: './deskapp/properties',
|
|
104
105
|
numericMapPath: './deskapp/properties/i18n-numeric-map.json',
|
package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexPlugin.js
CHANGED
|
@@ -103,7 +103,8 @@ class I18nNumericIndexPlugin {
|
|
|
103
103
|
|
|
104
104
|
const {
|
|
105
105
|
sortedKeys,
|
|
106
|
-
totalKeys
|
|
106
|
+
totalKeys,
|
|
107
|
+
originalKeyToNumericId
|
|
107
108
|
} = this.getNumericMap(compilation);
|
|
108
109
|
const {
|
|
109
110
|
jsResourceBase,
|
|
@@ -113,28 +114,31 @@ class I18nNumericIndexPlugin {
|
|
|
113
114
|
if (!locales.length) return callback();
|
|
114
115
|
const numericKeysSet = new Set(sortedKeys);
|
|
115
116
|
const englishData = allI18n.en_US || jsResourceBase;
|
|
117
|
+
const isDevMode = this.options.devMode || process.env.NODE_ENV === 'development';
|
|
116
118
|
locales.forEach(locale => {
|
|
117
119
|
const localeData = allI18n[locale] || {};
|
|
118
120
|
const numericData = {};
|
|
119
|
-
|
|
120
|
-
for (let i = 0; i < totalKeys; i++) {
|
|
121
|
-
const key = sortedKeys[i];
|
|
122
|
-
|
|
123
|
-
if (key && jsResourceBase[key] !== undefined) {
|
|
124
|
-
numericData[i] = localeData[key] ?? englishData[key];
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const dynamicData = {};
|
|
121
|
+
const unmappedData = {};
|
|
129
122
|
Object.keys(jsResourceBase).forEach(key => {
|
|
130
|
-
|
|
131
|
-
|
|
123
|
+
const translation = localeData[key] ?? englishData[key];
|
|
124
|
+
|
|
125
|
+
if (originalKeyToNumericId && originalKeyToNumericId.hasOwnProperty(key)) {
|
|
126
|
+
const numericId = originalKeyToNumericId[key];
|
|
127
|
+
numericData[numericId] = translation;
|
|
128
|
+
} else if (numericKeysSet.has(key)) {
|
|
129
|
+
const index = sortedKeys.indexOf(key);
|
|
130
|
+
|
|
131
|
+
if (index !== -1) {
|
|
132
|
+
numericData[index] = translation;
|
|
133
|
+
}
|
|
134
|
+
} else {
|
|
135
|
+
unmappedData[key] = translation;
|
|
132
136
|
}
|
|
133
137
|
});
|
|
134
138
|
|
|
135
139
|
if (this.options.singleFile) {
|
|
136
140
|
const combinedData = { ...numericData,
|
|
137
|
-
...
|
|
141
|
+
...unmappedData
|
|
138
142
|
};
|
|
139
143
|
|
|
140
144
|
if (Object.keys(combinedData).length > 0) {
|
|
@@ -146,8 +150,8 @@ class I18nNumericIndexPlugin {
|
|
|
146
150
|
this.emitChunk(compilation, this.options.numericFilenameTemplate, locale, numericData, 'numeric');
|
|
147
151
|
}
|
|
148
152
|
|
|
149
|
-
if (Object.keys(
|
|
150
|
-
this.emitChunk(compilation, this.options.dynamicFilenameTemplate, locale,
|
|
153
|
+
if (Object.keys(unmappedData).length > 0) {
|
|
154
|
+
this.emitChunk(compilation, this.options.dynamicFilenameTemplate, locale, unmappedData, 'dynamic');
|
|
151
155
|
}
|
|
152
156
|
}
|
|
153
157
|
});
|
|
@@ -56,6 +56,7 @@ function i18nIdReplaceLoaderConfig(options, webpackContext) {
|
|
|
56
56
|
allI18nData: allI18nData,
|
|
57
57
|
sourceMaps: false,
|
|
58
58
|
numericMapPath: numericMapPath,
|
|
59
|
+
devMode: options.i18nIndexing?.devMode || false,
|
|
59
60
|
includePaths: options.i18nIndexing?.loaderOptions?.includePaths || [],
|
|
60
61
|
excludePaths: options.i18nIndexing?.loaderOptions?.excludePaths || ['node_modules', 'tests']
|
|
61
62
|
};
|
|
@@ -61,6 +61,8 @@ module.exports = function i18nIdReplaceLoader(source, map) {
|
|
|
61
61
|
return callback(null, source, map);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
const isDevMode = options.devMode || process.env.NODE_ENV === 'development';
|
|
65
|
+
|
|
64
66
|
try {
|
|
65
67
|
const ast = parser.parse(source, {
|
|
66
68
|
sourceType: 'module',
|