update modules
This commit is contained in:
24
node_modules/i18next-xhr-backend/.circleci/config.yml
generated
vendored
Normal file
24
node_modules/i18next-xhr-backend/.circleci/config.yml
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
version: 2
|
||||
jobs:
|
||||
build:
|
||||
docker:
|
||||
- image: circleci/node:latest-browsers
|
||||
environment:
|
||||
CHROME_BIN: '/usr/bin/google-chrome'
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: update-npm
|
||||
command: 'sudo npm install -g npm@6'
|
||||
- restore_cache:
|
||||
key: dependency-cache-{{ checksum "package.json" }}
|
||||
- run:
|
||||
name: install-npm-wee
|
||||
command: npm install
|
||||
- save_cache:
|
||||
key: dependency-cache-{{ checksum "package.json" }}
|
||||
paths:
|
||||
- ./node_modules
|
||||
- run:
|
||||
name: test
|
||||
command: npm test
|
2
node_modules/i18next-xhr-backend/.prettierignore
generated
vendored
Normal file
2
node_modules/i18next-xhr-backend/.prettierignore
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
dist
|
||||
i18nextXHRBackend*
|
8
node_modules/i18next-xhr-backend/.prettierrc
generated
vendored
Normal file
8
node_modules/i18next-xhr-backend/.prettierrc
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"bracketSpacing": true,
|
||||
"jsxBracketSameLine": false,
|
||||
"printWidth": 100,
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all"
|
||||
}
|
6
node_modules/i18next-xhr-backend/.travis.yml
generated
vendored
6
node_modules/i18next-xhr-backend/.travis.yml
generated
vendored
@@ -1,6 +0,0 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "6.2"
|
||||
before_script:
|
||||
- npm install -g gulp
|
||||
- npm install -g karma
|
35
node_modules/i18next-xhr-backend/CHANGELOG.md
generated
vendored
35
node_modules/i18next-xhr-backend/CHANGELOG.md
generated
vendored
@@ -1,3 +1,38 @@
|
||||
### 3.2.2
|
||||
|
||||
- typescript: Hotfix TS error importing types from i18next [333](https://github.com/i18next/i18next-xhr-backend/pull/333)
|
||||
|
||||
### 3.2.1
|
||||
|
||||
- typescript: Use updated ts export default from i18next [330](https://github.com/i18next/i18next-xhr-backend/pull/330)
|
||||
|
||||
### 3.2.0
|
||||
|
||||
- Parse payload option [326](https://github.com/i18next/i18next-xhr-backend/pull/326)
|
||||
|
||||
### 3.1.2
|
||||
|
||||
- typescript: fix No inputs were found in config file" - tsconfig typo [323](https://github.com/i18next/i18next-xhr-backend/issues/323)
|
||||
|
||||
### 3.1.1
|
||||
|
||||
- typescript: fix use of class, add `use()` tests [322](https://github.com/i18next/i18next-xhr-backend/pull/322)
|
||||
|
||||
### 3.1.0
|
||||
|
||||
- allow customHeaders to be a function [321](https://github.com/i18next/i18next-xhr-backend/pull/321)
|
||||
|
||||
### 3.0.1
|
||||
|
||||
- typescript: Fix the types and use exposed types from i18next [319](https://github.com/i18next/i18next-xhr-backend/pull/319)
|
||||
|
||||
### 3.0.0
|
||||
|
||||
- removes deprecated jsnext:main from package.json
|
||||
- Bundle all entry points with rollup [314](https://github.com/i18next/i18next-xhr-backend/pull/314)
|
||||
- **note:** dist/es -> dist/esm, dist/commonjs -> dist/cjs (individual files -> one bundled file)
|
||||
- removes bower finally
|
||||
|
||||
### 2.0.1
|
||||
|
||||
- typescript: fix types [298](https://github.com/i18next/i18next-xhr-backend/pull/298)
|
||||
|
69
node_modules/i18next-xhr-backend/README.md
generated
vendored
69
node_modules/i18next-xhr-backend/README.md
generated
vendored
@@ -6,7 +6,7 @@
|
||||
[]()
|
||||
[](https://david-dm.org/i18next/i18next-xhr-backend)
|
||||
|
||||
This is a simple i18next backend to be used in the browser. It will load resources from a backend server using xhr.
|
||||
This is a simple i18next backend to be used in the browser. It will load resources from a backend server using the xhr API.
|
||||
|
||||
# Getting started
|
||||
|
||||
@@ -26,9 +26,7 @@ Wiring up:
|
||||
import i18next from 'i18next';
|
||||
import XHR from 'i18next-xhr-backend';
|
||||
|
||||
i18next
|
||||
.use(XHR)
|
||||
.init(i18nextOptions);
|
||||
i18next.use(XHR).init(i18nextOptions);
|
||||
```
|
||||
|
||||
- As with all modules you can either pass the constructor function (class) to the i18next.use or a concrete instance.
|
||||
@@ -65,12 +63,24 @@ i18next
|
||||
// here it removes the letter a from the json (bad idea)
|
||||
parse: function(data) { return data.replace(/a/g, ''); },
|
||||
|
||||
//parse data before it has been sent by addPath
|
||||
parsePayload: function(namespace, key, fallbackValue) { return { key } },
|
||||
|
||||
// allow cross domain requests
|
||||
crossDomain: false,
|
||||
|
||||
// allow credentials on cross domain requests
|
||||
withCredentials: false,
|
||||
|
||||
// overrideMimeType sets request.overrideMimeType("application/json")
|
||||
overrideMimeType: false,
|
||||
|
||||
// custom request headers sets request.setRequestHeader(key, value)
|
||||
customHeaders: {
|
||||
authorization: 'foo',
|
||||
// ...
|
||||
},
|
||||
|
||||
// define a custom xhr function
|
||||
// can be used to support XDomainRequest in IE 8 and 9
|
||||
//
|
||||
@@ -96,61 +106,28 @@ Options can be passed in:
|
||||
import i18next from 'i18next';
|
||||
import XHR from 'i18next-xhr-backend';
|
||||
|
||||
i18next
|
||||
.use(XHR)
|
||||
.init({
|
||||
backend: options
|
||||
});
|
||||
i18next.use(XHR).init({
|
||||
backend: options,
|
||||
});
|
||||
```
|
||||
|
||||
on construction:
|
||||
|
||||
```js
|
||||
import XHR from 'i18next-xhr-backend';
|
||||
const xhr = new XHR(null, options);
|
||||
import XHR from 'i18next-xhr-backend';
|
||||
const xhr = new XHR(null, options);
|
||||
```
|
||||
|
||||
via calling init:
|
||||
|
||||
```js
|
||||
import XHR from 'i18next-xhr-backend';
|
||||
const xhr = new XHR();
|
||||
xhr.init(null, options);
|
||||
import XHR from 'i18next-xhr-backend';
|
||||
const xhr = new XHR();
|
||||
xhr.init(null, options);
|
||||
```
|
||||
|
||||
## Misc
|
||||
|
||||
#### Usage with webpack's bundle loader instead of using xhr requests
|
||||
|
||||
To use with webpack, install [bundle-loader](https://github.com/webpack/bundle-loader) and [json-loader](https://github.com/webpack/json-loader).
|
||||
|
||||
Define a custom xhr function, webpack's bundle loader will load the translations for you.
|
||||
|
||||
```js
|
||||
function loadLocales(url, options, callback, data) {
|
||||
try {
|
||||
let waitForLocale = require('bundle!./locales/'+url+'.json');
|
||||
waitForLocale((locale) => {
|
||||
callback(locale, {status: '200'});
|
||||
})
|
||||
} catch (e) {
|
||||
callback(null, {status: '404'});
|
||||
}
|
||||
}
|
||||
|
||||
i18next
|
||||
.use(XHR)
|
||||
.init({
|
||||
backend: {
|
||||
loadPath: '{{lng}}',
|
||||
parse: (data) => data,
|
||||
ajax: loadLocales
|
||||
}
|
||||
}, (err, t) => {
|
||||
// ...
|
||||
});
|
||||
```
|
||||
|
||||
#### TypeScript definitions
|
||||
|
||||
- Install from `@types` (for TypeScript v2 and later):
|
||||
@@ -161,7 +138,7 @@ i18next
|
||||
|
||||
typings install --save --global dt~i18next-xhr-backend
|
||||
|
||||
--------------
|
||||
---
|
||||
|
||||
<h3 align="center">Gold Sponsors</h3>
|
||||
|
||||
|
214
node_modules/i18next-xhr-backend/dist/cjs/i18nextXHRBackend.js
generated
vendored
Normal file
214
node_modules/i18next-xhr-backend/dist/cjs/i18nextXHRBackend.js
generated
vendored
Normal file
@@ -0,0 +1,214 @@
|
||||
'use strict';
|
||||
|
||||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
||||
|
||||
var _classCallCheck = _interopDefault(require('@babel/runtime/helpers/classCallCheck'));
|
||||
var _createClass = _interopDefault(require('@babel/runtime/helpers/createClass'));
|
||||
var _defineProperty = _interopDefault(require('@babel/runtime/helpers/defineProperty'));
|
||||
var _typeof = _interopDefault(require('@babel/runtime/helpers/typeof'));
|
||||
|
||||
var arr = [];
|
||||
var each = arr.forEach;
|
||||
var slice = arr.slice;
|
||||
function defaults(obj) {
|
||||
each.call(slice.call(arguments, 1), function (source) {
|
||||
if (source) {
|
||||
for (var prop in source) {
|
||||
if (obj[prop] === undefined) obj[prop] = source[prop];
|
||||
}
|
||||
}
|
||||
});
|
||||
return obj;
|
||||
}
|
||||
|
||||
function addQueryString(url, params) {
|
||||
if (params && _typeof(params) === 'object') {
|
||||
var queryString = '',
|
||||
e = encodeURIComponent; // Must encode data
|
||||
|
||||
for (var paramName in params) {
|
||||
queryString += '&' + e(paramName) + '=' + e(params[paramName]);
|
||||
}
|
||||
|
||||
if (!queryString) {
|
||||
return url;
|
||||
}
|
||||
|
||||
url = url + (url.indexOf('?') !== -1 ? '&' : '?') + queryString.slice(1);
|
||||
}
|
||||
|
||||
return url;
|
||||
} // https://gist.github.com/Xeoncross/7663273
|
||||
|
||||
|
||||
function ajax(url, options, callback, data, cache) {
|
||||
if (data && _typeof(data) === 'object') {
|
||||
if (!cache) {
|
||||
data['_t'] = new Date();
|
||||
} // URL encoded form data must be in querystring format
|
||||
|
||||
|
||||
data = addQueryString('', data).slice(1);
|
||||
}
|
||||
|
||||
if (options.queryStringParams) {
|
||||
url = addQueryString(url, options.queryStringParams);
|
||||
}
|
||||
|
||||
try {
|
||||
var x;
|
||||
|
||||
if (XMLHttpRequest) {
|
||||
x = new XMLHttpRequest();
|
||||
} else {
|
||||
x = new ActiveXObject('MSXML2.XMLHTTP.3.0');
|
||||
}
|
||||
|
||||
x.open(data ? 'POST' : 'GET', url, 1);
|
||||
|
||||
if (!options.crossDomain) {
|
||||
x.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
||||
}
|
||||
|
||||
x.withCredentials = !!options.withCredentials;
|
||||
|
||||
if (data) {
|
||||
x.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
||||
}
|
||||
|
||||
if (x.overrideMimeType) {
|
||||
x.overrideMimeType("application/json");
|
||||
}
|
||||
|
||||
var h = options.customHeaders;
|
||||
h = typeof h === 'function' ? h() : h;
|
||||
|
||||
if (h) {
|
||||
for (var i in h) {
|
||||
x.setRequestHeader(i, h[i]);
|
||||
}
|
||||
}
|
||||
|
||||
x.onreadystatechange = function () {
|
||||
x.readyState > 3 && callback && callback(x.responseText, x);
|
||||
};
|
||||
|
||||
x.send(data);
|
||||
} catch (e) {
|
||||
console && console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
function getDefaults() {
|
||||
return {
|
||||
loadPath: '/locales/{{lng}}/{{ns}}.json',
|
||||
addPath: '/locales/add/{{lng}}/{{ns}}',
|
||||
allowMultiLoading: false,
|
||||
parse: JSON.parse,
|
||||
parsePayload: function parsePayload(namespace, key, fallbackValue) {
|
||||
return _defineProperty({}, key, fallbackValue || '');
|
||||
},
|
||||
crossDomain: false,
|
||||
ajax: ajax
|
||||
};
|
||||
}
|
||||
|
||||
var Backend =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function Backend(services) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
|
||||
_classCallCheck(this, Backend);
|
||||
|
||||
this.init(services, options);
|
||||
this.type = 'backend';
|
||||
}
|
||||
|
||||
_createClass(Backend, [{
|
||||
key: "init",
|
||||
value: function init(services) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
this.services = services;
|
||||
this.options = defaults(options, this.options || {}, getDefaults());
|
||||
}
|
||||
}, {
|
||||
key: "readMulti",
|
||||
value: function readMulti(languages, namespaces, callback) {
|
||||
var loadPath = this.options.loadPath;
|
||||
|
||||
if (typeof this.options.loadPath === 'function') {
|
||||
loadPath = this.options.loadPath(languages, namespaces);
|
||||
}
|
||||
|
||||
var url = this.services.interpolator.interpolate(loadPath, {
|
||||
lng: languages.join('+'),
|
||||
ns: namespaces.join('+')
|
||||
});
|
||||
this.loadUrl(url, callback);
|
||||
}
|
||||
}, {
|
||||
key: "read",
|
||||
value: function read(language, namespace, callback) {
|
||||
var loadPath = this.options.loadPath;
|
||||
|
||||
if (typeof this.options.loadPath === 'function') {
|
||||
loadPath = this.options.loadPath([language], [namespace]);
|
||||
}
|
||||
|
||||
var url = this.services.interpolator.interpolate(loadPath, {
|
||||
lng: language,
|
||||
ns: namespace
|
||||
});
|
||||
this.loadUrl(url, callback);
|
||||
}
|
||||
}, {
|
||||
key: "loadUrl",
|
||||
value: function loadUrl(url, callback) {
|
||||
var _this = this;
|
||||
|
||||
this.options.ajax(url, this.options, function (data, xhr) {
|
||||
if (xhr.status >= 500 && xhr.status < 600) return callback('failed loading ' + url, true
|
||||
/* retry */
|
||||
);
|
||||
if (xhr.status >= 400 && xhr.status < 500) return callback('failed loading ' + url, false
|
||||
/* no retry */
|
||||
);
|
||||
var ret, err;
|
||||
|
||||
try {
|
||||
ret = _this.options.parse(data, url);
|
||||
} catch (e) {
|
||||
err = 'failed parsing ' + url + ' to json';
|
||||
}
|
||||
|
||||
if (err) return callback(err, false);
|
||||
callback(null, ret);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "create",
|
||||
value: function create(languages, namespace, key, fallbackValue) {
|
||||
var _this2 = this;
|
||||
|
||||
if (typeof languages === 'string') languages = [languages];
|
||||
var payload = this.options.parsePayload(namespace, key, fallbackValue);
|
||||
languages.forEach(function (lng) {
|
||||
var url = _this2.services.interpolator.interpolate(_this2.options.addPath, {
|
||||
lng: lng,
|
||||
ns: namespace
|
||||
});
|
||||
|
||||
_this2.options.ajax(url, _this2.options, function (data, xhr) {//const statusCode = xhr.status.toString();
|
||||
// TODO: if statusCode === 4xx do log
|
||||
}, payload);
|
||||
});
|
||||
}
|
||||
}]);
|
||||
|
||||
return Backend;
|
||||
}();
|
||||
|
||||
Backend.type = 'backend';
|
||||
|
||||
module.exports = Backend;
|
77
node_modules/i18next-xhr-backend/dist/commonjs/ajax.js
generated
vendored
77
node_modules/i18next-xhr-backend/dist/commonjs/ajax.js
generated
vendored
@@ -1,77 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
||||
|
||||
function addQueryString(url, params) {
|
||||
if (params && (typeof params === 'undefined' ? 'undefined' : _typeof(params)) === 'object') {
|
||||
var queryString = '',
|
||||
e = encodeURIComponent;
|
||||
|
||||
// Must encode data
|
||||
for (var paramName in params) {
|
||||
queryString += '&' + e(paramName) + '=' + e(params[paramName]);
|
||||
}
|
||||
|
||||
if (!queryString) {
|
||||
return url;
|
||||
}
|
||||
|
||||
url = url + (url.indexOf('?') !== -1 ? '&' : '?') + queryString.slice(1);
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
// https://gist.github.com/Xeoncross/7663273
|
||||
function ajax(url, options, callback, data, cache) {
|
||||
|
||||
if (data && (typeof data === 'undefined' ? 'undefined' : _typeof(data)) === 'object') {
|
||||
if (!cache) {
|
||||
data['_t'] = new Date();
|
||||
}
|
||||
// URL encoded form data must be in querystring format
|
||||
data = addQueryString('', data).slice(1);
|
||||
}
|
||||
|
||||
if (options.queryStringParams) {
|
||||
url = addQueryString(url, options.queryStringParams);
|
||||
}
|
||||
|
||||
try {
|
||||
var x;
|
||||
if (XMLHttpRequest) {
|
||||
x = new XMLHttpRequest();
|
||||
} else {
|
||||
x = new ActiveXObject('MSXML2.XMLHTTP.3.0');
|
||||
}
|
||||
x.open(data ? 'POST' : 'GET', url, 1);
|
||||
if (!options.crossDomain) {
|
||||
x.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
||||
}
|
||||
x.withCredentials = !!options.withCredentials;
|
||||
if (data) {
|
||||
x.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
||||
}
|
||||
if (x.overrideMimeType) {
|
||||
x.overrideMimeType("application/json");
|
||||
}
|
||||
var h = options.customHeaders;
|
||||
if (h) {
|
||||
for (var i in h) {
|
||||
x.setRequestHeader(i, h[i]);
|
||||
}
|
||||
}
|
||||
x.onreadystatechange = function () {
|
||||
x.readyState > 3 && callback && callback(x.responseText, x);
|
||||
};
|
||||
x.send(data);
|
||||
} catch (e) {
|
||||
console && console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
exports.default = ajax;
|
123
node_modules/i18next-xhr-backend/dist/commonjs/index.js
generated
vendored
123
node_modules/i18next-xhr-backend/dist/commonjs/index.js
generated
vendored
@@ -1,123 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||
|
||||
var _utils = require('./utils.js');
|
||||
|
||||
var utils = _interopRequireWildcard(_utils);
|
||||
|
||||
var _ajax = require('./ajax.js');
|
||||
|
||||
var _ajax2 = _interopRequireDefault(_ajax);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function getDefaults() {
|
||||
return {
|
||||
loadPath: '/locales/{{lng}}/{{ns}}.json',
|
||||
addPath: '/locales/add/{{lng}}/{{ns}}',
|
||||
allowMultiLoading: false,
|
||||
parse: JSON.parse,
|
||||
crossDomain: false,
|
||||
ajax: _ajax2.default
|
||||
};
|
||||
}
|
||||
|
||||
var Backend = function () {
|
||||
function Backend(services) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
|
||||
_classCallCheck(this, Backend);
|
||||
|
||||
this.init(services, options);
|
||||
|
||||
this.type = 'backend';
|
||||
}
|
||||
|
||||
_createClass(Backend, [{
|
||||
key: 'init',
|
||||
value: function init(services) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
|
||||
this.services = services;
|
||||
this.options = utils.defaults(options, this.options || {}, getDefaults());
|
||||
}
|
||||
}, {
|
||||
key: 'readMulti',
|
||||
value: function readMulti(languages, namespaces, callback) {
|
||||
var loadPath = this.options.loadPath;
|
||||
if (typeof this.options.loadPath === 'function') {
|
||||
loadPath = this.options.loadPath(languages, namespaces);
|
||||
}
|
||||
|
||||
var url = this.services.interpolator.interpolate(loadPath, { lng: languages.join('+'), ns: namespaces.join('+') });
|
||||
|
||||
this.loadUrl(url, callback);
|
||||
}
|
||||
}, {
|
||||
key: 'read',
|
||||
value: function read(language, namespace, callback) {
|
||||
var loadPath = this.options.loadPath;
|
||||
if (typeof this.options.loadPath === 'function') {
|
||||
loadPath = this.options.loadPath([language], [namespace]);
|
||||
}
|
||||
|
||||
var url = this.services.interpolator.interpolate(loadPath, { lng: language, ns: namespace });
|
||||
|
||||
this.loadUrl(url, callback);
|
||||
}
|
||||
}, {
|
||||
key: 'loadUrl',
|
||||
value: function loadUrl(url, callback) {
|
||||
var _this = this;
|
||||
|
||||
this.options.ajax(url, this.options, function (data, xhr) {
|
||||
if (xhr.status >= 500 && xhr.status < 600) return callback('failed loading ' + url, true /* retry */);
|
||||
if (xhr.status >= 400 && xhr.status < 500) return callback('failed loading ' + url, false /* no retry */);
|
||||
|
||||
var ret = void 0,
|
||||
err = void 0;
|
||||
try {
|
||||
ret = _this.options.parse(data, url);
|
||||
} catch (e) {
|
||||
err = 'failed parsing ' + url + ' to json';
|
||||
}
|
||||
if (err) return callback(err, false);
|
||||
callback(null, ret);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'create',
|
||||
value: function create(languages, namespace, key, fallbackValue) {
|
||||
var _this2 = this;
|
||||
|
||||
if (typeof languages === 'string') languages = [languages];
|
||||
|
||||
var payload = {};
|
||||
payload[key] = fallbackValue || '';
|
||||
|
||||
languages.forEach(function (lng) {
|
||||
var url = _this2.services.interpolator.interpolate(_this2.options.addPath, { lng: lng, ns: namespace });
|
||||
|
||||
_this2.options.ajax(url, _this2.options, function (data, xhr) {
|
||||
//const statusCode = xhr.status.toString();
|
||||
// TODO: if statusCode === 4xx do log
|
||||
}, payload);
|
||||
});
|
||||
}
|
||||
}]);
|
||||
|
||||
return Backend;
|
||||
}();
|
||||
|
||||
Backend.type = 'backend';
|
||||
|
||||
exports.default = Backend;
|
32
node_modules/i18next-xhr-backend/dist/commonjs/utils.js
generated
vendored
32
node_modules/i18next-xhr-backend/dist/commonjs/utils.js
generated
vendored
@@ -1,32 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.defaults = defaults;
|
||||
exports.extend = extend;
|
||||
var arr = [];
|
||||
var each = arr.forEach;
|
||||
var slice = arr.slice;
|
||||
|
||||
function defaults(obj) {
|
||||
each.call(slice.call(arguments, 1), function (source) {
|
||||
if (source) {
|
||||
for (var prop in source) {
|
||||
if (obj[prop] === undefined) obj[prop] = source[prop];
|
||||
}
|
||||
}
|
||||
});
|
||||
return obj;
|
||||
}
|
||||
|
||||
function extend(obj) {
|
||||
each.call(slice.call(arguments, 1), function (source) {
|
||||
if (source) {
|
||||
for (var prop in source) {
|
||||
obj[prop] = source[prop];
|
||||
}
|
||||
}
|
||||
});
|
||||
return obj;
|
||||
}
|
71
node_modules/i18next-xhr-backend/dist/es/ajax.js
generated
vendored
71
node_modules/i18next-xhr-backend/dist/es/ajax.js
generated
vendored
@@ -1,71 +0,0 @@
|
||||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
||||
|
||||
function addQueryString(url, params) {
|
||||
if (params && (typeof params === 'undefined' ? 'undefined' : _typeof(params)) === 'object') {
|
||||
var queryString = '',
|
||||
e = encodeURIComponent;
|
||||
|
||||
// Must encode data
|
||||
for (var paramName in params) {
|
||||
queryString += '&' + e(paramName) + '=' + e(params[paramName]);
|
||||
}
|
||||
|
||||
if (!queryString) {
|
||||
return url;
|
||||
}
|
||||
|
||||
url = url + (url.indexOf('?') !== -1 ? '&' : '?') + queryString.slice(1);
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
// https://gist.github.com/Xeoncross/7663273
|
||||
function ajax(url, options, callback, data, cache) {
|
||||
|
||||
if (data && (typeof data === 'undefined' ? 'undefined' : _typeof(data)) === 'object') {
|
||||
if (!cache) {
|
||||
data['_t'] = new Date();
|
||||
}
|
||||
// URL encoded form data must be in querystring format
|
||||
data = addQueryString('', data).slice(1);
|
||||
}
|
||||
|
||||
if (options.queryStringParams) {
|
||||
url = addQueryString(url, options.queryStringParams);
|
||||
}
|
||||
|
||||
try {
|
||||
var x;
|
||||
if (XMLHttpRequest) {
|
||||
x = new XMLHttpRequest();
|
||||
} else {
|
||||
x = new ActiveXObject('MSXML2.XMLHTTP.3.0');
|
||||
}
|
||||
x.open(data ? 'POST' : 'GET', url, 1);
|
||||
if (!options.crossDomain) {
|
||||
x.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
||||
}
|
||||
x.withCredentials = !!options.withCredentials;
|
||||
if (data) {
|
||||
x.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
||||
}
|
||||
if (x.overrideMimeType) {
|
||||
x.overrideMimeType("application/json");
|
||||
}
|
||||
var h = options.customHeaders;
|
||||
if (h) {
|
||||
for (var i in h) {
|
||||
x.setRequestHeader(i, h[i]);
|
||||
}
|
||||
}
|
||||
x.onreadystatechange = function () {
|
||||
x.readyState > 3 && callback && callback(x.responseText, x);
|
||||
};
|
||||
x.send(data);
|
||||
} catch (e) {
|
||||
console && console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
export default ajax;
|
108
node_modules/i18next-xhr-backend/dist/es/index.js
generated
vendored
108
node_modules/i18next-xhr-backend/dist/es/index.js
generated
vendored
@@ -1,108 +0,0 @@
|
||||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
import * as utils from './utils.js';
|
||||
import ajax from './ajax.js';
|
||||
|
||||
function getDefaults() {
|
||||
return {
|
||||
loadPath: '/locales/{{lng}}/{{ns}}.json',
|
||||
addPath: '/locales/add/{{lng}}/{{ns}}',
|
||||
allowMultiLoading: false,
|
||||
parse: JSON.parse,
|
||||
crossDomain: false,
|
||||
ajax: ajax
|
||||
};
|
||||
}
|
||||
|
||||
var Backend = function () {
|
||||
function Backend(services) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
|
||||
_classCallCheck(this, Backend);
|
||||
|
||||
this.init(services, options);
|
||||
|
||||
this.type = 'backend';
|
||||
}
|
||||
|
||||
_createClass(Backend, [{
|
||||
key: 'init',
|
||||
value: function init(services) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
|
||||
this.services = services;
|
||||
this.options = utils.defaults(options, this.options || {}, getDefaults());
|
||||
}
|
||||
}, {
|
||||
key: 'readMulti',
|
||||
value: function readMulti(languages, namespaces, callback) {
|
||||
var loadPath = this.options.loadPath;
|
||||
if (typeof this.options.loadPath === 'function') {
|
||||
loadPath = this.options.loadPath(languages, namespaces);
|
||||
}
|
||||
|
||||
var url = this.services.interpolator.interpolate(loadPath, { lng: languages.join('+'), ns: namespaces.join('+') });
|
||||
|
||||
this.loadUrl(url, callback);
|
||||
}
|
||||
}, {
|
||||
key: 'read',
|
||||
value: function read(language, namespace, callback) {
|
||||
var loadPath = this.options.loadPath;
|
||||
if (typeof this.options.loadPath === 'function') {
|
||||
loadPath = this.options.loadPath([language], [namespace]);
|
||||
}
|
||||
|
||||
var url = this.services.interpolator.interpolate(loadPath, { lng: language, ns: namespace });
|
||||
|
||||
this.loadUrl(url, callback);
|
||||
}
|
||||
}, {
|
||||
key: 'loadUrl',
|
||||
value: function loadUrl(url, callback) {
|
||||
var _this = this;
|
||||
|
||||
this.options.ajax(url, this.options, function (data, xhr) {
|
||||
if (xhr.status >= 500 && xhr.status < 600) return callback('failed loading ' + url, true /* retry */);
|
||||
if (xhr.status >= 400 && xhr.status < 500) return callback('failed loading ' + url, false /* no retry */);
|
||||
|
||||
var ret = void 0,
|
||||
err = void 0;
|
||||
try {
|
||||
ret = _this.options.parse(data, url);
|
||||
} catch (e) {
|
||||
err = 'failed parsing ' + url + ' to json';
|
||||
}
|
||||
if (err) return callback(err, false);
|
||||
callback(null, ret);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'create',
|
||||
value: function create(languages, namespace, key, fallbackValue) {
|
||||
var _this2 = this;
|
||||
|
||||
if (typeof languages === 'string') languages = [languages];
|
||||
|
||||
var payload = {};
|
||||
payload[key] = fallbackValue || '';
|
||||
|
||||
languages.forEach(function (lng) {
|
||||
var url = _this2.services.interpolator.interpolate(_this2.options.addPath, { lng: lng, ns: namespace });
|
||||
|
||||
_this2.options.ajax(url, _this2.options, function (data, xhr) {
|
||||
//const statusCode = xhr.status.toString();
|
||||
// TODO: if statusCode === 4xx do log
|
||||
}, payload);
|
||||
});
|
||||
}
|
||||
}]);
|
||||
|
||||
return Backend;
|
||||
}();
|
||||
|
||||
Backend.type = 'backend';
|
||||
|
||||
export default Backend;
|
25
node_modules/i18next-xhr-backend/dist/es/utils.js
generated
vendored
25
node_modules/i18next-xhr-backend/dist/es/utils.js
generated
vendored
@@ -1,25 +0,0 @@
|
||||
var arr = [];
|
||||
var each = arr.forEach;
|
||||
var slice = arr.slice;
|
||||
|
||||
export function defaults(obj) {
|
||||
each.call(slice.call(arguments, 1), function (source) {
|
||||
if (source) {
|
||||
for (var prop in source) {
|
||||
if (obj[prop] === undefined) obj[prop] = source[prop];
|
||||
}
|
||||
}
|
||||
});
|
||||
return obj;
|
||||
}
|
||||
|
||||
export function extend(obj) {
|
||||
each.call(slice.call(arguments, 1), function (source) {
|
||||
if (source) {
|
||||
for (var prop in source) {
|
||||
obj[prop] = source[prop];
|
||||
}
|
||||
}
|
||||
});
|
||||
return obj;
|
||||
}
|
210
node_modules/i18next-xhr-backend/dist/esm/i18nextXHRBackend.js
generated
vendored
Normal file
210
node_modules/i18next-xhr-backend/dist/esm/i18nextXHRBackend.js
generated
vendored
Normal file
@@ -0,0 +1,210 @@
|
||||
import _classCallCheck from '@babel/runtime/helpers/esm/classCallCheck';
|
||||
import _createClass from '@babel/runtime/helpers/esm/createClass';
|
||||
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
||||
import _typeof from '@babel/runtime/helpers/esm/typeof';
|
||||
|
||||
var arr = [];
|
||||
var each = arr.forEach;
|
||||
var slice = arr.slice;
|
||||
function defaults(obj) {
|
||||
each.call(slice.call(arguments, 1), function (source) {
|
||||
if (source) {
|
||||
for (var prop in source) {
|
||||
if (obj[prop] === undefined) obj[prop] = source[prop];
|
||||
}
|
||||
}
|
||||
});
|
||||
return obj;
|
||||
}
|
||||
|
||||
function addQueryString(url, params) {
|
||||
if (params && _typeof(params) === 'object') {
|
||||
var queryString = '',
|
||||
e = encodeURIComponent; // Must encode data
|
||||
|
||||
for (var paramName in params) {
|
||||
queryString += '&' + e(paramName) + '=' + e(params[paramName]);
|
||||
}
|
||||
|
||||
if (!queryString) {
|
||||
return url;
|
||||
}
|
||||
|
||||
url = url + (url.indexOf('?') !== -1 ? '&' : '?') + queryString.slice(1);
|
||||
}
|
||||
|
||||
return url;
|
||||
} // https://gist.github.com/Xeoncross/7663273
|
||||
|
||||
|
||||
function ajax(url, options, callback, data, cache) {
|
||||
if (data && _typeof(data) === 'object') {
|
||||
if (!cache) {
|
||||
data['_t'] = new Date();
|
||||
} // URL encoded form data must be in querystring format
|
||||
|
||||
|
||||
data = addQueryString('', data).slice(1);
|
||||
}
|
||||
|
||||
if (options.queryStringParams) {
|
||||
url = addQueryString(url, options.queryStringParams);
|
||||
}
|
||||
|
||||
try {
|
||||
var x;
|
||||
|
||||
if (XMLHttpRequest) {
|
||||
x = new XMLHttpRequest();
|
||||
} else {
|
||||
x = new ActiveXObject('MSXML2.XMLHTTP.3.0');
|
||||
}
|
||||
|
||||
x.open(data ? 'POST' : 'GET', url, 1);
|
||||
|
||||
if (!options.crossDomain) {
|
||||
x.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
||||
}
|
||||
|
||||
x.withCredentials = !!options.withCredentials;
|
||||
|
||||
if (data) {
|
||||
x.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
||||
}
|
||||
|
||||
if (x.overrideMimeType) {
|
||||
x.overrideMimeType("application/json");
|
||||
}
|
||||
|
||||
var h = options.customHeaders;
|
||||
h = typeof h === 'function' ? h() : h;
|
||||
|
||||
if (h) {
|
||||
for (var i in h) {
|
||||
x.setRequestHeader(i, h[i]);
|
||||
}
|
||||
}
|
||||
|
||||
x.onreadystatechange = function () {
|
||||
x.readyState > 3 && callback && callback(x.responseText, x);
|
||||
};
|
||||
|
||||
x.send(data);
|
||||
} catch (e) {
|
||||
console && console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
function getDefaults() {
|
||||
return {
|
||||
loadPath: '/locales/{{lng}}/{{ns}}.json',
|
||||
addPath: '/locales/add/{{lng}}/{{ns}}',
|
||||
allowMultiLoading: false,
|
||||
parse: JSON.parse,
|
||||
parsePayload: function parsePayload(namespace, key, fallbackValue) {
|
||||
return _defineProperty({}, key, fallbackValue || '');
|
||||
},
|
||||
crossDomain: false,
|
||||
ajax: ajax
|
||||
};
|
||||
}
|
||||
|
||||
var Backend =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function Backend(services) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
|
||||
_classCallCheck(this, Backend);
|
||||
|
||||
this.init(services, options);
|
||||
this.type = 'backend';
|
||||
}
|
||||
|
||||
_createClass(Backend, [{
|
||||
key: "init",
|
||||
value: function init(services) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
this.services = services;
|
||||
this.options = defaults(options, this.options || {}, getDefaults());
|
||||
}
|
||||
}, {
|
||||
key: "readMulti",
|
||||
value: function readMulti(languages, namespaces, callback) {
|
||||
var loadPath = this.options.loadPath;
|
||||
|
||||
if (typeof this.options.loadPath === 'function') {
|
||||
loadPath = this.options.loadPath(languages, namespaces);
|
||||
}
|
||||
|
||||
var url = this.services.interpolator.interpolate(loadPath, {
|
||||
lng: languages.join('+'),
|
||||
ns: namespaces.join('+')
|
||||
});
|
||||
this.loadUrl(url, callback);
|
||||
}
|
||||
}, {
|
||||
key: "read",
|
||||
value: function read(language, namespace, callback) {
|
||||
var loadPath = this.options.loadPath;
|
||||
|
||||
if (typeof this.options.loadPath === 'function') {
|
||||
loadPath = this.options.loadPath([language], [namespace]);
|
||||
}
|
||||
|
||||
var url = this.services.interpolator.interpolate(loadPath, {
|
||||
lng: language,
|
||||
ns: namespace
|
||||
});
|
||||
this.loadUrl(url, callback);
|
||||
}
|
||||
}, {
|
||||
key: "loadUrl",
|
||||
value: function loadUrl(url, callback) {
|
||||
var _this = this;
|
||||
|
||||
this.options.ajax(url, this.options, function (data, xhr) {
|
||||
if (xhr.status >= 500 && xhr.status < 600) return callback('failed loading ' + url, true
|
||||
/* retry */
|
||||
);
|
||||
if (xhr.status >= 400 && xhr.status < 500) return callback('failed loading ' + url, false
|
||||
/* no retry */
|
||||
);
|
||||
var ret, err;
|
||||
|
||||
try {
|
||||
ret = _this.options.parse(data, url);
|
||||
} catch (e) {
|
||||
err = 'failed parsing ' + url + ' to json';
|
||||
}
|
||||
|
||||
if (err) return callback(err, false);
|
||||
callback(null, ret);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "create",
|
||||
value: function create(languages, namespace, key, fallbackValue) {
|
||||
var _this2 = this;
|
||||
|
||||
if (typeof languages === 'string') languages = [languages];
|
||||
var payload = this.options.parsePayload(namespace, key, fallbackValue);
|
||||
languages.forEach(function (lng) {
|
||||
var url = _this2.services.interpolator.interpolate(_this2.options.addPath, {
|
||||
lng: lng,
|
||||
ns: namespace
|
||||
});
|
||||
|
||||
_this2.options.ajax(url, _this2.options, function (data, xhr) {//const statusCode = xhr.status.toString();
|
||||
// TODO: if statusCode === 4xx do log
|
||||
}, payload);
|
||||
});
|
||||
}
|
||||
}]);
|
||||
|
||||
return Backend;
|
||||
}();
|
||||
|
||||
Backend.type = 'backend';
|
||||
|
||||
export default Backend;
|
396
node_modules/i18next-xhr-backend/dist/umd/i18nextXHRBackend.js
generated
vendored
396
node_modules/i18next-xhr-backend/dist/umd/i18nextXHRBackend.js
generated
vendored
@@ -1,198 +1,266 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||
typeof define === 'function' && define.amd ? define(factory) :
|
||||
(global.i18nextXHRBackend = factory());
|
||||
(global = global || self, global.i18nextXHRBackend = factory());
|
||||
}(this, (function () { 'use strict';
|
||||
|
||||
var arr = [];
|
||||
var each = arr.forEach;
|
||||
var slice = arr.slice;
|
||||
|
||||
function defaults(obj) {
|
||||
each.call(slice.call(arguments, 1), function (source) {
|
||||
if (source) {
|
||||
for (var prop in source) {
|
||||
if (obj[prop] === undefined) obj[prop] = source[prop];
|
||||
}
|
||||
function _classCallCheck(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
throw new TypeError("Cannot call a class as a function");
|
||||
}
|
||||
});
|
||||
return obj;
|
||||
}
|
||||
|
||||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
||||
|
||||
function addQueryString(url, params) {
|
||||
if (params && (typeof params === 'undefined' ? 'undefined' : _typeof(params)) === 'object') {
|
||||
var queryString = '',
|
||||
e = encodeURIComponent;
|
||||
|
||||
// Must encode data
|
||||
for (var paramName in params) {
|
||||
queryString += '&' + e(paramName) + '=' + e(params[paramName]);
|
||||
}
|
||||
|
||||
if (!queryString) {
|
||||
return url;
|
||||
}
|
||||
|
||||
url = url + (url.indexOf('?') !== -1 ? '&' : '?') + queryString.slice(1);
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
// https://gist.github.com/Xeoncross/7663273
|
||||
function ajax(url, options, callback, data, cache) {
|
||||
|
||||
if (data && (typeof data === 'undefined' ? 'undefined' : _typeof(data)) === 'object') {
|
||||
if (!cache) {
|
||||
data['_t'] = new Date();
|
||||
function _defineProperties(target, props) {
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
var descriptor = props[i];
|
||||
descriptor.enumerable = descriptor.enumerable || false;
|
||||
descriptor.configurable = true;
|
||||
if ("value" in descriptor) descriptor.writable = true;
|
||||
Object.defineProperty(target, descriptor.key, descriptor);
|
||||
}
|
||||
// URL encoded form data must be in querystring format
|
||||
data = addQueryString('', data).slice(1);
|
||||
}
|
||||
|
||||
if (options.queryStringParams) {
|
||||
url = addQueryString(url, options.queryStringParams);
|
||||
function _createClass(Constructor, protoProps, staticProps) {
|
||||
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
||||
if (staticProps) _defineProperties(Constructor, staticProps);
|
||||
return Constructor;
|
||||
}
|
||||
|
||||
try {
|
||||
var x;
|
||||
if (XMLHttpRequest) {
|
||||
x = new XMLHttpRequest();
|
||||
function _defineProperty(obj, key, value) {
|
||||
if (key in obj) {
|
||||
Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
x = new ActiveXObject('MSXML2.XMLHTTP.3.0');
|
||||
obj[key] = value;
|
||||
}
|
||||
x.open(data ? 'POST' : 'GET', url, 1);
|
||||
if (!options.crossDomain) {
|
||||
x.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
||||
}
|
||||
x.withCredentials = !!options.withCredentials;
|
||||
if (data) {
|
||||
x.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
||||
}
|
||||
if (x.overrideMimeType) {
|
||||
x.overrideMimeType("application/json");
|
||||
}
|
||||
var h = options.customHeaders;
|
||||
if (h) {
|
||||
for (var i in h) {
|
||||
x.setRequestHeader(i, h[i]);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
var arr = [];
|
||||
var each = arr.forEach;
|
||||
var slice = arr.slice;
|
||||
function defaults(obj) {
|
||||
each.call(slice.call(arguments, 1), function (source) {
|
||||
if (source) {
|
||||
for (var prop in source) {
|
||||
if (obj[prop] === undefined) obj[prop] = source[prop];
|
||||
}
|
||||
}
|
||||
});
|
||||
return obj;
|
||||
}
|
||||
|
||||
function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); }
|
||||
|
||||
function _typeof(obj) {
|
||||
if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") {
|
||||
_typeof = function _typeof(obj) {
|
||||
return _typeof2(obj);
|
||||
};
|
||||
} else {
|
||||
_typeof = function _typeof(obj) {
|
||||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj);
|
||||
};
|
||||
}
|
||||
x.onreadystatechange = function () {
|
||||
x.readyState > 3 && callback && callback(x.responseText, x);
|
||||
|
||||
return _typeof(obj);
|
||||
}
|
||||
|
||||
function addQueryString(url, params) {
|
||||
if (params && _typeof(params) === 'object') {
|
||||
var queryString = '',
|
||||
e = encodeURIComponent; // Must encode data
|
||||
|
||||
for (var paramName in params) {
|
||||
queryString += '&' + e(paramName) + '=' + e(params[paramName]);
|
||||
}
|
||||
|
||||
if (!queryString) {
|
||||
return url;
|
||||
}
|
||||
|
||||
url = url + (url.indexOf('?') !== -1 ? '&' : '?') + queryString.slice(1);
|
||||
}
|
||||
|
||||
return url;
|
||||
} // https://gist.github.com/Xeoncross/7663273
|
||||
|
||||
|
||||
function ajax(url, options, callback, data, cache) {
|
||||
if (data && _typeof(data) === 'object') {
|
||||
if (!cache) {
|
||||
data['_t'] = new Date();
|
||||
} // URL encoded form data must be in querystring format
|
||||
|
||||
|
||||
data = addQueryString('', data).slice(1);
|
||||
}
|
||||
|
||||
if (options.queryStringParams) {
|
||||
url = addQueryString(url, options.queryStringParams);
|
||||
}
|
||||
|
||||
try {
|
||||
var x;
|
||||
|
||||
if (XMLHttpRequest) {
|
||||
x = new XMLHttpRequest();
|
||||
} else {
|
||||
x = new ActiveXObject('MSXML2.XMLHTTP.3.0');
|
||||
}
|
||||
|
||||
x.open(data ? 'POST' : 'GET', url, 1);
|
||||
|
||||
if (!options.crossDomain) {
|
||||
x.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
||||
}
|
||||
|
||||
x.withCredentials = !!options.withCredentials;
|
||||
|
||||
if (data) {
|
||||
x.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
||||
}
|
||||
|
||||
if (x.overrideMimeType) {
|
||||
x.overrideMimeType("application/json");
|
||||
}
|
||||
|
||||
var h = options.customHeaders;
|
||||
h = typeof h === 'function' ? h() : h;
|
||||
|
||||
if (h) {
|
||||
for (var i in h) {
|
||||
x.setRequestHeader(i, h[i]);
|
||||
}
|
||||
}
|
||||
|
||||
x.onreadystatechange = function () {
|
||||
x.readyState > 3 && callback && callback(x.responseText, x);
|
||||
};
|
||||
|
||||
x.send(data);
|
||||
} catch (e) {
|
||||
console && console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
function getDefaults() {
|
||||
return {
|
||||
loadPath: '/locales/{{lng}}/{{ns}}.json',
|
||||
addPath: '/locales/add/{{lng}}/{{ns}}',
|
||||
allowMultiLoading: false,
|
||||
parse: JSON.parse,
|
||||
parsePayload: function parsePayload(namespace, key, fallbackValue) {
|
||||
return _defineProperty({}, key, fallbackValue || '');
|
||||
},
|
||||
crossDomain: false,
|
||||
ajax: ajax
|
||||
};
|
||||
x.send(data);
|
||||
} catch (e) {
|
||||
console && console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function getDefaults() {
|
||||
return {
|
||||
loadPath: '/locales/{{lng}}/{{ns}}.json',
|
||||
addPath: '/locales/add/{{lng}}/{{ns}}',
|
||||
allowMultiLoading: false,
|
||||
parse: JSON.parse,
|
||||
crossDomain: false,
|
||||
ajax: ajax
|
||||
};
|
||||
}
|
||||
|
||||
var Backend = function () {
|
||||
function Backend(services) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
|
||||
_classCallCheck(this, Backend);
|
||||
|
||||
this.init(services, options);
|
||||
|
||||
this.type = 'backend';
|
||||
}
|
||||
|
||||
_createClass(Backend, [{
|
||||
key: 'init',
|
||||
value: function init(services) {
|
||||
var Backend =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function Backend(services) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
|
||||
this.services = services;
|
||||
this.options = defaults(options, this.options || {}, getDefaults());
|
||||
_classCallCheck(this, Backend);
|
||||
|
||||
this.init(services, options);
|
||||
this.type = 'backend';
|
||||
}
|
||||
}, {
|
||||
key: 'readMulti',
|
||||
value: function readMulti(languages, namespaces, callback) {
|
||||
var loadPath = this.options.loadPath;
|
||||
if (typeof this.options.loadPath === 'function') {
|
||||
loadPath = this.options.loadPath(languages, namespaces);
|
||||
|
||||
_createClass(Backend, [{
|
||||
key: "init",
|
||||
value: function init(services) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
this.services = services;
|
||||
this.options = defaults(options, this.options || {}, getDefaults());
|
||||
}
|
||||
}, {
|
||||
key: "readMulti",
|
||||
value: function readMulti(languages, namespaces, callback) {
|
||||
var loadPath = this.options.loadPath;
|
||||
|
||||
var url = this.services.interpolator.interpolate(loadPath, { lng: languages.join('+'), ns: namespaces.join('+') });
|
||||
|
||||
this.loadUrl(url, callback);
|
||||
}
|
||||
}, {
|
||||
key: 'read',
|
||||
value: function read(language, namespace, callback) {
|
||||
var loadPath = this.options.loadPath;
|
||||
if (typeof this.options.loadPath === 'function') {
|
||||
loadPath = this.options.loadPath([language], [namespace]);
|
||||
}
|
||||
|
||||
var url = this.services.interpolator.interpolate(loadPath, { lng: language, ns: namespace });
|
||||
|
||||
this.loadUrl(url, callback);
|
||||
}
|
||||
}, {
|
||||
key: 'loadUrl',
|
||||
value: function loadUrl(url, callback) {
|
||||
var _this = this;
|
||||
|
||||
this.options.ajax(url, this.options, function (data, xhr) {
|
||||
if (xhr.status >= 500 && xhr.status < 600) return callback('failed loading ' + url, true /* retry */);
|
||||
if (xhr.status >= 400 && xhr.status < 500) return callback('failed loading ' + url, false /* no retry */);
|
||||
|
||||
var ret = void 0,
|
||||
err = void 0;
|
||||
try {
|
||||
ret = _this.options.parse(data, url);
|
||||
} catch (e) {
|
||||
err = 'failed parsing ' + url + ' to json';
|
||||
if (typeof this.options.loadPath === 'function') {
|
||||
loadPath = this.options.loadPath(languages, namespaces);
|
||||
}
|
||||
if (err) return callback(err, false);
|
||||
callback(null, ret);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'create',
|
||||
value: function create(languages, namespace, key, fallbackValue) {
|
||||
var _this2 = this;
|
||||
|
||||
if (typeof languages === 'string') languages = [languages];
|
||||
var url = this.services.interpolator.interpolate(loadPath, {
|
||||
lng: languages.join('+'),
|
||||
ns: namespaces.join('+')
|
||||
});
|
||||
this.loadUrl(url, callback);
|
||||
}
|
||||
}, {
|
||||
key: "read",
|
||||
value: function read(language, namespace, callback) {
|
||||
var loadPath = this.options.loadPath;
|
||||
|
||||
var payload = {};
|
||||
payload[key] = fallbackValue || '';
|
||||
if (typeof this.options.loadPath === 'function') {
|
||||
loadPath = this.options.loadPath([language], [namespace]);
|
||||
}
|
||||
|
||||
languages.forEach(function (lng) {
|
||||
var url = _this2.services.interpolator.interpolate(_this2.options.addPath, { lng: lng, ns: namespace });
|
||||
var url = this.services.interpolator.interpolate(loadPath, {
|
||||
lng: language,
|
||||
ns: namespace
|
||||
});
|
||||
this.loadUrl(url, callback);
|
||||
}
|
||||
}, {
|
||||
key: "loadUrl",
|
||||
value: function loadUrl(url, callback) {
|
||||
var _this = this;
|
||||
|
||||
_this2.options.ajax(url, _this2.options, function (data, xhr) {
|
||||
//const statusCode = xhr.status.toString();
|
||||
// TODO: if statusCode === 4xx do log
|
||||
}, payload);
|
||||
});
|
||||
}
|
||||
}]);
|
||||
this.options.ajax(url, this.options, function (data, xhr) {
|
||||
if (xhr.status >= 500 && xhr.status < 600) return callback('failed loading ' + url, true
|
||||
/* retry */
|
||||
);
|
||||
if (xhr.status >= 400 && xhr.status < 500) return callback('failed loading ' + url, false
|
||||
/* no retry */
|
||||
);
|
||||
var ret, err;
|
||||
|
||||
try {
|
||||
ret = _this.options.parse(data, url);
|
||||
} catch (e) {
|
||||
err = 'failed parsing ' + url + ' to json';
|
||||
}
|
||||
|
||||
if (err) return callback(err, false);
|
||||
callback(null, ret);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "create",
|
||||
value: function create(languages, namespace, key, fallbackValue) {
|
||||
var _this2 = this;
|
||||
|
||||
if (typeof languages === 'string') languages = [languages];
|
||||
var payload = this.options.parsePayload(namespace, key, fallbackValue);
|
||||
languages.forEach(function (lng) {
|
||||
var url = _this2.services.interpolator.interpolate(_this2.options.addPath, {
|
||||
lng: lng,
|
||||
ns: namespace
|
||||
});
|
||||
|
||||
_this2.options.ajax(url, _this2.options, function (data, xhr) {//const statusCode = xhr.status.toString();
|
||||
// TODO: if statusCode === 4xx do log
|
||||
}, payload);
|
||||
});
|
||||
}
|
||||
}]);
|
||||
|
||||
return Backend;
|
||||
}();
|
||||
|
||||
Backend.type = 'backend';
|
||||
|
||||
return Backend;
|
||||
}();
|
||||
|
||||
Backend.type = 'backend';
|
||||
|
||||
return Backend;
|
||||
|
||||
})));
|
||||
|
2
node_modules/i18next-xhr-backend/dist/umd/i18nextXHRBackend.min.js
generated
vendored
2
node_modules/i18next-xhr-backend/dist/umd/i18nextXHRBackend.min.js
generated
vendored
@@ -1 +1 @@
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.i18nextXHRBackend=e()}(this,function(){"use strict";function t(t){return r.call(s.call(arguments,1),function(e){if(e)for(var n in e)void 0===t[n]&&(t[n]=e[n])}),t}function e(t,e){if(e&&"object"===(void 0===e?"undefined":l(e))){var n="",o=encodeURIComponent;for(var i in e)n+="&"+o(i)+"="+o(e[i]);if(!n)return t;t=t+(-1!==t.indexOf("?")?"&":"?")+n.slice(1)}return t}function n(t,n,o,i,a){i&&"object"===(void 0===i?"undefined":l(i))&&(a||(i._t=new Date),i=e("",i).slice(1)),n.queryStringParams&&(t=e(t,n.queryStringParams));try{var r;r=XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("MSXML2.XMLHTTP.3.0"),r.open(i?"POST":"GET",t,1),n.crossDomain||r.setRequestHeader("X-Requested-With","XMLHttpRequest"),r.withCredentials=!!n.withCredentials,i&&r.setRequestHeader("Content-type","application/x-www-form-urlencoded"),r.overrideMimeType&&r.overrideMimeType("application/json");var s=n.customHeaders;if(s)for(var u in s)r.setRequestHeader(u,s[u]);r.onreadystatechange=function(){r.readyState>3&&o&&o(r.responseText,r)},r.send(i)}catch(t){console&&console.log(t)}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(){return{loadPath:"/locales/{{lng}}/{{ns}}.json",addPath:"/locales/add/{{lng}}/{{ns}}",allowMultiLoading:!1,parse:JSON.parse,crossDomain:!1,ajax:n}}var a=[],r=a.forEach,s=a.slice,l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),c=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};o(this,e),this.init(t,n),this.type="backend"}return u(e,[{key:"init",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.services=e,this.options=t(n,this.options||{},i())}},{key:"readMulti",value:function(t,e,n){var o=this.options.loadPath;"function"==typeof this.options.loadPath&&(o=this.options.loadPath(t,e));var i=this.services.interpolator.interpolate(o,{lng:t.join("+"),ns:e.join("+")});this.loadUrl(i,n)}},{key:"read",value:function(t,e,n){var o=this.options.loadPath;"function"==typeof this.options.loadPath&&(o=this.options.loadPath([t],[e]));var i=this.services.interpolator.interpolate(o,{lng:t,ns:e});this.loadUrl(i,n)}},{key:"loadUrl",value:function(t,e){var n=this;this.options.ajax(t,this.options,function(o,i){if(i.status>=500&&i.status<600)return e("failed loading "+t,!0);if(i.status>=400&&i.status<500)return e("failed loading "+t,!1);var a=void 0,r=void 0;try{a=n.options.parse(o,t)}catch(e){r="failed parsing "+t+" to json"}if(r)return e(r,!1);e(null,a)})}},{key:"create",value:function(t,e,n,o){var i=this;"string"==typeof t&&(t=[t]);var a={};a[n]=o||"",t.forEach(function(t){var n=i.services.interpolator.interpolate(i.options.addPath,{lng:t,ns:e});i.options.ajax(n,i.options,function(t,e){},a)})}}]),e}();return c.type="backend",c});
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).i18nextXHRBackend=e()}(this,(function(){"use strict";function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}var e=[],n=e.forEach,o=e.slice;function i(t){return n.call(o.call(arguments,1),(function(e){if(e)for(var n in e)void 0===t[n]&&(t[n]=e[n])})),t}function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function a(t){return(a="function"==typeof Symbol&&"symbol"===r(Symbol.iterator)?function(t){return r(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":r(t)})(t)}function s(t,e){if(e&&"object"===a(e)){var n="",o=encodeURIComponent;for(var i in e)n+="&"+o(i)+"="+o(e[i]);if(!n)return t;t=t+(-1!==t.indexOf("?")?"&":"?")+n.slice(1)}return t}function l(t,e,n,o,i){o&&"object"===a(o)&&(i||(o._t=new Date),o=s("",o).slice(1)),e.queryStringParams&&(t=s(t,e.queryStringParams));try{var r;(r=XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("MSXML2.XMLHTTP.3.0")).open(o?"POST":"GET",t,1),e.crossDomain||r.setRequestHeader("X-Requested-With","XMLHttpRequest"),r.withCredentials=!!e.withCredentials,o&&r.setRequestHeader("Content-type","application/x-www-form-urlencoded"),r.overrideMimeType&&r.overrideMimeType("application/json");var l=e.customHeaders;if(l="function"==typeof l?l():l)for(var u in l)r.setRequestHeader(u,l[u]);r.onreadystatechange=function(){r.readyState>3&&n&&n(r.responseText,r)},r.send(o)}catch(t){console&&console.log(t)}}function u(){return{loadPath:"/locales/{{lng}}/{{ns}}.json",addPath:"/locales/add/{{lng}}/{{ns}}",allowMultiLoading:!1,parse:JSON.parse,parsePayload:function(t,e,n){return function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}({},e,n||"")},crossDomain:!1,ajax:l}}var c=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),this.init(t,n),this.type="backend"}var n,o,r;return n=e,(o=[{key:"init",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.services=t,this.options=i(e,this.options||{},u())}},{key:"readMulti",value:function(t,e,n){var o=this.options.loadPath;"function"==typeof this.options.loadPath&&(o=this.options.loadPath(t,e));var i=this.services.interpolator.interpolate(o,{lng:t.join("+"),ns:e.join("+")});this.loadUrl(i,n)}},{key:"read",value:function(t,e,n){var o=this.options.loadPath;"function"==typeof this.options.loadPath&&(o=this.options.loadPath([t],[e]));var i=this.services.interpolator.interpolate(o,{lng:t,ns:e});this.loadUrl(i,n)}},{key:"loadUrl",value:function(t,e){var n=this;this.options.ajax(t,this.options,(function(o,i){if(i.status>=500&&i.status<600)return e("failed loading "+t,!0);if(i.status>=400&&i.status<500)return e("failed loading "+t,!1);var r,a;try{r=n.options.parse(o,t)}catch(e){a="failed parsing "+t+" to json"}if(a)return e(a,!1);e(null,r)}))}},{key:"create",value:function(t,e,n,o){var i=this;"string"==typeof t&&(t=[t]);var r=this.options.parsePayload(e,n,o);t.forEach((function(t){var n=i.services.interpolator.interpolate(i.options.addPath,{lng:t,ns:e});i.options.ajax(n,i.options,(function(t,e){}),r)}))}}])&&t(n.prototype,o),r&&t(n,r),e}();return c.type="backend",c}));
|
||||
|
396
node_modules/i18next-xhr-backend/i18nextXHRBackend.js
generated
vendored
396
node_modules/i18next-xhr-backend/i18nextXHRBackend.js
generated
vendored
@@ -1,198 +1,266 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||
typeof define === 'function' && define.amd ? define(factory) :
|
||||
(global.i18nextXHRBackend = factory());
|
||||
(global = global || self, global.i18nextXHRBackend = factory());
|
||||
}(this, (function () { 'use strict';
|
||||
|
||||
var arr = [];
|
||||
var each = arr.forEach;
|
||||
var slice = arr.slice;
|
||||
|
||||
function defaults(obj) {
|
||||
each.call(slice.call(arguments, 1), function (source) {
|
||||
if (source) {
|
||||
for (var prop in source) {
|
||||
if (obj[prop] === undefined) obj[prop] = source[prop];
|
||||
}
|
||||
function _classCallCheck(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
throw new TypeError("Cannot call a class as a function");
|
||||
}
|
||||
});
|
||||
return obj;
|
||||
}
|
||||
|
||||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
||||
|
||||
function addQueryString(url, params) {
|
||||
if (params && (typeof params === 'undefined' ? 'undefined' : _typeof(params)) === 'object') {
|
||||
var queryString = '',
|
||||
e = encodeURIComponent;
|
||||
|
||||
// Must encode data
|
||||
for (var paramName in params) {
|
||||
queryString += '&' + e(paramName) + '=' + e(params[paramName]);
|
||||
}
|
||||
|
||||
if (!queryString) {
|
||||
return url;
|
||||
}
|
||||
|
||||
url = url + (url.indexOf('?') !== -1 ? '&' : '?') + queryString.slice(1);
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
// https://gist.github.com/Xeoncross/7663273
|
||||
function ajax(url, options, callback, data, cache) {
|
||||
|
||||
if (data && (typeof data === 'undefined' ? 'undefined' : _typeof(data)) === 'object') {
|
||||
if (!cache) {
|
||||
data['_t'] = new Date();
|
||||
function _defineProperties(target, props) {
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
var descriptor = props[i];
|
||||
descriptor.enumerable = descriptor.enumerable || false;
|
||||
descriptor.configurable = true;
|
||||
if ("value" in descriptor) descriptor.writable = true;
|
||||
Object.defineProperty(target, descriptor.key, descriptor);
|
||||
}
|
||||
// URL encoded form data must be in querystring format
|
||||
data = addQueryString('', data).slice(1);
|
||||
}
|
||||
|
||||
if (options.queryStringParams) {
|
||||
url = addQueryString(url, options.queryStringParams);
|
||||
function _createClass(Constructor, protoProps, staticProps) {
|
||||
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
||||
if (staticProps) _defineProperties(Constructor, staticProps);
|
||||
return Constructor;
|
||||
}
|
||||
|
||||
try {
|
||||
var x;
|
||||
if (XMLHttpRequest) {
|
||||
x = new XMLHttpRequest();
|
||||
function _defineProperty(obj, key, value) {
|
||||
if (key in obj) {
|
||||
Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
x = new ActiveXObject('MSXML2.XMLHTTP.3.0');
|
||||
obj[key] = value;
|
||||
}
|
||||
x.open(data ? 'POST' : 'GET', url, 1);
|
||||
if (!options.crossDomain) {
|
||||
x.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
||||
}
|
||||
x.withCredentials = !!options.withCredentials;
|
||||
if (data) {
|
||||
x.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
||||
}
|
||||
if (x.overrideMimeType) {
|
||||
x.overrideMimeType("application/json");
|
||||
}
|
||||
var h = options.customHeaders;
|
||||
if (h) {
|
||||
for (var i in h) {
|
||||
x.setRequestHeader(i, h[i]);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
var arr = [];
|
||||
var each = arr.forEach;
|
||||
var slice = arr.slice;
|
||||
function defaults(obj) {
|
||||
each.call(slice.call(arguments, 1), function (source) {
|
||||
if (source) {
|
||||
for (var prop in source) {
|
||||
if (obj[prop] === undefined) obj[prop] = source[prop];
|
||||
}
|
||||
}
|
||||
});
|
||||
return obj;
|
||||
}
|
||||
|
||||
function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); }
|
||||
|
||||
function _typeof(obj) {
|
||||
if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") {
|
||||
_typeof = function _typeof(obj) {
|
||||
return _typeof2(obj);
|
||||
};
|
||||
} else {
|
||||
_typeof = function _typeof(obj) {
|
||||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj);
|
||||
};
|
||||
}
|
||||
x.onreadystatechange = function () {
|
||||
x.readyState > 3 && callback && callback(x.responseText, x);
|
||||
|
||||
return _typeof(obj);
|
||||
}
|
||||
|
||||
function addQueryString(url, params) {
|
||||
if (params && _typeof(params) === 'object') {
|
||||
var queryString = '',
|
||||
e = encodeURIComponent; // Must encode data
|
||||
|
||||
for (var paramName in params) {
|
||||
queryString += '&' + e(paramName) + '=' + e(params[paramName]);
|
||||
}
|
||||
|
||||
if (!queryString) {
|
||||
return url;
|
||||
}
|
||||
|
||||
url = url + (url.indexOf('?') !== -1 ? '&' : '?') + queryString.slice(1);
|
||||
}
|
||||
|
||||
return url;
|
||||
} // https://gist.github.com/Xeoncross/7663273
|
||||
|
||||
|
||||
function ajax(url, options, callback, data, cache) {
|
||||
if (data && _typeof(data) === 'object') {
|
||||
if (!cache) {
|
||||
data['_t'] = new Date();
|
||||
} // URL encoded form data must be in querystring format
|
||||
|
||||
|
||||
data = addQueryString('', data).slice(1);
|
||||
}
|
||||
|
||||
if (options.queryStringParams) {
|
||||
url = addQueryString(url, options.queryStringParams);
|
||||
}
|
||||
|
||||
try {
|
||||
var x;
|
||||
|
||||
if (XMLHttpRequest) {
|
||||
x = new XMLHttpRequest();
|
||||
} else {
|
||||
x = new ActiveXObject('MSXML2.XMLHTTP.3.0');
|
||||
}
|
||||
|
||||
x.open(data ? 'POST' : 'GET', url, 1);
|
||||
|
||||
if (!options.crossDomain) {
|
||||
x.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
||||
}
|
||||
|
||||
x.withCredentials = !!options.withCredentials;
|
||||
|
||||
if (data) {
|
||||
x.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
||||
}
|
||||
|
||||
if (x.overrideMimeType) {
|
||||
x.overrideMimeType("application/json");
|
||||
}
|
||||
|
||||
var h = options.customHeaders;
|
||||
h = typeof h === 'function' ? h() : h;
|
||||
|
||||
if (h) {
|
||||
for (var i in h) {
|
||||
x.setRequestHeader(i, h[i]);
|
||||
}
|
||||
}
|
||||
|
||||
x.onreadystatechange = function () {
|
||||
x.readyState > 3 && callback && callback(x.responseText, x);
|
||||
};
|
||||
|
||||
x.send(data);
|
||||
} catch (e) {
|
||||
console && console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
function getDefaults() {
|
||||
return {
|
||||
loadPath: '/locales/{{lng}}/{{ns}}.json',
|
||||
addPath: '/locales/add/{{lng}}/{{ns}}',
|
||||
allowMultiLoading: false,
|
||||
parse: JSON.parse,
|
||||
parsePayload: function parsePayload(namespace, key, fallbackValue) {
|
||||
return _defineProperty({}, key, fallbackValue || '');
|
||||
},
|
||||
crossDomain: false,
|
||||
ajax: ajax
|
||||
};
|
||||
x.send(data);
|
||||
} catch (e) {
|
||||
console && console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function getDefaults() {
|
||||
return {
|
||||
loadPath: '/locales/{{lng}}/{{ns}}.json',
|
||||
addPath: '/locales/add/{{lng}}/{{ns}}',
|
||||
allowMultiLoading: false,
|
||||
parse: JSON.parse,
|
||||
crossDomain: false,
|
||||
ajax: ajax
|
||||
};
|
||||
}
|
||||
|
||||
var Backend = function () {
|
||||
function Backend(services) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
|
||||
_classCallCheck(this, Backend);
|
||||
|
||||
this.init(services, options);
|
||||
|
||||
this.type = 'backend';
|
||||
}
|
||||
|
||||
_createClass(Backend, [{
|
||||
key: 'init',
|
||||
value: function init(services) {
|
||||
var Backend =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function Backend(services) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
|
||||
this.services = services;
|
||||
this.options = defaults(options, this.options || {}, getDefaults());
|
||||
_classCallCheck(this, Backend);
|
||||
|
||||
this.init(services, options);
|
||||
this.type = 'backend';
|
||||
}
|
||||
}, {
|
||||
key: 'readMulti',
|
||||
value: function readMulti(languages, namespaces, callback) {
|
||||
var loadPath = this.options.loadPath;
|
||||
if (typeof this.options.loadPath === 'function') {
|
||||
loadPath = this.options.loadPath(languages, namespaces);
|
||||
|
||||
_createClass(Backend, [{
|
||||
key: "init",
|
||||
value: function init(services) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
this.services = services;
|
||||
this.options = defaults(options, this.options || {}, getDefaults());
|
||||
}
|
||||
}, {
|
||||
key: "readMulti",
|
||||
value: function readMulti(languages, namespaces, callback) {
|
||||
var loadPath = this.options.loadPath;
|
||||
|
||||
var url = this.services.interpolator.interpolate(loadPath, { lng: languages.join('+'), ns: namespaces.join('+') });
|
||||
|
||||
this.loadUrl(url, callback);
|
||||
}
|
||||
}, {
|
||||
key: 'read',
|
||||
value: function read(language, namespace, callback) {
|
||||
var loadPath = this.options.loadPath;
|
||||
if (typeof this.options.loadPath === 'function') {
|
||||
loadPath = this.options.loadPath([language], [namespace]);
|
||||
}
|
||||
|
||||
var url = this.services.interpolator.interpolate(loadPath, { lng: language, ns: namespace });
|
||||
|
||||
this.loadUrl(url, callback);
|
||||
}
|
||||
}, {
|
||||
key: 'loadUrl',
|
||||
value: function loadUrl(url, callback) {
|
||||
var _this = this;
|
||||
|
||||
this.options.ajax(url, this.options, function (data, xhr) {
|
||||
if (xhr.status >= 500 && xhr.status < 600) return callback('failed loading ' + url, true /* retry */);
|
||||
if (xhr.status >= 400 && xhr.status < 500) return callback('failed loading ' + url, false /* no retry */);
|
||||
|
||||
var ret = void 0,
|
||||
err = void 0;
|
||||
try {
|
||||
ret = _this.options.parse(data, url);
|
||||
} catch (e) {
|
||||
err = 'failed parsing ' + url + ' to json';
|
||||
if (typeof this.options.loadPath === 'function') {
|
||||
loadPath = this.options.loadPath(languages, namespaces);
|
||||
}
|
||||
if (err) return callback(err, false);
|
||||
callback(null, ret);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'create',
|
||||
value: function create(languages, namespace, key, fallbackValue) {
|
||||
var _this2 = this;
|
||||
|
||||
if (typeof languages === 'string') languages = [languages];
|
||||
var url = this.services.interpolator.interpolate(loadPath, {
|
||||
lng: languages.join('+'),
|
||||
ns: namespaces.join('+')
|
||||
});
|
||||
this.loadUrl(url, callback);
|
||||
}
|
||||
}, {
|
||||
key: "read",
|
||||
value: function read(language, namespace, callback) {
|
||||
var loadPath = this.options.loadPath;
|
||||
|
||||
var payload = {};
|
||||
payload[key] = fallbackValue || '';
|
||||
if (typeof this.options.loadPath === 'function') {
|
||||
loadPath = this.options.loadPath([language], [namespace]);
|
||||
}
|
||||
|
||||
languages.forEach(function (lng) {
|
||||
var url = _this2.services.interpolator.interpolate(_this2.options.addPath, { lng: lng, ns: namespace });
|
||||
var url = this.services.interpolator.interpolate(loadPath, {
|
||||
lng: language,
|
||||
ns: namespace
|
||||
});
|
||||
this.loadUrl(url, callback);
|
||||
}
|
||||
}, {
|
||||
key: "loadUrl",
|
||||
value: function loadUrl(url, callback) {
|
||||
var _this = this;
|
||||
|
||||
_this2.options.ajax(url, _this2.options, function (data, xhr) {
|
||||
//const statusCode = xhr.status.toString();
|
||||
// TODO: if statusCode === 4xx do log
|
||||
}, payload);
|
||||
});
|
||||
}
|
||||
}]);
|
||||
this.options.ajax(url, this.options, function (data, xhr) {
|
||||
if (xhr.status >= 500 && xhr.status < 600) return callback('failed loading ' + url, true
|
||||
/* retry */
|
||||
);
|
||||
if (xhr.status >= 400 && xhr.status < 500) return callback('failed loading ' + url, false
|
||||
/* no retry */
|
||||
);
|
||||
var ret, err;
|
||||
|
||||
try {
|
||||
ret = _this.options.parse(data, url);
|
||||
} catch (e) {
|
||||
err = 'failed parsing ' + url + ' to json';
|
||||
}
|
||||
|
||||
if (err) return callback(err, false);
|
||||
callback(null, ret);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "create",
|
||||
value: function create(languages, namespace, key, fallbackValue) {
|
||||
var _this2 = this;
|
||||
|
||||
if (typeof languages === 'string') languages = [languages];
|
||||
var payload = this.options.parsePayload(namespace, key, fallbackValue);
|
||||
languages.forEach(function (lng) {
|
||||
var url = _this2.services.interpolator.interpolate(_this2.options.addPath, {
|
||||
lng: lng,
|
||||
ns: namespace
|
||||
});
|
||||
|
||||
_this2.options.ajax(url, _this2.options, function (data, xhr) {//const statusCode = xhr.status.toString();
|
||||
// TODO: if statusCode === 4xx do log
|
||||
}, payload);
|
||||
});
|
||||
}
|
||||
}]);
|
||||
|
||||
return Backend;
|
||||
}();
|
||||
|
||||
Backend.type = 'backend';
|
||||
|
||||
return Backend;
|
||||
}();
|
||||
|
||||
Backend.type = 'backend';
|
||||
|
||||
return Backend;
|
||||
|
||||
})));
|
||||
|
2
node_modules/i18next-xhr-backend/i18nextXHRBackend.min.js
generated
vendored
2
node_modules/i18next-xhr-backend/i18nextXHRBackend.min.js
generated
vendored
@@ -1 +1 @@
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.i18nextXHRBackend=e()}(this,function(){"use strict";function t(t){return r.call(s.call(arguments,1),function(e){if(e)for(var n in e)void 0===t[n]&&(t[n]=e[n])}),t}function e(t,e){if(e&&"object"===(void 0===e?"undefined":l(e))){var n="",o=encodeURIComponent;for(var i in e)n+="&"+o(i)+"="+o(e[i]);if(!n)return t;t=t+(-1!==t.indexOf("?")?"&":"?")+n.slice(1)}return t}function n(t,n,o,i,a){i&&"object"===(void 0===i?"undefined":l(i))&&(a||(i._t=new Date),i=e("",i).slice(1)),n.queryStringParams&&(t=e(t,n.queryStringParams));try{var r;r=XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("MSXML2.XMLHTTP.3.0"),r.open(i?"POST":"GET",t,1),n.crossDomain||r.setRequestHeader("X-Requested-With","XMLHttpRequest"),r.withCredentials=!!n.withCredentials,i&&r.setRequestHeader("Content-type","application/x-www-form-urlencoded"),r.overrideMimeType&&r.overrideMimeType("application/json");var s=n.customHeaders;if(s)for(var u in s)r.setRequestHeader(u,s[u]);r.onreadystatechange=function(){r.readyState>3&&o&&o(r.responseText,r)},r.send(i)}catch(t){console&&console.log(t)}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(){return{loadPath:"/locales/{{lng}}/{{ns}}.json",addPath:"/locales/add/{{lng}}/{{ns}}",allowMultiLoading:!1,parse:JSON.parse,crossDomain:!1,ajax:n}}var a=[],r=a.forEach,s=a.slice,l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),c=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};o(this,e),this.init(t,n),this.type="backend"}return u(e,[{key:"init",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.services=e,this.options=t(n,this.options||{},i())}},{key:"readMulti",value:function(t,e,n){var o=this.options.loadPath;"function"==typeof this.options.loadPath&&(o=this.options.loadPath(t,e));var i=this.services.interpolator.interpolate(o,{lng:t.join("+"),ns:e.join("+")});this.loadUrl(i,n)}},{key:"read",value:function(t,e,n){var o=this.options.loadPath;"function"==typeof this.options.loadPath&&(o=this.options.loadPath([t],[e]));var i=this.services.interpolator.interpolate(o,{lng:t,ns:e});this.loadUrl(i,n)}},{key:"loadUrl",value:function(t,e){var n=this;this.options.ajax(t,this.options,function(o,i){if(i.status>=500&&i.status<600)return e("failed loading "+t,!0);if(i.status>=400&&i.status<500)return e("failed loading "+t,!1);var a=void 0,r=void 0;try{a=n.options.parse(o,t)}catch(e){r="failed parsing "+t+" to json"}if(r)return e(r,!1);e(null,a)})}},{key:"create",value:function(t,e,n,o){var i=this;"string"==typeof t&&(t=[t]);var a={};a[n]=o||"",t.forEach(function(t){var n=i.services.interpolator.interpolate(i.options.addPath,{lng:t,ns:e});i.options.ajax(n,i.options,function(t,e){},a)})}}]),e}();return c.type="backend",c});
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).i18nextXHRBackend=e()}(this,(function(){"use strict";function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}var e=[],n=e.forEach,o=e.slice;function i(t){return n.call(o.call(arguments,1),(function(e){if(e)for(var n in e)void 0===t[n]&&(t[n]=e[n])})),t}function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function a(t){return(a="function"==typeof Symbol&&"symbol"===r(Symbol.iterator)?function(t){return r(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":r(t)})(t)}function s(t,e){if(e&&"object"===a(e)){var n="",o=encodeURIComponent;for(var i in e)n+="&"+o(i)+"="+o(e[i]);if(!n)return t;t=t+(-1!==t.indexOf("?")?"&":"?")+n.slice(1)}return t}function l(t,e,n,o,i){o&&"object"===a(o)&&(i||(o._t=new Date),o=s("",o).slice(1)),e.queryStringParams&&(t=s(t,e.queryStringParams));try{var r;(r=XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("MSXML2.XMLHTTP.3.0")).open(o?"POST":"GET",t,1),e.crossDomain||r.setRequestHeader("X-Requested-With","XMLHttpRequest"),r.withCredentials=!!e.withCredentials,o&&r.setRequestHeader("Content-type","application/x-www-form-urlencoded"),r.overrideMimeType&&r.overrideMimeType("application/json");var l=e.customHeaders;if(l="function"==typeof l?l():l)for(var u in l)r.setRequestHeader(u,l[u]);r.onreadystatechange=function(){r.readyState>3&&n&&n(r.responseText,r)},r.send(o)}catch(t){console&&console.log(t)}}function u(){return{loadPath:"/locales/{{lng}}/{{ns}}.json",addPath:"/locales/add/{{lng}}/{{ns}}",allowMultiLoading:!1,parse:JSON.parse,parsePayload:function(t,e,n){return function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}({},e,n||"")},crossDomain:!1,ajax:l}}var c=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),this.init(t,n),this.type="backend"}var n,o,r;return n=e,(o=[{key:"init",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.services=t,this.options=i(e,this.options||{},u())}},{key:"readMulti",value:function(t,e,n){var o=this.options.loadPath;"function"==typeof this.options.loadPath&&(o=this.options.loadPath(t,e));var i=this.services.interpolator.interpolate(o,{lng:t.join("+"),ns:e.join("+")});this.loadUrl(i,n)}},{key:"read",value:function(t,e,n){var o=this.options.loadPath;"function"==typeof this.options.loadPath&&(o=this.options.loadPath([t],[e]));var i=this.services.interpolator.interpolate(o,{lng:t,ns:e});this.loadUrl(i,n)}},{key:"loadUrl",value:function(t,e){var n=this;this.options.ajax(t,this.options,(function(o,i){if(i.status>=500&&i.status<600)return e("failed loading "+t,!0);if(i.status>=400&&i.status<500)return e("failed loading "+t,!1);var r,a;try{r=n.options.parse(o,t)}catch(e){a="failed parsing "+t+" to json"}if(a)return e(a,!1);e(null,r)}))}},{key:"create",value:function(t,e,n,o){var i=this;"string"==typeof t&&(t=[t]);var r=this.options.parsePayload(e,n,o);t.forEach((function(t){var n=i.services.interpolator.interpolate(i.options.addPath,{lng:t,ns:e});i.options.ajax(n,i.options,(function(t,e){}),r)}))}}])&&t(n.prototype,o),r&&t(n,r),e}();return c.type="backend",c}));
|
||||
|
128
node_modules/i18next-xhr-backend/index.d.ts
generated
vendored
128
node_modules/i18next-xhr-backend/index.d.ts
generated
vendored
@@ -1,67 +1,77 @@
|
||||
declare namespace I18NextXhrBackend {
|
||||
type LoadPathOption = string | ((lngs: string[], namespaces: string[]) => string);
|
||||
import { BackendModule, ReadCallback } from 'i18next';
|
||||
|
||||
interface BackendOptions {
|
||||
/**
|
||||
* path where resources get loaded from, or a function
|
||||
* returning a path:
|
||||
* function(lngs, namespaces) { return customPath; }
|
||||
* the returned path will interpolate lng, ns if provided like giving a static path
|
||||
*/
|
||||
loadPath?: LoadPathOption;
|
||||
/**
|
||||
* path to post missing resources
|
||||
*/
|
||||
addPath?: string;
|
||||
/**
|
||||
* your backend server supports multiLoading
|
||||
* locales/resources.json?lng=de+en&ns=ns1+ns2
|
||||
* set loadPath: '/locales/resources.json?lng={{lng}}&ns={{ns}}' to adapt to multiLoading
|
||||
*/
|
||||
allowMultiLoading?: boolean;
|
||||
/**
|
||||
* parse data after it has been fetched
|
||||
* in example use https://www.npmjs.com/package/json5
|
||||
* here it removes the letter a from the json (bad idea)
|
||||
*/
|
||||
parse?(data: string): string;
|
||||
/**
|
||||
* allow cross domain requests
|
||||
*/
|
||||
crossDomain?: boolean;
|
||||
/**
|
||||
* allow credentials on cross domain requests
|
||||
*/
|
||||
withCredentials?: boolean;
|
||||
/**
|
||||
* define a custom xhr function
|
||||
* can be used to support XDomainRequest in IE 8 and 9
|
||||
*/
|
||||
ajax?(url: string, options: BackendOptions, callback: AjaxRequestCallback, data: {} | string, cache: boolean): void;
|
||||
/**
|
||||
* adds parameters to resource URL. 'example.com' -> 'example.com?v=1.3.5'
|
||||
*/
|
||||
queryStringParams?: { [key: string]: string };
|
||||
type LoadPathOption = string | ((lngs: string[], namespaces: string[]) => string);
|
||||
|
||||
/**
|
||||
* @see https://github.com/i18next/i18next-xhr-backend/blob/281c7e235e1157b33122adacef1957252e5700f1/src/ajax.js#L52
|
||||
*/
|
||||
customHeaders?: { [key: string]: string };
|
||||
}
|
||||
interface BackendOptions {
|
||||
/**
|
||||
* path where resources get loaded from, or a function
|
||||
* returning a path:
|
||||
* function(lngs, namespaces) { return customPath; }
|
||||
* the returned path will interpolate lng, ns if provided like giving a static path
|
||||
*/
|
||||
loadPath?: LoadPathOption;
|
||||
/**
|
||||
* path to post missing resources
|
||||
*/
|
||||
addPath?: string;
|
||||
/**
|
||||
* your backend server supports multiLoading
|
||||
* locales/resources.json?lng=de+en&ns=ns1+ns2
|
||||
* set loadPath: '/locales/resources.json?lng={{lng}}&ns={{ns}}' to adapt to multiLoading
|
||||
*/
|
||||
allowMultiLoading?: boolean;
|
||||
/**
|
||||
* parse data after it has been fetched
|
||||
* in example use https://www.npmjs.com/package/json5
|
||||
* here it removes the letter a from the json (bad idea)
|
||||
*/
|
||||
parse?(data: string): string;
|
||||
/**
|
||||
* parse data before it has been sent by addPath
|
||||
*/
|
||||
parsePayload?(namespace: string, key: string, fallbackValue?: string): { [key: string]: any };
|
||||
/**
|
||||
* allow cross domain requests
|
||||
*/
|
||||
crossDomain?: boolean;
|
||||
/**
|
||||
* allow credentials on cross domain requests
|
||||
*/
|
||||
withCredentials?: boolean;
|
||||
/**
|
||||
* define a custom xhr function
|
||||
* can be used to support XDomainRequest in IE 8 and 9
|
||||
*/
|
||||
ajax?(
|
||||
url: string,
|
||||
options: BackendOptions,
|
||||
callback: AjaxRequestCallback,
|
||||
data: {} | string,
|
||||
cache: boolean,
|
||||
): void;
|
||||
/**
|
||||
* adds parameters to resource URL. 'example.com' -> 'example.com?v=1.3.5'
|
||||
*/
|
||||
queryStringParams?: { [key: string]: string };
|
||||
|
||||
type AjaxRequestCallback = (response: string, x: XMLHttpRequest) => void;
|
||||
|
||||
type LoadCallback = (error: any, result: string | false) => void;
|
||||
/**
|
||||
* @see https://github.com/i18next/i18next-xhr-backend/blob/281c7e235e1157b33122adacef1957252e5700f1/src/ajax.js#L52
|
||||
*/
|
||||
customHeaders?: { [key: string]: string };
|
||||
}
|
||||
|
||||
export default class I18NextXhrBackend {
|
||||
constructor(services?: any, options?: I18NextXhrBackend.BackendOptions);
|
||||
init(services?: any, options?: I18NextXhrBackend.BackendOptions): void;
|
||||
readMulti(languages: string[], namespaces: string[], callback: I18NextXhrBackend.LoadCallback): void;
|
||||
read(language: string, namespace: string, callback: I18NextXhrBackend.LoadCallback): void;
|
||||
loadUrl(url: string, callback: I18NextXhrBackend.LoadCallback): void;
|
||||
type AjaxRequestCallback = (response: string, x: XMLHttpRequest) => void;
|
||||
|
||||
// type LoadCallback = (error: any, result: string | false) => void;
|
||||
|
||||
export default class I18NextXhrBackend implements BackendModule<BackendOptions> {
|
||||
constructor(services?: any, options?: BackendOptions);
|
||||
init(services?: any, options?: BackendOptions): void;
|
||||
readMulti(languages: string[], namespaces: string[], callback: ReadCallback): void;
|
||||
read(language: string, namespace: string, callback: ReadCallback): void;
|
||||
loadUrl(url: string, callback: ReadCallback): void;
|
||||
create(languages: string | string[], namespace: string, key: string, fallbackValue: string): void;
|
||||
type: "backend";
|
||||
type: 'backend';
|
||||
services: any;
|
||||
options: I18NextXhrBackend.BackendOptions;
|
||||
options: BackendOptions;
|
||||
}
|
||||
|
2
node_modules/i18next-xhr-backend/index.js
generated
vendored
2
node_modules/i18next-xhr-backend/index.js
generated
vendored
@@ -1,5 +1,5 @@
|
||||
/* eslint no-var: 0 */
|
||||
var main = require('./dist/commonjs/index.js').default;
|
||||
var main = require('./dist/cjs/i18nextXHRBackend.js').default;
|
||||
|
||||
module.exports = main;
|
||||
module.exports.default = main;
|
||||
|
119
node_modules/i18next-xhr-backend/package.json
generated
vendored
119
node_modules/i18next-xhr-backend/package.json
generated
vendored
@@ -1,32 +1,27 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"i18next-xhr-backend@2.0.1",
|
||||
"D:\\Projects\\siag\\vanillajs-seed"
|
||||
]
|
||||
],
|
||||
"_from": "i18next-xhr-backend@2.0.1",
|
||||
"_id": "i18next-xhr-backend@2.0.1",
|
||||
"_from": "i18next-xhr-backend@^3.2.2",
|
||||
"_id": "i18next-xhr-backend@3.2.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-CP0XPjJsTE4hY1rM1KXFYo63Ib61EBLEcTvMDyJwr0vs9p/UTuA3ENCmzSs9+ghZgWSjdOigc0oUERHaxctbsQ==",
|
||||
"_integrity": "sha512-OtRf2Vo3IqAxsttQbpjYnmMML12IMB5e0fc5B7qKJFLScitYaXa1OhMX0n0X/3vrfFlpHL9Ro/H+ps4Ej2j7QQ==",
|
||||
"_location": "/i18next-xhr-backend",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "i18next-xhr-backend@2.0.1",
|
||||
"raw": "i18next-xhr-backend@^3.2.2",
|
||||
"name": "i18next-xhr-backend",
|
||||
"escapedName": "i18next-xhr-backend",
|
||||
"rawSpec": "2.0.1",
|
||||
"rawSpec": "^3.2.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "2.0.1"
|
||||
"fetchSpec": "^3.2.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/i18next-xhr-backend/-/i18next-xhr-backend-2.0.1.tgz",
|
||||
"_spec": "2.0.1",
|
||||
"_where": "D:\\Projects\\siag\\vanillajs-seed",
|
||||
"_resolved": "https://registry.npmjs.org/i18next-xhr-backend/-/i18next-xhr-backend-3.2.2.tgz",
|
||||
"_shasum": "769124441461b085291f539d91864e3691199178",
|
||||
"_spec": "i18next-xhr-backend@^3.2.2",
|
||||
"_where": "D:\\Projects\\vanillajs-seed",
|
||||
"author": {
|
||||
"name": "Jan Mühlemann",
|
||||
"email": "jan.muehlemann@gmail.com",
|
||||
@@ -35,77 +30,69 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/i18next/i18next-xhr-backend/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.5.5"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "backend layer for i18next using browsers xhr",
|
||||
"devDependencies": {
|
||||
"babel-cli": "6.18.0",
|
||||
"babel-core": "6.21.0",
|
||||
"babel-eslint": "7.1.1",
|
||||
"babel-preset-es2015": "6.18.0",
|
||||
"babel-preset-stage-0": "6.16.0",
|
||||
"babelify": "7.3.0",
|
||||
"browserify": "13.3.0",
|
||||
"browserify-istanbul": "2.0.0",
|
||||
"chai": "3.5.0",
|
||||
"coveralls": "2.11.15",
|
||||
"dtslint": "^0.4.2",
|
||||
"eslint": "3.13.0",
|
||||
"eslint-config-airbnb": "13.0.0",
|
||||
"i18next": "4.1.4",
|
||||
"@babel/core": "^7.5.5",
|
||||
"@babel/plugin-transform-runtime": "^7.5.5",
|
||||
"@babel/preset-env": "^7.5.5",
|
||||
"babel-eslint": "^10.0.2",
|
||||
"babel-polyfill": "^6.26.0",
|
||||
"babelify": "^10.0.0",
|
||||
"browserify": "16.3.0",
|
||||
"browserify-istanbul": "3.0.1",
|
||||
"chai": "4.2.0",
|
||||
"coveralls": "3.0.5",
|
||||
"cpy-cli": "^2.0.0",
|
||||
"dtslint": "^0.9.0",
|
||||
"eslint": "6.1.0",
|
||||
"eslint-config-airbnb": "17.1.1",
|
||||
"i18next": "^19.0.0",
|
||||
"istanbul": "github:gotwarlost/istanbul#source-map",
|
||||
"json5": "0.5.1",
|
||||
"karma": "1.3.0",
|
||||
"karma-browserify": "5.1.0",
|
||||
"json5": "2.1.0",
|
||||
"karma": "4.2.0",
|
||||
"karma-browserify": "6.1.0",
|
||||
"karma-chai": "0.1.0",
|
||||
"karma-chrome-launcher": "2.0.0",
|
||||
"karma-cli": "1.0.1",
|
||||
"karma-chrome-launcher": "3.0.0",
|
||||
"karma-cli": "2.0.0",
|
||||
"karma-coverage": "github:douglasduteil/karma-coverage#next",
|
||||
"karma-coveralls": "1.1.2",
|
||||
"karma-coveralls": "2.1.0",
|
||||
"karma-expect": "1.1.3",
|
||||
"karma-mocha": "1.3.0",
|
||||
"karma-phantomjs-launcher": "1.0.2",
|
||||
"karma-rollup-preprocessor": "3.0.3",
|
||||
"karma-phantomjs-launcher": "1.0.4",
|
||||
"karma-sinon": "1.0.5",
|
||||
"karma-spec-reporter": "0.0.26",
|
||||
"mkdirp": "0.5.1",
|
||||
"mocha": "3.2.0",
|
||||
"phantomjs-prebuilt": "2.1.14",
|
||||
"rimraf": "2.5.4",
|
||||
"rollup": "0.41.1",
|
||||
"rollup-plugin-babel": "2.7.1",
|
||||
"rollup-plugin-node-resolve": "2.0.0",
|
||||
"rollup-plugin-uglify": "1.0.1",
|
||||
"sinon": "1.17.7",
|
||||
"tslint": "^5.12.1",
|
||||
"typescript": "^3.3.1",
|
||||
"yargs": "6.6.0"
|
||||
"karma-spec-reporter": "0.0.32",
|
||||
"mocha": "6.2.0",
|
||||
"phantomjs-prebuilt": "2.1.16",
|
||||
"rimraf": "2.6.3",
|
||||
"rollup": "^1.18.0",
|
||||
"rollup-plugin-babel": "^4.3.3",
|
||||
"rollup-plugin-node-resolve": "^5.2.0",
|
||||
"rollup-plugin-terser": "^5.1.1",
|
||||
"sinon": "7.3.2",
|
||||
"tslint": "^5.18.0",
|
||||
"typescript": "^3.5.3"
|
||||
},
|
||||
"homepage": "https://github.com/i18next/i18next-xhr-backend",
|
||||
"jsnext:main": "dist/es/index.js",
|
||||
"keywords": [
|
||||
"i18next",
|
||||
"i18next-backend"
|
||||
],
|
||||
"license": "MIT",
|
||||
"lock": false,
|
||||
"main": "./index.js",
|
||||
"main": "./dist/cjs/i18nextXHRBackend.js",
|
||||
"module": "./dist/esm/i18nextXHRBackend.js",
|
||||
"name": "i18next-xhr-backend",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/i18next/i18next-xhr-backend.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npm run clean && npm run build:cjs && npm run build:es && npm run build:umd && npm run copy",
|
||||
"build-win": "npm run clean && npm run build:cjs && npm run build:es-win && npm run build:umd && npm run copy-win",
|
||||
"build:amd": "rollup -c rollup.config.js --format amd && rollup -c rollup.config.js --format umd --uglify",
|
||||
"build:cjs": "babel src --out-dir dist/commonjs",
|
||||
"build:es": "BABEL_ENV=jsnext babel src --out-dir dist/es",
|
||||
"build:es-win": "SET BABEL_ENV=jsnext babel src --out-dir dist/es",
|
||||
"build:iife": "rollup -c rollup.config.js --format iife && rollup -c rollup.config.js --format iife --uglify",
|
||||
"build:umd": "rollup -c rollup.config.js --format umd && rollup -c rollup.config.js --format umd --uglify",
|
||||
"clean": "rimraf dist && mkdirp dist",
|
||||
"copy": "cp ./dist/umd/i18nextXHRBackend.min.js ./i18nextXHRBackend.min.js && cp ./dist/umd/i18nextXHRBackend.js ./i18nextXHRBackend.js",
|
||||
"copy-win": "xcopy .\\dist\\umd\\i18nextXHRBackend.min.js .\\i18nextXHRBackend.min.js /y && xcopy .\\dist\\umd\\i18nextXHRBackend.js .\\i18nextXHRBackend.js /y",
|
||||
"build": "rimraf dist && rollup -c && cpy \"./dist/umd/*.js\" ./",
|
||||
"postversion": "git push && git push --tags",
|
||||
"pretest": "npm run test:typescript",
|
||||
"preversion": "npm run test && npm run build && git push",
|
||||
@@ -114,5 +101,5 @@
|
||||
"test:typescript": "tslint --project tsconfig.json"
|
||||
},
|
||||
"types": "./index.d.ts",
|
||||
"version": "2.0.1"
|
||||
"version": "3.2.2"
|
||||
}
|
||||
|
78
node_modules/i18next-xhr-backend/rollup.config.js
generated
vendored
78
node_modules/i18next-xhr-backend/rollup.config.js
generated
vendored
@@ -1,31 +1,55 @@
|
||||
import babel from 'rollup-plugin-babel';
|
||||
import uglify from 'rollup-plugin-uglify';
|
||||
import nodeResolve from 'rollup-plugin-node-resolve';
|
||||
import { argv } from 'yargs';
|
||||
import { terser } from 'rollup-plugin-terser';
|
||||
import pkg from './package.json';
|
||||
|
||||
const format = argv.format || argv.f || 'iife';
|
||||
const compress = argv.uglify;
|
||||
|
||||
const babelOptions = {
|
||||
exclude: 'node_modules/**',
|
||||
presets: [['es2015', { modules: false }], 'stage-0'],
|
||||
babelrc: false
|
||||
};
|
||||
|
||||
const dest = {
|
||||
amd: `dist/amd/i18nextXHRBackend${compress ? '.min' : ''}.js`,
|
||||
umd: `dist/umd/i18nextXHRBackend${compress ? '.min' : ''}.js`,
|
||||
iife: `dist/iife/i18nextXHRBackend${compress ? '.min' : ''}.js`
|
||||
}[format];
|
||||
|
||||
export default {
|
||||
entry: 'src/index.js',
|
||||
format,
|
||||
const getBabelOptions = ({ useESModules }) => ({
|
||||
exclude: /node_modules/,
|
||||
runtimeHelpers: true,
|
||||
plugins: [
|
||||
babel(babelOptions),
|
||||
nodeResolve({ jsnext: true })
|
||||
].concat(compress ? uglify() : []),
|
||||
moduleName: 'i18nextXHRBackend',
|
||||
//moduleId: 'i18nextXHRBackend',
|
||||
dest
|
||||
};
|
||||
['@babel/transform-runtime', { useESModules }]
|
||||
]
|
||||
});
|
||||
|
||||
const input = './src/index.js';
|
||||
const name = 'i18nextXHRBackend'
|
||||
// check relative and absolute paths for windows and unix
|
||||
const external = id => !id.startsWith('.') && !id.startsWith('/') && !id.includes(':');
|
||||
|
||||
export default [
|
||||
{
|
||||
input,
|
||||
output: { format: 'cjs', file: pkg.main },
|
||||
external,
|
||||
plugins: [
|
||||
babel(getBabelOptions({ useESModules: false }))
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
input,
|
||||
output: { format: 'esm', file: pkg.module },
|
||||
external,
|
||||
plugins: [
|
||||
babel(getBabelOptions({ useESModules: true }))
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
input,
|
||||
output: { format: 'umd', name, file: `dist/umd/${name}.js` },
|
||||
plugins: [
|
||||
babel(getBabelOptions({ useESModules: true })),
|
||||
nodeResolve()
|
||||
],
|
||||
},
|
||||
{
|
||||
input,
|
||||
output: { format: 'umd', name, file: `dist/umd/${name}.min.js` },
|
||||
plugins: [
|
||||
babel(getBabelOptions({ useESModules: true })),
|
||||
nodeResolve(),
|
||||
terser()
|
||||
],
|
||||
}
|
||||
]
|
||||
|
2
node_modules/i18next-xhr-backend/tsconfig.json
generated
vendored
2
node_modules/i18next-xhr-backend/tsconfig.json
generated
vendored
@@ -11,5 +11,5 @@
|
||||
"baseUrl": ".",
|
||||
"paths": { "i18next-xhr-backend": ["./index.d.ts"] }
|
||||
},
|
||||
"include": ["./indext.d.ts", "./test/**/*.ts*"]
|
||||
"include": ["./index.d.ts", "./test/**/*.ts*"]
|
||||
}
|
||||
|
3
node_modules/i18next-xhr-backend/tslint.json
generated
vendored
3
node_modules/i18next-xhr-backend/tslint.json
generated
vendored
@@ -2,6 +2,7 @@
|
||||
"defaultSeverity": "error",
|
||||
"extends": "dtslint/dtslint.json",
|
||||
"rules": {
|
||||
"semicolon": false
|
||||
"semicolon": false,
|
||||
"no-null-undefined-union": false
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user