Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: i18next/i18next-http-backend
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ace4566895634e5768d150c075cb8fc904dded59
Choose a base ref
...
head repository: i18next/i18next-http-backend
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7928244ebfa1afee4777d07145222826e7c840d7
Choose a head ref
  • 3 commits
  • 6 files changed
  • 1 contributor

Commits on Jan 3, 2022

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    4689d8f View commit details

Commits on Jan 21, 2022

  1. update dependencies, also to fix #84

    adrai committed Jan 21, 2022
    Copy the full SHA
    00b7e8f View commit details
  2. 1.3.2

    adrai committed Jan 21, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    7928244 View commit details
Showing with 75 additions and 17 deletions.
  1. +9 −0 README.md
  2. +39 −0 example/jquery/index.html
  3. +10 −0 example/jquery/locales/en/translation.json
  4. +3 −3 i18nextHttpBackend.js
  5. +1 −1 i18nextHttpBackend.min.js
  6. +13 −13 package.json
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -19,6 +19,8 @@ If you don't want to manage your translation files manually or are simply lookin

Source can be loaded via [npm](https://www.npmjs.com/package/i18next-http-backend) or [downloaded](https://github.com/i18next/i18next-http-backend/blob/master/i18nextHttpBackend.min.js) from this repo.

There's also the possibility to directly import it via a CDN like [jsdelivr](https://cdn.jsdelivr.net/npm/i18next-http-backend@1.3.1/i18nextHttpBackend.min.js) or [unpkg](https://unpkg.com/i18next-http-backend@1.3.1/i18nextHttpBackend.min.js) or similar.

```bash
# npm package
$ npm install i18next-http-backend
@@ -42,6 +44,13 @@ import Backend from 'https://deno.land/x/i18next_http_backend/index.js'
i18next.use(Backend).init(i18nextOptions);
```

for plain browser:

```html
<script src="https://cdn.jsdelivr.net/npm/i18next-http-backend@1.3.1/i18nextHttpBackend.min.js"></script>
<!-- an example can be found in example/jquery/index.html -->
```

- As with all modules you can either pass the constructor function (class) to the i18next.use or a concrete instance.
- If you don't use a module loader it will be added to `window.i18nextHttpBackend`

39 changes: 39 additions & 0 deletions example/jquery/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/i18next@21.6.4/i18next.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jquery-i18next@1.2.1/jquery-i18next.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/i18next-http-backend@1.3.1/i18nextHttpBackend.min.js"></script>
</head>

<body>

<ul class="nav">
<li><a href="#" data-i18n="nav.home"></a></li>
<li><a href="#" data-i18n="nav.page1"></a></li>
<li><a href="#" data-i18n="nav.page2"></a></li>
</ul>

<div class="content">
<input data-i18n="[placeholder]input.placeholder; [title]input.placeholder" />
</div>

<script>
i18next.use(i18nextHttpBackend).init({
debug: true,
fallbackLng: 'en' // evtl. use language-detector https://github.com/i18next/i18next-browser-languageDetector
}, function(err, t) {
// for options see
// https://github.com/i18next/jquery-i18next#initialize-the-plugin
jqueryI18next.init(i18next, $);

// start localizing, details:
// https://github.com/i18next/jquery-i18next#usage-of-selector-function
$('.nav').localize();
$('.content').localize();
});
</script>

</body>

</html>
10 changes: 10 additions & 0 deletions example/jquery/locales/en/translation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"input": {
"placeholder": "a placeholder"
},
"nav": {
"home": "Home",
"page1": "Page One",
"page2": "Page Two"
}
}
6 changes: 3 additions & 3 deletions i18nextHttpBackend.js
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons

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); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

@@ -248,7 +248,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

var fetchApi;

@@ -409,7 +409,7 @@ exports.defaults = defaults;
exports.hasXMLHttpRequest = hasXMLHttpRequest;
exports.makePromise = makePromise;

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

var arr = [];
var each = arr.forEach;
2 changes: 1 addition & 1 deletion i18nextHttpBackend.min.js
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "i18next-http-backend",
"version": "1.3.1",
"version": "1.3.2",
"private": false,
"type": "module",
"main": "./cjs/index.js",
@@ -19,28 +19,28 @@
},
"module": "./esm/index.js",
"dependencies": {
"cross-fetch": "3.1.4"
"cross-fetch": "3.1.5"
},
"types": "./index.d.ts",
"devDependencies": {
"@babel/cli": "7.13.0",
"@babel/core": "7.13.1",
"@babel/preset-env": "7.13.5",
"@babel/cli": "7.16.8",
"@babel/core": "7.16.10",
"@babel/preset-env": "7.16.11",
"babel-plugin-add-module-exports": "1.0.4",
"browserify": "17.0.0",
"eslint": "7.20.0",
"eslint-config-standard": "16.0.2",
"eslint-plugin-import": "2.22.1",
"eslint": "7.32.0",
"eslint-config-standard": "16.0.3",
"eslint-plugin-import": "2.25.4",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "4.3.1",
"eslint-plugin-promise": "5.2.0",
"eslint-plugin-require-path-exists": "1.1.9",
"eslint-plugin-standard": "5.0.0",
"expect.js": "0.3.1",
"i18next": "20.0.0",
"json-server": "0.16.3",
"i18next": "21.6.6",
"json-server": "0.17.0",
"json5": "2.2.0",
"mocha": "8.3.0",
"uglify-js": "3.12.8",
"mocha": "9.1.4",
"uglify-js": "3.14.5",
"xmlhttprequest": "1.8.0"
},
"description": "i18next-http-backend is a backend layer for i18next using in Node.js, in the browser and for Deno.",