KJ
This commit is contained in:
dopeuni444
2025-08-06 11:08:49 +04:00
parent b5a22951ae
commit ae726301f8
8715 changed files with 588619 additions and 243113 deletions

100
unified-ai-platform/node_modules/y18n/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,100 @@
# Change Log
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
### [5.0.8](https://www.github.com/yargs/y18n/compare/v5.0.7...v5.0.8) (2021-04-07)
### Bug Fixes
* **deno:** force modern release for Deno ([b1c215a](https://www.github.com/yargs/y18n/commit/b1c215aed714bee5830e76de3e335504dc2c4dab))
### [5.0.7](https://www.github.com/yargs/y18n/compare/v5.0.6...v5.0.7) (2021-04-07)
### Bug Fixes
* **deno:** force release for deno ([#121](https://www.github.com/yargs/y18n/issues/121)) ([d3f2560](https://www.github.com/yargs/y18n/commit/d3f2560e6cedf2bfa2352e9eec044da53f9a06b2))
### [5.0.6](https://www.github.com/yargs/y18n/compare/v5.0.5...v5.0.6) (2021-04-05)
### Bug Fixes
* **webpack:** skip readFileSync if not defined ([#117](https://www.github.com/yargs/y18n/issues/117)) ([6966fa9](https://www.github.com/yargs/y18n/commit/6966fa91d2881cc6a6c531e836099e01f4da1616))
### [5.0.5](https://www.github.com/yargs/y18n/compare/v5.0.4...v5.0.5) (2020-10-25)
### Bug Fixes
* address prototype pollution issue ([#108](https://www.github.com/yargs/y18n/issues/108)) ([a9ac604](https://www.github.com/yargs/y18n/commit/a9ac604abf756dec9687be3843e2c93bfe581f25))
### [5.0.4](https://www.github.com/yargs/y18n/compare/v5.0.3...v5.0.4) (2020-10-16)
### Bug Fixes
* **exports:** node 13.0 and 13.1 require the dotted object form _with_ a string fallback ([#105](https://www.github.com/yargs/y18n/issues/105)) ([4f85d80](https://www.github.com/yargs/y18n/commit/4f85d80dbaae6d2c7899ae394f7ad97805df4886))
### [5.0.3](https://www.github.com/yargs/y18n/compare/v5.0.2...v5.0.3) (2020-10-16)
### Bug Fixes
* **exports:** node 13.0-13.6 require a string fallback ([#103](https://www.github.com/yargs/y18n/issues/103)) ([e39921e](https://www.github.com/yargs/y18n/commit/e39921e1017f88f5d8ea97ddea854ffe92d68e74))
### [5.0.2](https://www.github.com/yargs/y18n/compare/v5.0.1...v5.0.2) (2020-10-01)
### Bug Fixes
* **deno:** update types for deno ^1.4.0 ([#100](https://www.github.com/yargs/y18n/issues/100)) ([3834d9a](https://www.github.com/yargs/y18n/commit/3834d9ab1332f2937c935ada5e76623290efae81))
### [5.0.1](https://www.github.com/yargs/y18n/compare/v5.0.0...v5.0.1) (2020-09-05)
### Bug Fixes
* main had old index path ([#98](https://www.github.com/yargs/y18n/issues/98)) ([124f7b0](https://www.github.com/yargs/y18n/commit/124f7b047ba9596bdbdf64459988304e77f3de1b))
## [5.0.0](https://www.github.com/yargs/y18n/compare/v4.0.0...v5.0.0) (2020-09-05)
### ⚠ BREAKING CHANGES
* exports maps are now used, which modifies import behavior.
* drops Node 6 and 4. begin following Node.js LTS schedule (#89)
### Features
* add support for ESM and Deno [#95](https://www.github.com/yargs/y18n/issues/95)) ([4d7ae94](https://www.github.com/yargs/y18n/commit/4d7ae94bcb42e84164e2180366474b1cd321ed94))
### Build System
* drops Node 6 and 4. begin following Node.js LTS schedule ([#89](https://www.github.com/yargs/y18n/issues/89)) ([3cc0c28](https://www.github.com/yargs/y18n/commit/3cc0c287240727b84eaf1927f903612ec80f5e43))
### 4.0.1 (2020-10-25)
### Bug Fixes
* address prototype pollution issue ([#108](https://www.github.com/yargs/y18n/issues/108)) ([a9ac604](https://www.github.com/yargs/y18n/commit/7de58ca0d315990cdb38234e97fc66254cdbcd71))
## [4.0.0](https://github.com/yargs/y18n/compare/v3.2.1...v4.0.0) (2017-10-10)
### Bug Fixes
* allow support for falsy values like 0 in tagged literal ([#45](https://github.com/yargs/y18n/issues/45)) ([c926123](https://github.com/yargs/y18n/commit/c926123))
### Features
* **__:** added tagged template literal support ([#44](https://github.com/yargs/y18n/issues/44)) ([0598daf](https://github.com/yargs/y18n/commit/0598daf))
### BREAKING CHANGES
* **__:** dropping Node 0.10/Node 0.12 support

127
unified-ai-platform/node_modules/y18n/README.md generated vendored Normal file
View File

@@ -0,0 +1,127 @@
# y18n
[![NPM version][npm-image]][npm-url]
[![js-standard-style][standard-image]][standard-url]
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
The bare-bones internationalization library used by yargs.
Inspired by [i18n](https://www.npmjs.com/package/i18n).
## Examples
_simple string translation:_
```js
const __ = require('y18n')().__;
console.log(__('my awesome string %s', 'foo'));
```
output:
`my awesome string foo`
_using tagged template literals_
```js
const __ = require('y18n')().__;
const str = 'foo';
console.log(__`my awesome string ${str}`);
```
output:
`my awesome string foo`
_pluralization support:_
```js
const __n = require('y18n')().__n;
console.log(__n('one fish %s', '%d fishes %s', 2, 'foo'));
```
output:
`2 fishes foo`
## Deno Example
As of `v5` `y18n` supports [Deno](https://github.com/denoland/deno):
```typescript
import y18n from "https://deno.land/x/y18n/deno.ts";
const __ = y18n({
locale: 'pirate',
directory: './test/locales'
}).__
console.info(__`Hi, ${'Ben'} ${'Coe'}!`)
```
You will need to run with `--allow-read` to load alternative locales.
## JSON Language Files
The JSON language files should be stored in a `./locales` folder.
File names correspond to locales, e.g., `en.json`, `pirate.json`.
When strings are observed for the first time they will be
added to the JSON file corresponding to the current locale.
## Methods
### require('y18n')(config)
Create an instance of y18n with the config provided, options include:
* `directory`: the locale directory, default `./locales`.
* `updateFiles`: should newly observed strings be updated in file, default `true`.
* `locale`: what locale should be used.
* `fallbackToLanguage`: should fallback to a language-only file (e.g. `en.json`)
be allowed if a file matching the locale does not exist (e.g. `en_US.json`),
default `true`.
### y18n.\_\_(str, arg, arg, arg)
Print a localized string, `%s` will be replaced with `arg`s.
This function can also be used as a tag for a template literal. You can use it
like this: <code>__&#96;hello ${'world'}&#96;</code>. This will be equivalent to
`__('hello %s', 'world')`.
### y18n.\_\_n(singularString, pluralString, count, arg, arg, arg)
Print a localized string with appropriate pluralization. If `%d` is provided
in the string, the `count` will replace this placeholder.
### y18n.setLocale(str)
Set the current locale being used.
### y18n.getLocale()
What locale is currently being used?
### y18n.updateLocale(obj)
Update the current locale with the key value pairs in `obj`.
## Supported Node.js Versions
Libraries in this ecosystem make a best effort to track
[Node.js' release schedule](https://nodejs.org/en/about/releases/). Here's [a
post on why we think this is important](https://medium.com/the-node-js-collection/maintainers-should-consider-following-node-js-release-schedule-ab08ed4de71a).
## License
ISC
[npm-url]: https://npmjs.org/package/y18n
[npm-image]: https://img.shields.io/npm/v/y18n.svg
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg
[standard-url]: https://github.com/feross/standard

View File

@@ -0,0 +1,174 @@
let shim;
class Y18N {
constructor(opts) {
// configurable options.
opts = opts || {};
this.directory = opts.directory || './locales';
this.updateFiles = typeof opts.updateFiles === 'boolean' ? opts.updateFiles : true;
this.locale = opts.locale || 'en';
this.fallbackToLanguage = typeof opts.fallbackToLanguage === 'boolean' ? opts.fallbackToLanguage : true;
// internal stuff.
this.cache = Object.create(null);
this.writeQueue = [];
}
__(...args) {
if (typeof arguments[0] !== 'string') {
return this._taggedLiteral(arguments[0], ...arguments);
}
const str = args.shift();
let cb = function () { }; // start with noop.
if (typeof args[args.length - 1] === 'function')
cb = args.pop();
cb = cb || function () { }; // noop.
if (!this.cache[this.locale])
this._readLocaleFile();
// we've observed a new string, update the language file.
if (!this.cache[this.locale][str] && this.updateFiles) {
this.cache[this.locale][str] = str;
// include the current directory and locale,
// since these values could change before the
// write is performed.
this._enqueueWrite({
directory: this.directory,
locale: this.locale,
cb
});
}
else {
cb();
}
return shim.format.apply(shim.format, [this.cache[this.locale][str] || str].concat(args));
}
__n() {
const args = Array.prototype.slice.call(arguments);
const singular = args.shift();
const plural = args.shift();
const quantity = args.shift();
let cb = function () { }; // start with noop.
if (typeof args[args.length - 1] === 'function')
cb = args.pop();
if (!this.cache[this.locale])
this._readLocaleFile();
let str = quantity === 1 ? singular : plural;
if (this.cache[this.locale][singular]) {
const entry = this.cache[this.locale][singular];
str = entry[quantity === 1 ? 'one' : 'other'];
}
// we've observed a new string, update the language file.
if (!this.cache[this.locale][singular] && this.updateFiles) {
this.cache[this.locale][singular] = {
one: singular,
other: plural
};
// include the current directory and locale,
// since these values could change before the
// write is performed.
this._enqueueWrite({
directory: this.directory,
locale: this.locale,
cb
});
}
else {
cb();
}
// if a %d placeholder is provided, add quantity
// to the arguments expanded by util.format.
const values = [str];
if (~str.indexOf('%d'))
values.push(quantity);
return shim.format.apply(shim.format, values.concat(args));
}
setLocale(locale) {
this.locale = locale;
}
getLocale() {
return this.locale;
}
updateLocale(obj) {
if (!this.cache[this.locale])
this._readLocaleFile();
for (const key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
this.cache[this.locale][key] = obj[key];
}
}
}
_taggedLiteral(parts, ...args) {
let str = '';
parts.forEach(function (part, i) {
const arg = args[i + 1];
str += part;
if (typeof arg !== 'undefined') {
str += '%s';
}
});
return this.__.apply(this, [str].concat([].slice.call(args, 1)));
}
_enqueueWrite(work) {
this.writeQueue.push(work);
if (this.writeQueue.length === 1)
this._processWriteQueue();
}
_processWriteQueue() {
const _this = this;
const work = this.writeQueue[0];
// destructure the enqueued work.
const directory = work.directory;
const locale = work.locale;
const cb = work.cb;
const languageFile = this._resolveLocaleFile(directory, locale);
const serializedLocale = JSON.stringify(this.cache[locale], null, 2);
shim.fs.writeFile(languageFile, serializedLocale, 'utf-8', function (err) {
_this.writeQueue.shift();
if (_this.writeQueue.length > 0)
_this._processWriteQueue();
cb(err);
});
}
_readLocaleFile() {
let localeLookup = {};
const languageFile = this._resolveLocaleFile(this.directory, this.locale);
try {
// When using a bundler such as webpack, readFileSync may not be defined:
if (shim.fs.readFileSync) {
localeLookup = JSON.parse(shim.fs.readFileSync(languageFile, 'utf-8'));
}
}
catch (err) {
if (err instanceof SyntaxError) {
err.message = 'syntax error in ' + languageFile;
}
if (err.code === 'ENOENT')
localeLookup = {};
else
throw err;
}
this.cache[this.locale] = localeLookup;
}
_resolveLocaleFile(directory, locale) {
let file = shim.resolve(directory, './', locale + '.json');
if (this.fallbackToLanguage && !this._fileExistsSync(file) && ~locale.lastIndexOf('_')) {
// attempt fallback to language only
const languageFile = shim.resolve(directory, './', locale.split('_')[0] + '.json');
if (this._fileExistsSync(languageFile))
file = languageFile;
}
return file;
}
_fileExistsSync(file) {
return shim.exists(file);
}
}
export function y18n(opts, _shim) {
shim = _shim;
const y18n = new Y18N(opts);
return {
__: y18n.__.bind(y18n),
__n: y18n.__n.bind(y18n),
setLocale: y18n.setLocale.bind(y18n),
getLocale: y18n.getLocale.bind(y18n),
updateLocale: y18n.updateLocale.bind(y18n),
locale: y18n.locale
};
}

View File

@@ -0,0 +1,19 @@
import { readFileSync, statSync, writeFile } from 'fs';
import { format } from 'util';
import { resolve } from 'path';
export default {
fs: {
readFileSync,
writeFile
},
format,
resolve,
exists: (file) => {
try {
return statSync(file).isFile();
}
catch (err) {
return false;
}
}
};

8
unified-ai-platform/node_modules/y18n/index.mjs generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import shim from './build/lib/platform-shims/node.js'
import { y18n as _y18n } from './build/lib/index.js'
const y18n = (opts) => {
return _y18n(opts, shim)
}
export default y18n

70
unified-ai-platform/node_modules/y18n/package.json generated vendored Normal file
View File

@@ -0,0 +1,70 @@
{
"name": "y18n",
"version": "5.0.8",
"description": "the bare-bones internationalization library used by yargs",
"exports": {
".": [
{
"import": "./index.mjs",
"require": "./build/index.cjs"
},
"./build/index.cjs"
]
},
"type": "module",
"module": "./build/lib/index.js",
"keywords": [
"i18n",
"internationalization",
"yargs"
],
"homepage": "https://github.com/yargs/y18n",
"bugs": {
"url": "https://github.com/yargs/y18n/issues"
},
"repository": "yargs/y18n",
"license": "ISC",
"author": "Ben Coe <bencoe@gmail.com>",
"main": "./build/index.cjs",
"scripts": {
"check": "standardx **/*.ts **/*.cjs **/*.mjs",
"fix": "standardx --fix **/*.ts **/*.cjs **/*.mjs",
"pretest": "rimraf build && tsc -p tsconfig.test.json && cross-env NODE_ENV=test npm run build:cjs",
"test": "c8 --reporter=text --reporter=html mocha test/*.cjs",
"test:esm": "c8 --reporter=text --reporter=html mocha test/esm/*.mjs",
"posttest": "npm run check",
"coverage": "c8 report --check-coverage",
"precompile": "rimraf build",
"compile": "tsc",
"postcompile": "npm run build:cjs",
"build:cjs": "rollup -c",
"prepare": "npm run compile"
},
"devDependencies": {
"@types/node": "^14.6.4",
"@wessberg/rollup-plugin-ts": "^1.3.1",
"c8": "^7.3.0",
"chai": "^4.0.1",
"cross-env": "^7.0.2",
"gts": "^3.0.0",
"mocha": "^8.0.0",
"rimraf": "^3.0.2",
"rollup": "^2.26.10",
"standardx": "^7.0.0",
"ts-transform-default-export": "^1.0.2",
"typescript": "^4.0.0"
},
"files": [
"build",
"index.mjs",
"!*.d.ts"
],
"engines": {
"node": ">=10"
},
"standardx": {
"ignore": [
"build"
]
}
}