inital commit

This commit is contained in:
2026-01-01 15:25:19 +05:30
commit f0ae49465a
36361 changed files with 4894111 additions and 0 deletions

9
node_modules/i18next-resources-to-backend/.babelrc generated vendored Normal file
View File

@@ -0,0 +1,9 @@
{
"presets": [
["@babel/preset-env", {
"targets": {
"ie": 11
}
}, "@babel/react"]
]
}

View File

@@ -0,0 +1,23 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 7
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- "discussion"
- "feature request"
- "bug"
- "breaking change"
- "doc"
- "issue"
- "help wanted"
- "good first issue"
# Label to use when marking an issue as stale
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false

View File

@@ -0,0 +1,24 @@
name: deno
on:
push:
branches:
- main
jobs:
test:
name: Test on deno ${{ matrix.deno }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
deno: [ '1.x' ]
# os: [ubuntu-latest, windows-latest, macOS-latest]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
- name: Setup Deno
uses: denolib/setup-deno@master
with:
deno-version: ${{ matrix.deno }}
- run: deno --version
- run: deno test test/deno/*.ts --reload --no-check

View File

@@ -0,0 +1,24 @@
name: node
on:
push:
branches:
- main
jobs:
test:
name: Test on node ${{ matrix.node }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
node: [ '20.x', '18.x', '16.x' ]
# os: [ubuntu-latest, windows-latest, macOS-latest]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- run: npm install
- run: npm test

37
node_modules/i18next-resources-to-backend/.ts.eslintrc generated vendored Normal file
View File

@@ -0,0 +1,37 @@
{
"extends": [
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"env": { "node": true },
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"project": "./tsconfig.json",
"createDefaultProgram": true
},
"rules": {
"semi": ["error", "never"],
"import/export": "off", // this errors on multiple exports (overload interfaces)
"require-path-exists/exists": "off"
},
"overrides": [
{
"files": ["*.d.ts","*.test-d.ts"],
"rules": {
"@typescript-eslint/no-explicit-any": "off"
}
},
{
"files": ["*.test-d.ts"],
"rules": {
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-non-null-assertion": "off"
}
}
]
}

140
node_modules/i18next-resources-to-backend/README.md generated vendored Normal file
View File

@@ -0,0 +1,140 @@
# Introduction
[![Actions](https://github.com/i18next/i18next-resources-to-backend/workflows/node/badge.svg)](https://github.com/i18next/i18next-resources-to-backend/actions?query=workflow%3Anode)
[![Actions deno](https://github.com/i18next/i18next-resources-to-backend/workflows/deno/badge.svg)](https://github.com/i18next/i18next-resources-to-backend/actions?query=workflow%3Adeno)
[![npm version](https://img.shields.io/npm/v/i18next-resources-to-backend.svg?style=flat-square)](https://www.npmjs.com/package/i18next-resources-to-backend)
This package helps to transform resources to an i18next backend. To be used in Node.js, in the browser and for Deno.
# Getting started
Source can be loaded via [npm](https://www.npmjs.com/package/i18next-resources-to-backend).
```bash
# npm package
$ npm install i18next-resources-to-backend
```
## simple example - dynamic imports (lazy load in memory translations)
i18next-resources-to-backend helps to transform resources to an i18next backend. This means you can lazy load translations.
The dynamic import must be passed a string. Webpack will fail to load the resource if you pass a variable to `import()`.
For example, when using webpack:
```js
import i18next from 'i18next';
import resourcesToBackend from 'i18next-resources-to-backend';
i18next
.use(resourcesToBackend((language, namespace) => import(`./locales/${language}/${namespace}.json`)))
.on('failedLoading', (lng, ns, msg) => console.error(msg);
.init({ /* other options */ })
```
## used as fallback in combination with another i18next backend
i.e. [Browser fallback with local / bundled translations](https://www.i18next.com/how-to/backend-fallback#browser-fallback-with-local-bundled-translations)
Wiring up:
```js
import i18next from 'i18next'
import ChainedBackend from 'i18next-chained-backend'
import resourcesToBackend from 'i18next-resources-to-backend'
import HttpBackend from 'i18next-http-backend'
i18next.use(ChainedBackend).init({
backend: {
backends: [
HttpBackend, // if a namespace can't be loaded via normal http-backend loadPath, then the inMemoryLocalBackend will try to return the correct resources
resourcesToBackend({
en: {
translations: {
sayHi: 'hello world'
}
}
})
],
backendOptions: [{
loadPath: 'http://localhost:8080/locales/{{lng}}/{{ns}}.json'
}]
}
})
```
for Deno:
```js
import i18next from 'https://deno.land/x/i18next/index.js'
import ChainedBackend from 'https://deno.land/x/i18next_chained_backend/index.js'
import resourcesToBackend from 'https://deno.land/x/i18next_resources_to_backend/index.js'
import HttpBackend from 'https://deno.land/x/i18next_http_backend/index.js'
i18next.use(ChainedBackend).init({
backend: {
backends: [
HttpBackend, // if a namespace can't be loaded via normal http-backend loadPath, then the inMemoryLocalBackend will try to return the correct resources
resourcesToBackend({
en: {
translations: {
sayHi: 'hello world'
}
}
})
],
backendOptions: [{
loadPath: 'http://localhost:8080/locales/{{lng}}/{{ns}}.json'
}]
}
})
```
## you can also lazy load the in memory translations, i.e. when using webpack:
```js
i18next.use(ChainedBackend).init({
backend: {
backends: [
HttpBackend, // if a namespace can't be loaded via normal http-backend loadPath, then the inMemoryLocalBackend will try to return the correct resources
// with dynamic import, you have to use the "default" key of the module ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#importing_defaults )
resourcesToBackend((language, namespace) => import(`./locales/${language}/${namespace}.json`))
// resourcesToBackend((language, namespace, callback) => {
// import(`./locales/${language}/${namespace}.json`)
// .then(({ default: resources }) => {
// callback(null, resources)
// })
// .catch((error) => {
// callback(error, null)
// })
// })
],
backendOptions: [{
loadPath: 'http://localhost:8080/locales/{{lng}}/{{ns}}.json'
}]
}
})
```
---
<h3 align="center">Gold Sponsors</h3>
<p align="center">
<a href="https://locize.com/" target="_blank">
<img src="https://raw.githubusercontent.com/i18next/i18next/master/assets/locize_sponsor_240.gif" width="240px">
</a>
</p>
---
**From the creators of i18next: localization as a service - locize.com**
A translation management system built around the i18next ecosystem - [locize.com](https://locize.com).
![locize](https://locize.com/img/ads/github_locize.png)
With using [locize](http://locize.com/?utm_source=react_i18next_readme&utm_medium=github) you directly support the future of i18next.
---

View File

@@ -0,0 +1,7 @@
import { BackendModule, Resource, ReadCallback, ResourceKey } from 'i18next'
type ImportFn<L, N> = ((language: L, namespace: N, callback: ReadCallback) => void) | ((language: L, namespace: N) => Promise<ResourceKey | boolean | null | undefined>)
declare function resourcesToBackend<L = string, N = string>(res: Resource | ImportFn<L, N>): BackendModule
export default resourcesToBackend

View File

@@ -0,0 +1,32 @@
'use strict';
var resourcesToBackend = function resourcesToBackend(res) {
return {
type: 'backend',
init: function init(services, backendOptions, i18nextOptions) {},
read: function read(language, namespace, callback) {
if (typeof res === 'function') {
if (res.length < 3) {
try {
var r = res(language, namespace);
if (r && typeof r.then === 'function') {
r.then(function (data) {
return callback(null, data && data.default || data);
}).catch(callback);
} else {
callback(null, r);
}
} catch (err) {
callback(err);
}
return;
}
res(language, namespace, callback);
return;
}
callback(null, res && res[language] && res[language][namespace]);
}
};
};
module.exports = resourcesToBackend;

View File

@@ -0,0 +1 @@
{"type":"commonjs"}

View File

@@ -0,0 +1,3 @@
import * as index from './index.js'
export default index.default

View File

@@ -0,0 +1,7 @@
import { BackendModule, Resource, ReadCallback, ResourceKey } from 'i18next'
type ImportFn<L, N> = ((language: L, namespace: N, callback: ReadCallback) => void) | ((language: L, namespace: N) => Promise<ResourceKey | boolean | null | undefined>)
declare function resourcesToBackend<L = string, N = string>(res: Resource | ImportFn<L, N>): BackendModule
export default resourcesToBackend

View File

@@ -0,0 +1,30 @@
var resourcesToBackend = function resourcesToBackend(res) {
return {
type: 'backend',
init: function init(services, backendOptions, i18nextOptions) {},
read: function read(language, namespace, callback) {
if (typeof res === 'function') {
if (res.length < 3) {
try {
var r = res(language, namespace);
if (r && typeof r.then === 'function') {
r.then(function (data) {
return callback(null, data && data.default || data);
}).catch(callback);
} else {
callback(null, r);
}
} catch (err) {
callback(err);
}
return;
}
res(language, namespace, callback);
return;
}
callback(null, res && res[language] && res[language][namespace]);
}
};
};
export { resourcesToBackend as default };

View File

@@ -0,0 +1,38 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.i18nextResourcesToBackend = factory());
})(this, (function () { 'use strict';
var resourcesToBackend = function resourcesToBackend(res) {
return {
type: 'backend',
init: function init(services, backendOptions, i18nextOptions) {},
read: function read(language, namespace, callback) {
if (typeof res === 'function') {
if (res.length < 3) {
try {
var r = res(language, namespace);
if (r && typeof r.then === 'function') {
r.then(function (data) {
return callback(null, data && data.default || data);
}).catch(callback);
} else {
callback(null, r);
}
} catch (err) {
callback(err);
}
return;
}
res(language, namespace, callback);
return;
}
callback(null, res && res[language] && res[language][namespace]);
}
};
};
return resourcesToBackend;
}));

View File

@@ -0,0 +1 @@
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).i18nextResourcesToBackend=n()}(this,(function(){"use strict";return function(e){return{type:"backend",init:function(e,n,t){},read:function(n,t,f){if("function"!=typeof e)f(null,e&&e[n]&&e[n][t]);else{if(e.length<3){try{var o=e(n,t);o&&"function"==typeof o.then?o.then((function(e){return f(null,e&&e.default||e)})).catch(f):f(null,o)}catch(e){f(e)}return}e(n,t,f)}}}}}));

View File

@@ -0,0 +1,3 @@
import * as index from './index.js'
export default index.default

7
node_modules/i18next-resources-to-backend/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,7 @@
import { BackendModule, Resource, ReadCallback, ResourceKey } from 'i18next'
type ImportFn<L, N> = ((language: L, namespace: N, callback: ReadCallback) => void) | ((language: L, namespace: N) => Promise<ResourceKey | boolean | null | undefined>)
declare function resourcesToBackend<L = string, N = string>(res: Resource | ImportFn<L, N>): BackendModule
export default resourcesToBackend

3
node_modules/i18next-resources-to-backend/index.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import resourcesToBackend from './src/index.js'
export default resourcesToBackend

19
node_modules/i18next-resources-to-backend/licence generated vendored Normal file
View File

@@ -0,0 +1,19 @@
Copyright (c) 2023 i18next
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

94
node_modules/i18next-resources-to-backend/package.json generated vendored Normal file
View File

@@ -0,0 +1,94 @@
{
"name": "i18next-resources-to-backend",
"version": "1.2.1",
"description": "This package helps to transform resources to an i18next backend",
"keywords": [
"i18next",
"i18next-backend",
"i18next-chained-backend"
],
"homepage": "https://github.com/i18next/i18next-resources-to-backend",
"repository": {
"type": "git",
"url": "git@github.com:i18next/i18next-resources-to-backend.git"
},
"bugs": {
"url": "https://github.com/i18next/i18next-resources-to-backend/issues"
},
"type": "module",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"browser": "./dist/umd/i18nextResourcesToBackend.js",
"types": "./index.d.mts",
"exports": {
"./package.json": "./package.json",
".": {
"types": {
"require": "./dist/cjs/index.d.ts",
"import": "./dist/esm/index.d.mts"
},
"module": "./dist/esm/index.js",
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js",
"default": "./dist/esm/index.js"
},
"./cjs": {
"types": "./dist/cjs/index.d.ts",
"default": "./dist/cjs/index.js"
},
"./esm": {
"types": "./dist/esm/index.d.mts",
"default": "./dist/esm/index.js"
},
"./src": {
"default": "./src/index.js"
}
},
"scripts": {
"lint:javascript": "eslint .",
"lint:typescript": "eslint -c .ts.eslintrc *.d.ts *.d.mts test/types/**/*.test-d.ts",
"lint": "npm run lint:javascript && npm run lint:typescript",
"build": "rm -rf dist && rollup -c && echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json && cp index.d.ts dist/cjs/index.d.ts && cp index.d.ts dist/esm/index.d.ts && cp index.d.mts dist/esm/index.d.mts",
"test:deno": "deno test test/deno/*.ts --reload --no-check",
"test:typescript": "tsd",
"test": "npm run lint && mocha --colors --reporter spec --recursive test/*.js",
"test:all": "npm run test && npm run test:typescript && npm run test:deno",
"preversion": "npm run test && npm run build && git push",
"postversion": "git push && git push --tags"
},
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.23.2"
},
"devDependencies": {
"@babel/core": "^7.23.3",
"@babel/plugin-transform-runtime": "^7.23.3",
"@babel/preset-env": "^7.23.3",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.4",
"@types/mocha": "^10.0.4",
"@typescript-eslint/eslint-plugin": "^6.10.0",
"@typescript-eslint/parser": "^6.10.0",
"babel-plugin-add-module-exports": "^1.0.4",
"eslint": "^8.53.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-n": "^16.3.1",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-require-path-exists": "^1.1.9",
"eslint-plugin-standard": "^5.0.0",
"i18next": "^23.7.1",
"i18next-chained-backend": "^4.6.2",
"mocha": "^10.2.0",
"rollup": "^4.3.0",
"should": "^13.2.3",
"sinon": "^17.0.1",
"tsd": "^0.29.0",
"typescript": "^5.2.2"
},
"tsd": {
"directory": "test/types"
}
}

View File

@@ -0,0 +1,83 @@
import { babel } from '@rollup/plugin-babel'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import terser from '@rollup/plugin-terser'
import commonjs from '@rollup/plugin-commonjs'
import { readFileSync } from 'fs'
const pkg = JSON.parse(readFileSync(new URL('package.json', import.meta.url)))
const getBabelOptions = ({ useESModules, plugins = [] }) => ({
exclude: /node_modules/,
babelHelpers: 'runtime',
plugins: [['@babel/transform-runtime', { useESModules }]].concat(plugins),
comments: false
})
const input = './src/index.js'
// check relative and absolute paths for windows and unix
const external = id => !id.startsWith('.') && !id.startsWith('/') && !id.includes(':')
export default [
{
input,
output: {
dir: 'dist/cjs',
preserveModules: true,
// file: pkg.main,
format: 'cjs'
},
external,
// external: [
// ...Object.keys(pkg.dependencies || {})
// ],
plugins: [babel(getBabelOptions({
useESModules: false,
plugins: [['add-module-exports']]
}))]
},
{
input,
output: {
dir: 'dist/esm',
preserveModules: true,
// file: pkg.module,
format: 'esm' // the preferred format
},
external,
// external: [
// ...Object.keys(pkg.dependencies || {})
// ],
plugins: [babel(getBabelOptions({ useESModules: true }))]
},
// this is not used, if we make sure every js file is imported with .js ending
// {
// input,
// output: {
// dir: 'dist/deno',
// preserveModules: true,
// // file: pkg.module,
// format: 'esm' // the preferred format
// },
// external
// // external: [
// // ...Object.keys(pkg.dependencies || {})
// // ]
// },
{
input,
output: {
file: pkg.browser,
format: 'umd',
name: 'i18nextResourcesToBackend' // the global which can be used in a browser
},
plugins: [commonjs(), babel(getBabelOptions({ useESModules: true })), nodeResolve()]
},
{
input,
output: {
file: pkg.browser.replace('.js', '.min.js'),
format: 'umd',
name: 'i18nextResourcesToBackend' // the global which can be used in a browser
},
plugins: [commonjs(), babel(getBabelOptions({ useESModules: true })), nodeResolve(), terser()]
}
]

30
node_modules/i18next-resources-to-backend/src/index.js generated vendored Normal file
View File

@@ -0,0 +1,30 @@
const resourcesToBackend = (res) => ({
type: 'backend',
init (services, backendOptions, i18nextOptions) { /* use services and options */ },
read (language, namespace, callback) {
if (typeof res === 'function') { // in case someone wants to customize the loading...
if (res.length < 3) {
// no callback
try {
const r = res(language, namespace)
if (r && typeof r.then === 'function') {
// promise
r.then((data) => callback(null, (data && data.default) || data)).catch(callback)
} else {
// sync
callback(null, r)
}
} catch (err) {
callback(err)
}
return
}
// normal with callback
res(language, namespace, callback)
return
}
callback(null, res && res[language] && res[language][namespace])
}
})
export default resourcesToBackend

View File

@@ -0,0 +1,14 @@
{
"compilerOptions": {
"target": "es6",
"lib": [ "es2015" ],
"module": "commonjs",
"noEmit": true,
"strict": true
},
"include": [
"test/types/*.test-d.ts",
"*.d.ts",
"*.d.mts"
]
}