locizify 7.0.4 → 8.0.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 +9 -0
- package/README.md +5 -5
- package/dist/umd/locizify.js +37 -3
- package/dist/umd/locizify.min.js +2 -2
- package/locizify.js +37 -3
- package/locizify.min.js +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
### 8.0.1
|
|
2
|
+
|
|
3
|
+
- update i18next-locize-backend
|
|
4
|
+
|
|
5
|
+
### 8.0.0
|
|
6
|
+
|
|
7
|
+
- update i18next-locize-backend
|
|
8
|
+
- log/error is shown if cdnType is not defined, because of changing default to 'standard' instead of 'pro'
|
|
9
|
+
|
|
1
10
|
### 7.0.4
|
|
2
11
|
|
|
3
12
|
- update i18next-locize-backend
|
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ Just drop the following line to your header to deliver your content in any langu
|
|
|
12
12
|
id="locizify"
|
|
13
13
|
projectid="[PROJECT_ID]"
|
|
14
14
|
apikey="[API_KEY]"
|
|
15
|
-
src="https://unpkg.com/locizify@^
|
|
15
|
+
src="https://unpkg.com/locizify@^8.0.0"
|
|
16
16
|
autopilot="true"
|
|
17
17
|
cdnType="standard"
|
|
18
18
|
></script>
|
|
@@ -22,7 +22,7 @@ Just drop the following line to your header to deliver your content in any langu
|
|
|
22
22
|
id="locizify"
|
|
23
23
|
projectid="[PROJECT_ID]"
|
|
24
24
|
apikey="[API_KEY]"
|
|
25
|
-
src="https://cdn.jsdelivr.net/npm/locizify@^
|
|
25
|
+
src="https://cdn.jsdelivr.net/npm/locizify@^8.0.0"
|
|
26
26
|
autopilot="true"
|
|
27
27
|
cdnType="standard"
|
|
28
28
|
></script>
|
|
@@ -71,7 +71,7 @@ Add the script to your page:
|
|
|
71
71
|
id="locizify"
|
|
72
72
|
projectid="[PROJECT_ID]"
|
|
73
73
|
apikey="[API_KEY]"
|
|
74
|
-
src="https://unpkg.com/locizify@^
|
|
74
|
+
src="https://unpkg.com/locizify@^8.0.0"
|
|
75
75
|
autopilot
|
|
76
76
|
cdnType="standard"
|
|
77
77
|
></script>
|
|
@@ -105,7 +105,7 @@ Add the script to your page:
|
|
|
105
105
|
apikey="[API_KEY]"
|
|
106
106
|
referencelng="[LNG]"
|
|
107
107
|
fallbacklng="[LNG]"
|
|
108
|
-
src="https://unpkg.com/locizify@^
|
|
108
|
+
src="https://unpkg.com/locizify@^8.0.0"
|
|
109
109
|
|
|
110
110
|
// all custom attributes can also be prefixed with data-
|
|
111
111
|
// data-projectid="[PROJECT_ID]"
|
|
@@ -136,7 +136,7 @@ Add the script to your page:
|
|
|
136
136
|
<!DOCTYPE html>
|
|
137
137
|
<html>
|
|
138
138
|
<head>
|
|
139
|
-
<script src="https://unpkg.com/locizify@^
|
|
139
|
+
<script src="https://unpkg.com/locizify@^8.0.0"></script>
|
|
140
140
|
<script>
|
|
141
141
|
locizify.init({
|
|
142
142
|
// required
|
package/dist/umd/locizify.js
CHANGED
|
@@ -7260,6 +7260,12 @@
|
|
|
7260
7260
|
}).catch(function () {});
|
|
7261
7261
|
} catch (e) {}
|
|
7262
7262
|
}
|
|
7263
|
+
var storage = {};
|
|
7264
|
+
var parseMaxAge = function parseMaxAge(headerString) {
|
|
7265
|
+
if (!headerString) return 0;
|
|
7266
|
+
var matches = headerString.match(/max-age=([0-9]+)/);
|
|
7267
|
+
return matches ? parseInt(matches[1], 10) : 0;
|
|
7268
|
+
};
|
|
7263
7269
|
var requestWithFetch$1 = function requestWithFetch(options, url, payload, callback) {
|
|
7264
7270
|
var headers = {};
|
|
7265
7271
|
if (typeof window === 'undefined' && typeof global !== 'undefined' && typeof global.process !== 'undefined' && global.process.versions && global.process.versions.node) {
|
|
@@ -7285,11 +7291,13 @@
|
|
|
7285
7291
|
status: response.status,
|
|
7286
7292
|
resourceNotExisting: resourceNotExisting
|
|
7287
7293
|
});
|
|
7294
|
+
var cacheControl = response.headers && response.headers.get('cache-control');
|
|
7288
7295
|
response.text().then(function (data) {
|
|
7289
7296
|
callback(null, {
|
|
7290
7297
|
status: response.status,
|
|
7291
7298
|
data: data,
|
|
7292
|
-
resourceNotExisting: resourceNotExisting
|
|
7299
|
+
resourceNotExisting: resourceNotExisting,
|
|
7300
|
+
cacheControl: cacheControl
|
|
7293
7301
|
});
|
|
7294
7302
|
}).catch(callback);
|
|
7295
7303
|
};
|
|
@@ -7330,10 +7338,12 @@
|
|
|
7330
7338
|
resourceNotExisting: resourceNotExisting
|
|
7331
7339
|
});
|
|
7332
7340
|
}
|
|
7341
|
+
var cacheControl = x.getResponseHeader('Cache-Control');
|
|
7333
7342
|
x.readyState > 3 && callback(x.status >= 400 ? x.statusText : null, {
|
|
7334
7343
|
status: x.status,
|
|
7335
7344
|
data: x.responseText,
|
|
7336
|
-
resourceNotExisting: resourceNotExisting
|
|
7345
|
+
resourceNotExisting: resourceNotExisting,
|
|
7346
|
+
cacheControl: cacheControl
|
|
7337
7347
|
});
|
|
7338
7348
|
};
|
|
7339
7349
|
x.send(JSON.stringify(payload));
|
|
@@ -7347,6 +7357,26 @@
|
|
|
7347
7357
|
payload = undefined;
|
|
7348
7358
|
}
|
|
7349
7359
|
callback = callback || function () {};
|
|
7360
|
+
var useCacheLayer = typeof window === 'undefined' && options.useCacheLayer;
|
|
7361
|
+
if (useCacheLayer && !payload && !options.noCache && storage[url] && storage[url].expires > Date.now()) {
|
|
7362
|
+
return callback(null, storage[url].data);
|
|
7363
|
+
}
|
|
7364
|
+
var originalCallback = callback;
|
|
7365
|
+
callback = function callback(err, res) {
|
|
7366
|
+
if (useCacheLayer && !err && res && !payload && res.cacheControl) {
|
|
7367
|
+
var maxAge = parseMaxAge(res.cacheControl);
|
|
7368
|
+
if (maxAge > 0) {
|
|
7369
|
+
storage[url] = {
|
|
7370
|
+
data: res,
|
|
7371
|
+
expires: Date.now() + maxAge * 1000
|
|
7372
|
+
};
|
|
7373
|
+
}
|
|
7374
|
+
}
|
|
7375
|
+
originalCallback(err, res);
|
|
7376
|
+
};
|
|
7377
|
+
if (!payload && options.noCache && options.cdnType === 'standard') {
|
|
7378
|
+
url += (url.indexOf('?') >= 0 ? '&' : '?') + 'cache=no';
|
|
7379
|
+
}
|
|
7350
7380
|
if (fetchApi$1) {
|
|
7351
7381
|
return requestWithFetch$1(options, url, payload, callback);
|
|
7352
7382
|
}
|
|
@@ -7420,7 +7450,8 @@
|
|
|
7420
7450
|
reloadInterval: typeof window !== 'undefined' ? false : 60 * 60 * 1000,
|
|
7421
7451
|
checkForProjectTimeout: 3 * 1000,
|
|
7422
7452
|
storageExpiration: 60 * 60 * 1000,
|
|
7423
|
-
writeDebounce: 5 * 1000
|
|
7453
|
+
writeDebounce: 5 * 1000,
|
|
7454
|
+
useCacheLayer: typeof window === 'undefined'
|
|
7424
7455
|
}, getApiPaths(cdnType));
|
|
7425
7456
|
};
|
|
7426
7457
|
var hasLocalStorageSupport$1;
|
|
@@ -7559,6 +7590,9 @@
|
|
|
7559
7590
|
Object.keys(apiPaths).forEach(function (ap) {
|
|
7560
7591
|
if (!orgPassedOptions[ap]) _this.options[ap] = apiPaths[ap];
|
|
7561
7592
|
});
|
|
7593
|
+
if (!orgPassedOptions.cdnType) {
|
|
7594
|
+
console.error('[i18next-locize-backend] In the next major version, the default \'cdnType\' will be \'standard\'. Please set \'cdnType\' explicitly in your options to avoid missing translations.');
|
|
7595
|
+
}
|
|
7562
7596
|
if (this.options.pull) {
|
|
7563
7597
|
console.warn('The pull API was removed use "private: true" option instead: https://www.locize.com/docs/api#fetch-private-namespace-resources');
|
|
7564
7598
|
}
|