initial commit
This commit is contained in:
3
node_modules/i18next/.prettierignore
generated
vendored
Normal file
3
node_modules/i18next/.prettierignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
i18next.js
|
||||
i18next.min.js
|
||||
src/PluralResolver.js
|
8
node_modules/i18next/.prettierrc
generated
vendored
Normal file
8
node_modules/i18next/.prettierrc
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"bracketSpacing": true,
|
||||
"jsxBracketSameLine": false,
|
||||
"printWidth": 100,
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all"
|
||||
}
|
942
node_modules/i18next/CHANGELOG.md
generated
vendored
Normal file
942
node_modules/i18next/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,942 @@
|
||||
### 15.0.9
|
||||
|
||||
- IE: <=IE10 fix (unable to call parent constructor) [1227](https://github.com/i18next/i18next/pull/1227)
|
||||
|
||||
### 15.0.8
|
||||
|
||||
- typescript: adding init function to 3rdParty module typings and enforcing type property [1223](https://github.com/i18next/i18next/pull/1223)
|
||||
|
||||
### 15.0.7
|
||||
|
||||
- typescript: Add useSuspense to ReactOptions, fix error throwing on test [1219](https://github.com/i18next/i18next/pull/1219)
|
||||
|
||||
### 15.0.6
|
||||
|
||||
- typescript: add Interpolator interface [1213](https://github.com/i18next/i18next/pull/1213)
|
||||
|
||||
### 15.0.5
|
||||
|
||||
- typescript: Add `hashTransKey` to `ReactOptions` [1208](https://github.com/i18next/i18next/pull/1208)
|
||||
- Expose error on reloadResources [1212](https://github.com/i18next/i18next/pull/1212)
|
||||
|
||||
### 15.0.4
|
||||
|
||||
- add default export on node.js entry [1204](https://github.com/i18next/i18next/pull/1204)
|
||||
- typescript: Add defaultValue tests and allow second arg string as defaultValue [1206](https://github.com/i18next/i18next/pull/1206)
|
||||
|
||||
### 15.0.3
|
||||
|
||||
- typescript: accept templatestringsarray as TKey [1199](https://github.com/i18next/i18next/pull/1199)
|
||||
- allow arrays on addResources
|
||||
|
||||
### 15.0.2
|
||||
|
||||
- try fixing UMD build
|
||||
|
||||
### 15.0.1
|
||||
|
||||
- fix export name on global (typo)
|
||||
|
||||
### 15.0.0
|
||||
|
||||
- update build process (while all test passes feeling more save making this a major release)
|
||||
|
||||
### 14.1.1
|
||||
|
||||
- allow empty string for array join [1191](https://github.com/i18next/i18next/issues/1191)
|
||||
|
||||
### 14.1.0
|
||||
|
||||
- support plurals in returning objecttree array [1196](https://github.com/i18next/i18next/issues/1196)
|
||||
|
||||
### 14.0.1
|
||||
|
||||
- typescript: Parameterized use of TFunction fails while WithT use works [1188](https://github.com/i18next/i18next/pull/1188)
|
||||
|
||||
### 14.0.0
|
||||
|
||||
- typescript: BREAKING Refactor generics usage [1180](https://github.com/i18next/i18next/pull/1180)
|
||||
|
||||
### 13.1.5
|
||||
|
||||
- es modules: Fix bug when import by ES Module [1179](https://github.com/i18next/i18next/pull/1179)
|
||||
- typescript: Add module property [1176](https://github.com/i18next/i18next/pull/1176)
|
||||
|
||||
### 13.1.4
|
||||
|
||||
- fixes plural rule for JSON compatibility v2 introduced in 11.3.3 https://github.com/i18next/i18next/commit/d4d329fd7042f932eedf8bba1d92234707efd04c#diff-e171f9b8b4e0f5df027bd8bd7b962f1bR1140 [1174](https://github.com/i18next/i18next/issues/1174)
|
||||
|
||||
### 13.1.3
|
||||
|
||||
- TypeScript: Pull up WithT interface allowing for overrides [1172](https://github.com/i18next/i18next/pull/1172)
|
||||
|
||||
### 13.1.2
|
||||
|
||||
- Add typescript testing [1165](https://github.com/i18next/i18next/pull/1165)
|
||||
- Add `transEmptyNodeValue` to `ReactOptions` [1166](https://github.com/i18next/i18next/pull/1166)
|
||||
- Run prettier on typescript files for easier diffing in PRs [1167](https://github.com/i18next/i18next/pull/1167)
|
||||
|
||||
### 13.1.1
|
||||
|
||||
- fix init() attributes typings [1158](https://github.com/i18next/i18next/pull/1158)
|
||||
|
||||
### 13.1.0
|
||||
|
||||
- Support interpolation for defaultValue as parameter [1151](https://github.com/i18next/i18next/pull/1151)
|
||||
|
||||
### 13.0.1
|
||||
|
||||
- update typedefinitions [1152](https://github.com/i18next/i18next/pull/1152)
|
||||
|
||||
### 13.0.0
|
||||
|
||||
- pass options to missingInterpolationHandler [1146](https://github.com/i18next/i18next/pull/1146)
|
||||
- refactor non valid keys handling [1143](https://github.com/i18next/i18next/pull/1143)
|
||||
|
||||
BREAKING:
|
||||
|
||||
- adds typescript definitions directly into this repo - no longer need to grab them from definitlytyped [1142](https://github.com/i18next/i18next/pull/1142)
|
||||
- promise API added for all functions providing a callback [1130](https://github.com/i18next/i18next/pull/1130) -> means those will now return a Promise and not this -> so you can't chain eg. i18next.init().on() anylonger as init returns a Promise
|
||||
|
||||
### 12.1.0
|
||||
|
||||
- adds partialBundledLanguages flag in init options [1136](https://github.com/i18next/i18next/pull/1136)
|
||||
|
||||
### 12.0.0
|
||||
|
||||
- add hebrew update [1121](https://github.com/i18next/i18next/pull/1121)
|
||||
|
||||
### 11.10.2
|
||||
|
||||
- revert hebrew
|
||||
|
||||
### 11.10.1
|
||||
|
||||
- Adds Hebrew plural support [1121](https://github.com/i18next/i18next/pull/1121)
|
||||
|
||||
### 11.10.0
|
||||
|
||||
- Allow missingInterpolationHandler to be provided as t() option [1118](https://github.com/i18next/i18next/pull/1118)
|
||||
|
||||
### 11.9.1
|
||||
|
||||
- fixes allow overriding of fallbackLng when in options passed to t functions call
|
||||
|
||||
### 11.9.0
|
||||
|
||||
- merge load and reloadResources functionality to allow an optional callback in reloadResources
|
||||
|
||||
### 11.8.0
|
||||
|
||||
- deeper support for i18nFormats - add getResource function from format
|
||||
|
||||
### 11.7.0
|
||||
|
||||
- allows defining defaultValues for plurals -> same logic as using pluralsuffixes in translation files [details](https://www.i18next.com/translation-function/plurals#how-to-find-the-correct-plural-suffix) using eg. defaultValue_plural / defaultValue_2 based on request [1096](https://github.com/i18next/i18next/issues/1096)
|
||||
|
||||
### 11.6.0
|
||||
|
||||
- expose new store function getDataByLanguage [1087](https://github.com/i18next/i18next/pull/1087)
|
||||
|
||||
### 11.5.0
|
||||
|
||||
- EventEmitter.prototype.on returns this for chaining calls [1079](https://github.com/i18next/i18next/pull/1079)
|
||||
|
||||
### 11.4.0
|
||||
|
||||
- Allow to pass raw value to the custom interpolation escape function [1076](https://github.com/i18next/i18next/pull/1076)
|
||||
|
||||
### 11.3.6
|
||||
|
||||
- fix support zero for saveMissing plurals [1072](https://github.com/i18next/i18next/pull/1072)
|
||||
|
||||
### 11.3.5
|
||||
|
||||
- trigger loaded event only once per loaded namespace - consolidate all the loaded and done queued load calls [react-i18next 456 ](https://github.com/i18next/react-i18next/issues/456)
|
||||
|
||||
### 11.3.4
|
||||
|
||||
- fixes simplifyPluralSuffix: false cases for languages having only singular, plural [1069](https://github.com/i18next/i18next/issues/1069)
|
||||
|
||||
### 11.3.3
|
||||
|
||||
- pass down resolved to i18nFormat.parse as last argument
|
||||
|
||||
### 11.3.2
|
||||
|
||||
- Properly handle arguments containing arrays while listening to a wildcard event [1052](https://github.com/i18next/i18next/pull/1052)
|
||||
|
||||
### 11.3.1
|
||||
|
||||
- Fixes allowing setting keySeparator to false in calling t function [1051](https://github.com/i18next/i18next/pull/1051)
|
||||
|
||||
### 11.3.0
|
||||
|
||||
- Option to skip interpolation when calling t. [1050](https://github.com/i18next/i18next/pull/1050)
|
||||
|
||||
### 11.2.3
|
||||
|
||||
- Remove unnecessary warning when value is empty string [1046](https://github.com/i18next/i18next/pull/1046)
|
||||
|
||||
### 11.2.2
|
||||
|
||||
- adds used key to call parse of i18nFormat
|
||||
|
||||
### 11.2.1
|
||||
|
||||
- fixes for i18nFormat plugin
|
||||
|
||||
### 11.2.0
|
||||
|
||||
- allows new plugin of type 'i18nFormat' to override i18next format with eg. ICU format
|
||||
|
||||
### 11.0.0 - 11.1.1 (fixing version mismatch cdn.js - npm)
|
||||
|
||||
- **[BREAKING]** removes plugin of type cache. Can be replace by [i18next-chained-backend](https://github.com/i18next/i18next-chained-backend) example cache for localStorage [i18next-localstorage-backend](https://github.com/i18next/i18next-localstorage-backend#getting-started)
|
||||
- **[BREAKING]** removes the support for multiload (multiRead) in backends - will just use read per language-namespace. You can enable multiRead support in backends again by using [i18next-multiload-backend-adapter](https://github.com/i18next/i18next-multiload-backend-adapter)
|
||||
|
||||
### 10.6.0
|
||||
|
||||
- adds missingInterpolationHandler [1039](https://github.com/i18next/i18next/pull/1039)
|
||||
|
||||
### 10.5.1
|
||||
|
||||
- fixes call to getPluralFormsOfKey if called with unsupported language [1032](https://github.com/i18next/i18next/issues/1032)
|
||||
- Avoid mutating whitelist array. [1037](https://github.com/i18next/i18next/pull/1037)
|
||||
|
||||
### 10.5.0
|
||||
|
||||
- Adds options.silent to addResources and addResourceBundle [1024](https://github.com/i18next/i18next/pull/1024)
|
||||
|
||||
### 10.4.1
|
||||
|
||||
- forward options in backend.create saveMissing
|
||||
|
||||
### 10.4.0
|
||||
|
||||
- fixes combination of returnObject and context by returning original value for deep translation when lookup for inner returns a key (failed to translate proper) [1014](https://github.com/i18next/i18next/issues/1014)
|
||||
- _[EXPERIMENTAL]_ additional you can pass `tDescription` to the `t` options or as a third param to calling `t` -> `t(key, defaultValue, tDescription);`. Those will get forwarded to the backend and can be submitted on saveMissing to provide contextual information for translators.
|
||||
|
||||
### 10.3.0
|
||||
|
||||
- new option saveMissingPlurals (default true) will enable submitting plural forms on saveMissing if t call is for plural (count passed in options).
|
||||
|
||||
### 10.2.2
|
||||
|
||||
- fixes Context and nested lost initial options [1009](https://github.com/i18next/i18next/issues/1009)
|
||||
|
||||
### 10.2.1
|
||||
|
||||
- optimize update output in log
|
||||
|
||||
### 10.2.0
|
||||
|
||||
- _[EXPERIMENTAL]_ init option updateMissing: enable to update default values if different from translated value (only useful on initial development or when keeping code as source of truth not changing values outside of code)
|
||||
|
||||
### 10.1.0
|
||||
|
||||
- return boolean, number from translator
|
||||
- initial set language on translator if non set yet (after that only if loaded) [#998](https://github.com/i18next/i18next/issues/998)
|
||||
|
||||
### 10.0.7
|
||||
|
||||
- support all overloadTranslationOptionHandler in getFixedT [react-i18next/issues/332](https://github.com/i18next/react-i18next/issues/332)
|
||||
|
||||
### 10.0.6
|
||||
|
||||
- native browser es modules via adding .js where needed [PR980](https://github.com/i18next/i18next/pull/980)
|
||||
|
||||
### 10.0.5
|
||||
|
||||
- should fix sync of options in clone and its translator
|
||||
|
||||
### 10.0.2
|
||||
|
||||
- fixes issue in object return when passing in multiple keys
|
||||
|
||||
### 10.0.1
|
||||
|
||||
- fixes support for using suffix `_0` on languages only having "singular" form
|
||||
|
||||
### 10.0.0
|
||||
|
||||
- **[BREAKING]** brings pt, pt-PT, pt-BR plurals in line with, new pt reflects pt-BR and pt-PT gets a special case for plural handling http://www.unicode.org/cldr/charts/26/supplemental/language_plural_rules.html
|
||||
|
||||
### 9.1.0
|
||||
|
||||
- support for using suffix `_0` on languages only having "singular" form enables easier convert in tool chains
|
||||
|
||||
### 9.0.1
|
||||
|
||||
- propagate changeLanguage to translator after loadResources
|
||||
|
||||
### 9.0.0
|
||||
|
||||
- **[BREAKING]** removes the compatibility options to i18next v1 you can add that back like we do in our backward compatibility tests: [https://github.com/i18next/i18next/blob/master/test/backward/v1.11.1.compat.js#L45-L52](https://github.com/i18next/i18next/blob/master/test/backward/v1.11.1.compat.js#L45-L52)
|
||||
- removes the compatibility options to i18next v1
|
||||
- allows passing in second param as string on getFixedT returned t function so we could use that as defaultValue
|
||||
- add setting maxReplaces in interpolation options to prevent endless loop in interpolation
|
||||
|
||||
### 8.4.3
|
||||
|
||||
- getFixedT lng parameter of array type -> pass as lngs to t function [PR949](https://github.com/i18next/i18next/pull/949)
|
||||
|
||||
### 8.4.2
|
||||
|
||||
- fixes merging options in clone instance...do not override passed values by values on main instance
|
||||
|
||||
### 8.4.1
|
||||
|
||||
- emits correct lng to changeLanguage event (fixes async detection behaviour) [PR933](https://github.com/i18next/i18next/pull/933)
|
||||
|
||||
### 8.4.0
|
||||
|
||||
- expose i18next.options.interpolation.format on i18next.format
|
||||
- i18next.dir if not passing lng use first of i18next.languages before using i18next.language
|
||||
|
||||
### 8.3.0
|
||||
|
||||
- allows nesting objects/arrays into objects [#925](https://github.com/i18next/i18next/issues/925)
|
||||
|
||||
### 8.2.1
|
||||
|
||||
- fixes issue in async lng detection
|
||||
|
||||
### 8.2.0
|
||||
|
||||
- supports now async language detection - when language detector has member async = true
|
||||
|
||||
### 8.1.0
|
||||
|
||||
- option to disable nesting by calling `i18next.t('key', { nest: false })` [PR920](https://github.com/i18next/i18next/pull/920)
|
||||
- fixes passing lng from options to formatter function if available
|
||||
|
||||
### 8.0.0
|
||||
|
||||
- nonExplicitWhitelist flag now not only gets considered on a fallback lng but also on user language. Eg. userlng 'de-AT' and whitelist ['de'] will now let de-AT pass as whitelisted if nonExplicitWhitelist is set true.
|
||||
|
||||
### 7.2.3
|
||||
|
||||
- rebuild seems we had a mistake in pushing latest build
|
||||
|
||||
### 7.2.2
|
||||
|
||||
- fixes issue in accepting string as a result of "nested" lookup [PR909](https://github.com/i18next/i18next/pull/909)
|
||||
|
||||
### 7.2.1
|
||||
|
||||
- fixes iterating over object's own properties [#904](https://github.com/i18next/i18next/pull/904)
|
||||
|
||||
### 7.2.0
|
||||
|
||||
- new init option simplifyPluralSuffix - setting it to false will treat all plurals using suffix numbers even for locals only having singular and plural
|
||||
- even if no lng set or detected at least load the fallback languages
|
||||
- delay init call on createInstance if not set initImmediate to false [#879](https://github.com/i18next/i18next/issues/879)
|
||||
|
||||
### 7.1.3
|
||||
|
||||
- fixes issue in returnObject tree called with options including ns: [react-i18next #240](https://github.com/i18next/react-i18next/issues/240)
|
||||
|
||||
### 7.1.2
|
||||
|
||||
- remove regex escape from format separators [#896](https://github.com/i18next/i18next/pull/896)
|
||||
|
||||
### 7.1.1
|
||||
|
||||
- change to named plugins for 3rd party - just calling init
|
||||
|
||||
### 7.1.0
|
||||
|
||||
- add option to include plugins not directly related - they get called their init function with current instance of i18next on init
|
||||
|
||||
### 7.0.1
|
||||
|
||||
- fix issue in fallback lng detection if no code was detected
|
||||
- check for having a lng in append when searching locals to load on loadResources - avoid error on express middleware
|
||||
|
||||
### 7.0.0
|
||||
|
||||
- [BREAKING] Removed special cases for norwegian which resolved nb-NO to nb-NO, no will now resolve to nb-NO, nb [#870](https://github.com/i18next/i18next/issues/870) using norwegian you could migrate to old behaviour like:
|
||||
|
||||
fallbackLng: {
|
||||
'nb': ['no', 'en'],
|
||||
'nn': ['no', 'en'],
|
||||
'default': ['en']
|
||||
}
|
||||
|
||||
- adding exports for named import (destruction es6) [#873](https://github.com/i18next/i18next/issues/873)
|
||||
- change entry point for umd build to /src/i18next to avoid mixed export
|
||||
- replace cloning in interpolation nesting to use object assign instead of json.stringify/parse so circular structures can be used [#875](https://github.com/i18next/i18next/issues/875)
|
||||
- update all build dependencies
|
||||
|
||||
### 6.1.2
|
||||
|
||||
- fixes fix in 6.1.1
|
||||
|
||||
### 6.1.1
|
||||
|
||||
- patching same separators to lookup if the ns exists - else guess the first item is just part of the key and not meant as a namespace
|
||||
|
||||
### 6.1.0
|
||||
|
||||
- you now can use same nsSeparator and keySeparator (eg. use a dot for both)
|
||||
|
||||
### 6.0.3
|
||||
|
||||
- do not loop over objectTree if keySeparator is set to false
|
||||
|
||||
### 6.0.2
|
||||
|
||||
- fixes init flow of clone
|
||||
|
||||
### 6.0.1
|
||||
|
||||
- fixes issue in event emitter, assert all emitters get called even if one called get removed and changes the array index
|
||||
|
||||
### 6.0.0
|
||||
|
||||
- Return namespace in cimode with appendNamespaceToCIMode option (default now will only return key without namespace - independent of call to t function) [#863](https://github.com/i18next/i18next/issues/863)
|
||||
|
||||
### 5.0.0
|
||||
|
||||
- Nested keys should not be escaped by default [#854](https://github.com/i18next/i18next/issues/854)
|
||||
- Make sure i18next.init() runs for i18next.cloneInstance() [#860](https://github.com/i18next/i18next/pull/860)
|
||||
|
||||
### 4.2.0
|
||||
|
||||
- adds i18next.isInitialized when isInitialized
|
||||
- triggers backend loaded event before initialized
|
||||
|
||||
### 4.1.3 / 4.1.4
|
||||
|
||||
- smaller changes suggested to still inofficial support ie8 [#852](https://github.com/i18next/i18next/issues/852)
|
||||
|
||||
### 4.1.2
|
||||
|
||||
- fixes same interpolation object with multiple getFixedT() in different locales yields wrong translation [#851](https://github.com/i18next/i18next/issues/851)
|
||||
- updated all build deps
|
||||
|
||||
### 4.1.1
|
||||
|
||||
- remove subs array from logger - no longer keep changing debug flag on subs if changing on main
|
||||
|
||||
### 4.1.0
|
||||
|
||||
- Custom escape function, single-quotes in nested [#843](https://github.com/i18next/i18next/pull/843)
|
||||
|
||||
### 4.0.0
|
||||
|
||||
- [BREAKING; only webpack2-beta users] will add module entry point used by webpack2, this might break your current build with webpack2-beta if configured incorrectly, see: [#836](https://github.com/i18next/i18next/issues/836)
|
||||
|
||||
### 3.5.2
|
||||
|
||||
- remove the module entry point again will be added in 4.0.0
|
||||
|
||||
### 3.5.1
|
||||
|
||||
- fix build output add a test file to test the generated build
|
||||
|
||||
### 3.5.0
|
||||
|
||||
- Setting options on individual translations override, rather than merge global configs [#832](https://github.com/i18next/i18next/issues/832)
|
||||
- Create an new translator when cloning i18next instance [#834](https://github.com/i18next/i18next/pull/834)
|
||||
- allows fallbackLng to be an string, an array or an object defining fallbacks for lng, lng-region plus default, eg
|
||||
|
||||
fallbackLng: {
|
||||
'de-CH': ['fr', 'it', 'en'],
|
||||
'de': ['fr', 'en'],
|
||||
'zh-Hans': ['zh-Hant', 'en'],
|
||||
'zh-Hant': ['zh-Hans', 'en'],
|
||||
'default': ['en']
|
||||
}
|
||||
|
||||
### 3.4.4
|
||||
|
||||
- Fix Interpolator.escapeValue defaulting to undefined in some cases [#826](https://github.com/i18next/i18next/issues/826)
|
||||
|
||||
### 3.4.3
|
||||
|
||||
- Fix Interpolator formatter exception error propagation due to not reset RegExp indices [#820](https://github.com/i18next/i18next/issues/820)
|
||||
|
||||
### 3.4.2
|
||||
|
||||
- assert dir function does not crash if no language available
|
||||
|
||||
### 3.4.1
|
||||
|
||||
- fix issue with format containing formatSeparator for interpolation formatting
|
||||
|
||||
### 3.4.0
|
||||
|
||||
- adds formatting 'format this: {{var, formatRule}}' having a function on options.interpolation.format: function(value, format, lng) { return value } like suggested here [#774](https://github.com/i18next/i18next/issues/774)
|
||||
|
||||
### 3.3.1
|
||||
|
||||
- fixed an issue with several unescaped key in the interpolation string [#746](https://github.com/i18next/i18next/pull/746)
|
||||
|
||||
### 3.3.0
|
||||
|
||||
- allows option `nonExplicitWhitelist` on init [#741](https://github.com/i18next/i18next/pull/741)
|
||||
|
||||
### 3.2.0
|
||||
|
||||
- adds api function i18next.reloadResources(), i18next.reloadResources(lngs, ns) to trigger a reload of translations
|
||||
|
||||
### 3.1.0
|
||||
|
||||
- emits missingKey always (like console.log) even if saveMissing is of -> use missingKeyHandler if you only want the trigger only on saveMissing: true
|
||||
|
||||
### 3.0.0
|
||||
|
||||
- **[BREAKING]** per default i18next uses now the same index as used in gettext for plurals. eg. for arabic suffixes are 0,1,2,3,4,5 instead of 0,1,2,3,11,100. You can enforce old behaviour by setting compatibilityJSON = 'v2' on i18next init.
|
||||
- **[BREAKING]** AMD export will be unnamed now
|
||||
- don't call saveMissing if no lng
|
||||
|
||||
### 2.5.1
|
||||
|
||||
- fixes rtl support [#656](https://github.com/i18next/i18next/pull/656/files)
|
||||
|
||||
### 2.5.0
|
||||
|
||||
- allow null or empty string as defaultValue
|
||||
- init option `initImmediate (default: true)` to init without immediate
|
||||
|
||||
### 2.4.1
|
||||
|
||||
- if passing resources don't immediate loading fixes [#636](https://github.com/i18next/i18next/issues/636)
|
||||
|
||||
### 2.4.0
|
||||
|
||||
- support now language code variants with scripts and other exotic forms: zh-Hans-MO, sgn-BE-fr, de-AT-1996,...
|
||||
- trigger of changeLanguage, load of data with a setTimeout to allow other operations meanwhile
|
||||
|
||||
### 2.3.5
|
||||
|
||||
- Only add language to preload array when new [#613](https://github.com/i18next/i18next/pull/613/files)
|
||||
|
||||
### 2.3.4
|
||||
|
||||
- get babel 6 output IE compatible: https://jsfiddle.net/jamuhl/2qc7oLf8/
|
||||
|
||||
### 2.3.2
|
||||
|
||||
- add index to make export compatible again
|
||||
|
||||
### 2.3.1
|
||||
|
||||
- build /dist/es with included babelhelpers
|
||||
|
||||
### 2.3.0
|
||||
|
||||
- change build chain to use rollup...allows 'js:next' and reduces build from 45kb to 33kb minified (/lib --> /dist/commonjs folder, new /dist/es for rollup,...)
|
||||
- fixes detection when using both context and pluralization and context not found. [#851](https://github.com/i18next/i18next/pull/581)
|
||||
|
||||
### 2.2.0
|
||||
|
||||
- return instance after init for further chaning
|
||||
- make init optional on backend, cache
|
||||
- package.json entry points now to /lib not to mangled version...this might be the better solution for most use cases (build chains built on npm, webpack, browserify, node,...)
|
||||
|
||||
### 2.1.0
|
||||
|
||||
- allow keySeparator, nsSeparator = false to turn that off
|
||||
|
||||
### 2.0.26
|
||||
|
||||
- extended emitted arguments on 'added' event
|
||||
|
||||
### 2.0.24
|
||||
|
||||
- fixes unneeded reload of resources that failed to load
|
||||
|
||||
### 2.0.23
|
||||
|
||||
- fixes returnObjects in case of multiple namespaces
|
||||
|
||||
### 2.0.22
|
||||
|
||||
- add options for context, pluralSeparator
|
||||
|
||||
### 2.0.21
|
||||
|
||||
- clear done load request in backendConnector
|
||||
|
||||
### 2.0.20
|
||||
|
||||
- pass full options to detectors as third arg
|
||||
|
||||
### 2.0.19
|
||||
|
||||
- do not callback err in backendConnector if no backend is specified
|
||||
|
||||
### 2.0.18
|
||||
|
||||
- check for fallbackLng exist
|
||||
|
||||
### 2.0.17
|
||||
|
||||
- adds cimode to options.whitelist if set
|
||||
- emits failedLoading on load error
|
||||
|
||||
### 2.0.16
|
||||
|
||||
- adds addResource to i18next API
|
||||
- fix init of i18next without options, callback
|
||||
|
||||
### 2.0.15
|
||||
|
||||
- avoid loading of resources for lng=cimode
|
||||
|
||||
### 2.0.14
|
||||
|
||||
- enhance callback on load from backend...wait for pendings
|
||||
|
||||
### 2.0.10
|
||||
|
||||
- fixing build chain
|
||||
- do not post process on nested translation resolve
|
||||
|
||||
### 2.0.5
|
||||
|
||||
- fixing allow nesting on interpolated nesting vars
|
||||
|
||||
### 2.0.4
|
||||
|
||||
- don't log lng changed if no lng was detected
|
||||
- extend result on arrayJoins
|
||||
|
||||
### 2.0.1
|
||||
|
||||
- assert defaults are arrays where needed
|
||||
- assert calling lngUtils.toResolveHierarchy does not add undefined as code if called without code param
|
||||
|
||||
### 2.0.0
|
||||
|
||||
- complete rewrite of i18next codebase
|
||||
|
||||
---
|
||||
|
||||
### 1.11.2
|
||||
|
||||
- replace forEach loop to support IE8 [PR 461](https://github.com/i18next/i18next/pull/461)
|
||||
|
||||
### 1.11.1
|
||||
|
||||
- fixes issue in nesting using multiple namespaces and lookups in fallback namespaces
|
||||
- Fix use of sprintf as shortcutFunction when first argument falsey [PR 453](https://github.com/i18next/i18next/pull/453)
|
||||
|
||||
### 1.11.0
|
||||
|
||||
- Add nsseparator and keyseparator as options to translation function [PR 446](https://github.com/i18next/i18next/pull/446)
|
||||
- Resolves issue #448 - TypeScript errors [PR 449](https://github.com/i18next/i18next/pull/449)
|
||||
- Fixing \_deepExtend to handle keys deep existing in source and target [PR 444](https://github.com/i18next/i18next/pull/444)
|
||||
- `resource` to `resources` in addResources function [PR 440](https://github.com/i18next/i18next/pull/440)
|
||||
- Runs multiple post processes for missing translations [PR 438](https://github.com/i18next/i18next/pull/438)
|
||||
- Add support to override Ajax HTTP headers [PR 431](https://github.com/i18next/i18next/pull/431)
|
||||
- Fixed mnk plural definition [PR 427](https://github.com/i18next/i18next/pull/427)
|
||||
- Add dir function to return directionality of current language, closes… [PR 413](https://github.com/i18next/i18next/pull/413)
|
||||
|
||||
### 1.10.3
|
||||
|
||||
- fixes issue where lng get fixed on data-i18n-options
|
||||
- [SECURITY] merges Reimplement XSS-vulnerable sequential replacement code [PR 443](https://github.com/i18next/i18next/pull/443)
|
||||
|
||||
### 1.10.2
|
||||
|
||||
- streamline callback(err, t) for case where resStore is passed in
|
||||
|
||||
### 1.10.1
|
||||
|
||||
- fixes Adds jquery like functionality without the jquery plugin. [PR 403](https://github.com/i18next/i18next/pull/403) by adding it to output
|
||||
|
||||
### 1.10.0
|
||||
|
||||
- [BREAKING] new callbacks will be node.js conform function(err, t) | Forward the error from sync fetch methods to the init callback function [PR 402](https://github.com/i18next/i18next/pull/402)
|
||||
- fix fallback lng option during translations [PR 399](https://github.com/i18next/i18next/pull/399)
|
||||
- Adds jquery like functionality without the jquery plugin. [PR 403](https://github.com/i18next/i18next/pull/403)
|
||||
|
||||
### 1.9.1
|
||||
|
||||
- fix fallback lng option during translations [PR 399](https://github.com/i18next/i18next/pull/399)
|
||||
- Adds jquery like functionality without the jquery plugin. [PR 403](https://github.com/i18next/i18next/pull/403)
|
||||
|
||||
### 1.9.0
|
||||
|
||||
- i18n.noConflict() [PR 371](https://github.com/i18next/i18next/pull/371)
|
||||
- fix fallback to default namepsace when namespace passed as an option [PR 375](https://github.com/i18next/i18next/pull/375)
|
||||
- cache option for ajax requests [PR 376](https://github.com/i18next/i18next/pull/376)
|
||||
- option to show key on value is empty string [PR 379](https://github.com/i18next/i18next/pull/379)
|
||||
- Add isInitialized method [PR 380](https://github.com/i18next/i18next/pull/380)
|
||||
- Null check for detectLngFromLocalStorage [PR 384](https://github.com/i18next/i18next/pull/384)
|
||||
- support for adding timeout in configuration for ajax request [PR 387](https://github.com/i18next/i18next/pull/387)
|
||||
|
||||
### 1.8.2
|
||||
|
||||
- fixes build of commonjs with jquery file
|
||||
|
||||
### 1.8.0
|
||||
|
||||
- [BREAKING] adds custom build for commonjs with jquery...default will be without require for jquery
|
||||
- fixes issue [issue 360](https://github.com/i18next/i18next/issues/360)
|
||||
- expose applyReplacement on api
|
||||
- save resources to localStorage when useLocaleStore is true
|
||||
- add support on key is a number
|
||||
- added getResourceBundle to API
|
||||
- allow multiple post-processors
|
||||
- fallback to singular if no plural is found fixes issue [issue 356](https://github.com/i18next/i18next/issues/356)
|
||||
- access localstorage always with try catch fixes issue [issue 353](https://github.com/i18next/i18next/issues/353)
|
||||
|
||||
### 1.7.7
|
||||
|
||||
- fixes issue with stack overflow on t(lng, count)
|
||||
- fixes empty value fallback when processing secondary ns
|
||||
|
||||
### 1.7.6
|
||||
|
||||
- fixes lng detection (i18next-client on npm)
|
||||
|
||||
### 1.7.5
|
||||
|
||||
- adds option to define defaultOptions, which gets merged into t(options) [issue 307](https://github.com/i18next/i18next/issues/307)
|
||||
- optimization of size added by plural rules
|
||||
- handle error on json parse when using internal xhr
|
||||
- fixes plural/singular on count if going on fallbacks eg. fr --> en
|
||||
- fixes global leak of sync in amd versions
|
||||
- apply options.lowerCaseLng to fallbackLng too
|
||||
- added hasResourceBundle(lng, ns) to check if bundle exists
|
||||
- added experimental i18n.sync.reload --> resets resStore and reloads resources
|
||||
- catch issues with localStorage quota
|
||||
- changes detectlanguage to support whitelist entries
|
||||
|
||||
### 1.7.4
|
||||
|
||||
- add resource bundle gets deep extend flag i18n.addResourceBundle(lng, ns, { 'deep': { 'key2': 'value2' }}, true);
|
||||
- new functions to add one key value or multiple i18n.addResource(lng, ns, key, value);, i18n.addResources(lng, ns, {'key1': 'value1', 'deep.key2': 'value2'});
|
||||
- lngWhitelist merged
|
||||
- override postMissing function
|
||||
- allow floats for count
|
||||
- added indefinite functionality for plurals
|
||||
- optional set replacing vars to replace member to avoid collision with other options
|
||||
- experimental optional detectLngFromLocalStorage
|
||||
- fix for norwegian language
|
||||
|
||||
### 1.7.3
|
||||
|
||||
- solves issue with ie8 not providing .trim function on string -> added to shim
|
||||
- set data using \$(selector).i18n() on data-i18n='[data-someDataAttr]key'
|
||||
- more bullet proof state handling on failed file load
|
||||
- corrected latvian plurals based on [issue 231](https://github.com/jamuhl/i18next/issues/231)
|
||||
- allow array of fallback languages
|
||||
- allow int in values passed to shortcut sprintf
|
||||
- setLng to 'cimode' will trigger a CI mode returning 'key' instead of translation
|
||||
|
||||
### 1.7.2
|
||||
|
||||
- introducing option fallbackOnEmpty -> empty string will fallback
|
||||
- added function removeResourceBundle(lng, ns) -> removes a resource set
|
||||
- fixed issue with no option passed to setLng
|
||||
- added ability to prepend, append content with data-i18n attributes
|
||||
- introducing objectTreeKeyHandler
|
||||
- fixes issue with i18n.t(null), i18n.t(undefined) throwing exception
|
||||
- returnObjectTrees does not mangle arrays, functions, and regexps
|
||||
- optimized structure for bower support
|
||||
|
||||
### 1.7.1
|
||||
|
||||
- fixed some typo
|
||||
- allow translate to take an array of keys - take first found
|
||||
- allow numbers in object trees
|
||||
|
||||
### 1.7.0
|
||||
|
||||
- test if initialisation finished before allowing calling t function
|
||||
- setting option fixLng=true will return t function on init or setLng with the lng fixed for every subsequent call to t
|
||||
- grab key from content if attr data-i18n has no value
|
||||
- setting shortcutFunction to 'defaultValue' allows calling i18n.t(key, defaultValue)
|
||||
- empty string in defaultValue is now valid no longer displaying key
|
||||
- allow option cookieDomain
|
||||
- fixes issue #115 out of stack exception in IE8 by recursing \_translate in objectTrees
|
||||
|
||||
### 1.6.3
|
||||
|
||||
- option to parse key if missing
|
||||
- fixes issue where plural don't get translated if language is passed in t options
|
||||
- fixes issue where key or defaultValue aren't postProcessed with itself as value
|
||||
- fixes issue with fallbackLng = false in combination with sendMissingTo = fallback
|
||||
- fixes namespace fallback loop to only loop if array has really a ns in it
|
||||
|
||||
### 1.6.2
|
||||
|
||||
- fixes some var typo
|
||||
- fixes sendMissing to correct namespace
|
||||
- fixes sendMissing in combination with fallbackNS
|
||||
|
||||
### 1.6.1
|
||||
|
||||
- PR #106 optionally un/escape interpolated content
|
||||
- PR #101 automatic gettext like sprintf syntax detection + postprocess injection
|
||||
- customload will get called on dynamicLoad too
|
||||
- fixes namespace array settings if loaded resourcebundle or additional namespaces
|
||||
- lookup of not existend resouces can be fallbacked to other namespaces - see option fallbackNS (array or string if one ns to fallback to)
|
||||
- defaultValues get postProcessed
|
||||
- BREAKING: per default null values in resources get translated to fallback. This can be changed by setting option fallbackOnNull to false
|
||||
- PR #81 added support for passing options to nested resources
|
||||
- PR #88 added an exists method to check for the existence of a key in the resource store
|
||||
- fixed issue with null value throws in applyReplacement function
|
||||
- fixed issue #80 empty string lookup ends in fallback instead of returning result in language
|
||||
- fixed issue with null value in resources not returning expected value
|
||||
- optimized tests to use on server (nodejs) too
|
||||
- allow zepto as drop in replacement for \$
|
||||
- using testacular as runner
|
||||
- upgraded to grunt 0.4.0
|
||||
- fixed optional interpolation prefix/suffix not used in plural translation cases
|
||||
- optimized check if there are multiple keys for the data-i18n attribute to parse
|
||||
|
||||
### 1.6.0
|
||||
|
||||
- option to specify target to set attributes with jquery function by using 'data-i18n-target attribute'
|
||||
- function to set new options for nesting functionality
|
||||
- function to add resources after init
|
||||
- option to lookup in default namespace if value is not found in given namespace
|
||||
- option to change interpolation prefix and suffix via translation options
|
||||
- fixed issue with using ns/keyseparator on plurals, context,...
|
||||
- fixed issue with posting missing when not using jquery
|
||||
- post missing in correct lng if lng is given in translation options
|
||||
- proper usage of deferred object in init function
|
||||
- fixed issue replacing values in objectTree
|
||||
|
||||
### 1.5.10
|
||||
|
||||
- BREAKING: fixed plural rules for languages with extended plural forms (more than 2 forms)
|
||||
- merged pull #61 - custom loader (enables jsonp or other loading custom loading strategies)
|
||||
- escaping interpolation prefix/suffix for proper regex replace
|
||||
|
||||
### 1.5.9
|
||||
|
||||
- functions to load additional namespaces after init and to set default namespace to something else
|
||||
- set if you don't want to read defaultValues from content while using jquery fc
|
||||
- set dataAttribute to different value
|
||||
- set cookieName to different value
|
||||
- some smallbugfixes
|
||||
- typesafe use of console if in debug mode
|
||||
|
||||
### 1.5.8
|
||||
|
||||
- disable cookie usage by setting init option useCookie to false
|
||||
- accept empty string as translation value
|
||||
- fixed bug in own ajax implementation not using proper sendType
|
||||
- fixed bug for returning objTree in combination with namespace
|
||||
- fixed bug in plurals of romanic lngs
|
||||
|
||||
### 1.5.7
|
||||
|
||||
- pass namespace in t() options
|
||||
- interpolation nesting
|
||||
- changable querystring param to look language up from
|
||||
|
||||
### 1.5.6
|
||||
|
||||
- typesafe check for window, document existance
|
||||
- runnable under rhino
|
||||
- seperated amd builds with/without jquery
|
||||
|
||||
### 1.5.5
|
||||
|
||||
- **BREAKING** added all plurals: suffixes will new be same as in gettext usage (number indexes key_plural_0|2|3|4|5|7|8|10|11|20|100), additional if needed signature of addRule has changed
|
||||
- added sprintf as postprocessor -> postProcess = 'sprintf' and sprintf = obj or array
|
||||
- set default postProcessor on init
|
||||
- redone build process with grunt
|
||||
- drop in replacement for jquery each, extend, ajax
|
||||
- setting fallbackLng to false will stop loading and looking it up
|
||||
- option to load only current or unspecific language files
|
||||
|
||||
### 1.5.0
|
||||
|
||||
- pass options to sync.\_fetchOne, use options for fetching
|
||||
- support for i18next-webtranslate
|
||||
|
||||
### 1.4.1
|
||||
|
||||
- post processor
|
||||
- **BREAKING:** localStorage defaults to false
|
||||
- added localStorageExpirationTime for better caching control
|
||||
- few bug fixes
|
||||
|
||||
### 1.4.0
|
||||
|
||||
- preload multiple languages
|
||||
- translate key to other language than current
|
||||
- fixed issue with namespace usage in combination with context and plurals
|
||||
- more options to send missing values
|
||||
- better amd support
|
||||
|
||||
### 1.3.4
|
||||
|
||||
- set type of ajax request to GET (options sendType: default POST)
|
||||
- set cookie expiration (options cookieExpirationTime: in minutes)
|
||||
- read / cache translation options (context, count, ...) in data-attribute (options useDataAttrOptions: default false)
|
||||
|
||||
### 1.3.3
|
||||
|
||||
- optional return an objectTree from translation
|
||||
- use jquery promises or callback in initialisation
|
||||
- rewrote all tests with mocha.js
|
||||
|
||||
### 1.3.2
|
||||
|
||||
- options to init i18next sync (options -> getAsync = false)
|
||||
- replace all occurence of replacement string
|
||||
|
||||
### 1.3.1
|
||||
|
||||
- pass options to selector.i18n() thanks to [@hugojosefson](https://github.com/jamuhl/i18next/pull/10)
|
||||
- close [issue #8(https://github.com/jamuhl/i18next/issues/8)]: Fail silently when trying to access a path with children
|
||||
- cleanup
|
||||
- debug flag (options.debug -> write infos/errors to console)
|
||||
|
||||
### 1.2.5
|
||||
|
||||
- fix for IE8
|
||||
|
||||
### 1.2.4
|
||||
|
||||
- added indexOf for non ECMA-262 standard compliant browsers (IE < 9)
|
||||
- calling i28n() on element with data-i18n attribute will localize it now (i18n now not only works on container elements child)
|
||||
|
||||
### 1.2.3
|
||||
|
||||
- extended detectLng: switch via qs _setLng=_ or cookie _i18next_
|
||||
- assert county in locale will be uppercased `en-us` -> `en-US`
|
||||
- provide option to have locale always lowercased _option lowerCaseLng_
|
||||
- set lng cookie when set in init function
|
||||
|
||||
### 1.2
|
||||
|
||||
- support for translation context
|
||||
- fixed zero count in plurals
|
||||
- init without options, callback
|
||||
|
||||
### 1.1
|
||||
|
||||
- support for multiple plural forms
|
||||
- common.js enabled (for node.js serverside)
|
||||
- changes to be less dependent on jquery (override it's functions, add to root if no jquery)
|
||||
- enable it on serverside with node.js [i18next-node](https://github.com/jamuhl/i18next-node)
|
||||
|
||||
### 1.0
|
||||
|
||||
- support for other attribute translation via _data-i18n_ attribute
|
||||
- bug fixes
|
||||
- tests with qunit and sinon
|
||||
|
||||
### 0.9
|
||||
|
||||
- multi-namespace support
|
||||
- loading static files or dynamic route
|
||||
- jquery function for _data-i18n_ attibute
|
||||
- post missing translations to the server
|
||||
- graceful fallback en-US -> en -> fallbackLng
|
||||
- localstorage support
|
||||
- support for pluralized strings
|
||||
- insertion of variables into translations
|
||||
- translation nesting
|
21
node_modules/i18next/LICENSE
generated
vendored
Normal file
21
node_modules/i18next/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 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.
|
54
node_modules/i18next/README.md
generated
vendored
Normal file
54
node_modules/i18next/README.md
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
# i18next: learn once - translate everywhere [](https://twitter.com/intent/tweet?text=Awesome%20i18next:%20learn%20once%20-%20translate%20everywhere%20-%20the%20internationalization%20ecosystem%20&url=https://github.com/i18next/i18next&via=jamuhl&hashtags=i18n,javascript,dev)
|
||||
|
||||
[](https://circleci.com/gh/i18next/i18next)
|
||||
[](https://codeclimate.com/github/i18next/i18next)
|
||||
[](https://coveralls.io/github/i18next/i18next)
|
||||
[](http://packagequality.com/#?package=i18next)
|
||||
[](https://cdnjs.com/libraries/i18next)
|
||||
[](https://www.npmjs.com/package/i18next)
|
||||
[](https://david-dm.org/i18next/i18next)
|
||||
|
||||
i18next is a very popular internationalization framework for browser or any other javascript environment (eg. node.js).
|
||||
|
||||

|
||||
|
||||
i18next provides:
|
||||
|
||||
- Flexible connection to [backend](https://www.i18next.com/plugins-and-utils.html#backends) (loading translations via xhr, ...)
|
||||
- Optional [caching](https://www.i18next.com/plugins-and-utils.html#caches), user [language detection](https://www.i18next.com/plugins-and-utils.html#language-detector), ...
|
||||
- Proper [pluralizations](https://www.i18next.com/plurals.html)
|
||||
- Translation [context](https://www.i18next.com/context.html)
|
||||
- [Nesting](https://www.i18next.com/nesting.html), [Variable replacement](https://www.i18next.com/interpolation.html)
|
||||
- Flexibility: [Use it everywhere](https://www.i18next.com/supported-frameworks.html)
|
||||
- Extensibility: eg. [sprintf](https://www.i18next.com/plugins-and-utils.html#post-processors)
|
||||
- ...
|
||||
|
||||
For more information visit the website:
|
||||
|
||||
- [Getting started](https://www.i18next.com/getting-started.html)
|
||||
- [Translation Functionality](https://www.i18next.com/essentials.html)
|
||||
- [API](https://www.i18next.com/api.html)
|
||||
|
||||
Our focus is providing the core to building a booming ecosystem. Independent of the building blocks you choose, be it react, angular or even good old jquery proper translation capabilities are just [one step away](https://www.i18next.com/supported-frameworks.html).
|
||||
|
||||
---
|
||||
|
||||
<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).
|
||||
|
||||

|
||||
|
||||
With using [locize](http://locize.com/?utm_source=i18next_readme&utm_medium=github) you directly support the future of i18next.
|
||||
|
||||
---
|
279
node_modules/i18next/dist/commonjs/BackendConnector.js
generated
vendored
Normal file
279
node_modules/i18next/dist/commonjs/BackendConnector.js
generated
vendored
Normal file
@@ -0,0 +1,279 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread"));
|
||||
|
||||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
||||
|
||||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
||||
|
||||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
||||
|
||||
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
||||
|
||||
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
||||
|
||||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
||||
|
||||
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
||||
|
||||
var utils = _interopRequireWildcard(require("./utils.js"));
|
||||
|
||||
var _logger = _interopRequireDefault(require("./logger.js"));
|
||||
|
||||
var _EventEmitter2 = _interopRequireDefault(require("./EventEmitter.js"));
|
||||
|
||||
function remove(arr, what) {
|
||||
var found = arr.indexOf(what);
|
||||
|
||||
while (found !== -1) {
|
||||
arr.splice(found, 1);
|
||||
found = arr.indexOf(what);
|
||||
}
|
||||
}
|
||||
|
||||
var Connector =
|
||||
/*#__PURE__*/
|
||||
function (_EventEmitter) {
|
||||
(0, _inherits2.default)(Connector, _EventEmitter);
|
||||
|
||||
function Connector(backend, store, services) {
|
||||
var _this;
|
||||
|
||||
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
||||
(0, _classCallCheck2.default)(this, Connector);
|
||||
_this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(Connector).call(this));
|
||||
|
||||
_EventEmitter2.default.call((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this))); // <=IE10 fix (unable to call parent constructor)
|
||||
|
||||
|
||||
_this.backend = backend;
|
||||
_this.store = store;
|
||||
_this.languageUtils = services.languageUtils;
|
||||
_this.options = options;
|
||||
_this.logger = _logger.default.create('backendConnector');
|
||||
_this.state = {};
|
||||
_this.queue = [];
|
||||
|
||||
if (_this.backend && _this.backend.init) {
|
||||
_this.backend.init(services, options.backend, options);
|
||||
}
|
||||
|
||||
return _this;
|
||||
}
|
||||
|
||||
(0, _createClass2.default)(Connector, [{
|
||||
key: "queueLoad",
|
||||
value: function queueLoad(languages, namespaces, options, callback) {
|
||||
var _this2 = this;
|
||||
|
||||
// find what needs to be loaded
|
||||
var toLoad = [];
|
||||
var pending = [];
|
||||
var toLoadLanguages = [];
|
||||
var toLoadNamespaces = [];
|
||||
languages.forEach(function (lng) {
|
||||
var hasAllNamespaces = true;
|
||||
namespaces.forEach(function (ns) {
|
||||
var name = "".concat(lng, "|").concat(ns);
|
||||
|
||||
if (!options.reload && _this2.store.hasResourceBundle(lng, ns)) {
|
||||
_this2.state[name] = 2; // loaded
|
||||
} else if (_this2.state[name] < 0) {// nothing to do for err
|
||||
} else if (_this2.state[name] === 1) {
|
||||
if (pending.indexOf(name) < 0) pending.push(name);
|
||||
} else {
|
||||
_this2.state[name] = 1; // pending
|
||||
|
||||
hasAllNamespaces = false;
|
||||
if (pending.indexOf(name) < 0) pending.push(name);
|
||||
if (toLoad.indexOf(name) < 0) toLoad.push(name);
|
||||
if (toLoadNamespaces.indexOf(ns) < 0) toLoadNamespaces.push(ns);
|
||||
}
|
||||
});
|
||||
if (!hasAllNamespaces) toLoadLanguages.push(lng);
|
||||
});
|
||||
|
||||
if (toLoad.length || pending.length) {
|
||||
this.queue.push({
|
||||
pending: pending,
|
||||
loaded: {},
|
||||
errors: [],
|
||||
callback: callback
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
toLoad: toLoad,
|
||||
pending: pending,
|
||||
toLoadLanguages: toLoadLanguages,
|
||||
toLoadNamespaces: toLoadNamespaces
|
||||
};
|
||||
}
|
||||
}, {
|
||||
key: "loaded",
|
||||
value: function loaded(name, err, data) {
|
||||
var _name$split = name.split('|'),
|
||||
_name$split2 = (0, _slicedToArray2.default)(_name$split, 2),
|
||||
lng = _name$split2[0],
|
||||
ns = _name$split2[1];
|
||||
|
||||
if (err) this.emit('failedLoading', lng, ns, err);
|
||||
|
||||
if (data) {
|
||||
this.store.addResourceBundle(lng, ns, data);
|
||||
} // set loaded
|
||||
|
||||
|
||||
this.state[name] = err ? -1 : 2; // consolidated loading done in this run - only emit once for a loaded namespace
|
||||
|
||||
var loaded = {}; // callback if ready
|
||||
|
||||
this.queue.forEach(function (q) {
|
||||
utils.pushPath(q.loaded, [lng], ns);
|
||||
remove(q.pending, name);
|
||||
if (err) q.errors.push(err);
|
||||
|
||||
if (q.pending.length === 0 && !q.done) {
|
||||
// only do once per loaded -> this.emit('loaded', q.loaded);
|
||||
Object.keys(q.loaded).forEach(function (l) {
|
||||
if (!loaded[l]) loaded[l] = [];
|
||||
|
||||
if (q.loaded[l].length) {
|
||||
q.loaded[l].forEach(function (ns) {
|
||||
if (loaded[l].indexOf(ns) < 0) loaded[l].push(ns);
|
||||
});
|
||||
}
|
||||
});
|
||||
/* eslint no-param-reassign: 0 */
|
||||
|
||||
q.done = true;
|
||||
|
||||
if (q.errors.length) {
|
||||
q.callback(q.errors);
|
||||
} else {
|
||||
q.callback();
|
||||
}
|
||||
}
|
||||
}); // emit consolidated loaded event
|
||||
|
||||
this.emit('loaded', loaded); // remove done load requests
|
||||
|
||||
this.queue = this.queue.filter(function (q) {
|
||||
return !q.done;
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "read",
|
||||
value: function read(lng, ns, fcName) {
|
||||
var _this3 = this;
|
||||
|
||||
var tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
||||
var wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 250;
|
||||
var callback = arguments.length > 5 ? arguments[5] : undefined;
|
||||
if (!lng.length) return callback(null, {}); // noting to load
|
||||
|
||||
return this.backend[fcName](lng, ns, function (err, data) {
|
||||
if (err && data
|
||||
/* = retryFlag */
|
||||
&& tried < 5) {
|
||||
setTimeout(function () {
|
||||
_this3.read.call(_this3, lng, ns, fcName, tried + 1, wait * 2, callback);
|
||||
}, wait);
|
||||
return;
|
||||
}
|
||||
|
||||
callback(err, data);
|
||||
});
|
||||
}
|
||||
/* eslint consistent-return: 0 */
|
||||
|
||||
}, {
|
||||
key: "prepareLoading",
|
||||
value: function prepareLoading(languages, namespaces) {
|
||||
var _this4 = this;
|
||||
|
||||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
||||
var callback = arguments.length > 3 ? arguments[3] : undefined;
|
||||
|
||||
if (!this.backend) {
|
||||
this.logger.warn('No backend was added via i18next.use. Will not load resources.');
|
||||
return callback && callback();
|
||||
}
|
||||
|
||||
if (typeof languages === 'string') languages = this.languageUtils.toResolveHierarchy(languages);
|
||||
if (typeof namespaces === 'string') namespaces = [namespaces];
|
||||
var toLoad = this.queueLoad(languages, namespaces, options, callback);
|
||||
|
||||
if (!toLoad.toLoad.length) {
|
||||
if (!toLoad.pending.length) callback(); // nothing to load and no pendings...callback now
|
||||
|
||||
return null; // pendings will trigger callback
|
||||
}
|
||||
|
||||
toLoad.toLoad.forEach(function (name) {
|
||||
_this4.loadOne(name);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "load",
|
||||
value: function load(languages, namespaces, callback) {
|
||||
this.prepareLoading(languages, namespaces, {}, callback);
|
||||
}
|
||||
}, {
|
||||
key: "reload",
|
||||
value: function reload(languages, namespaces, callback) {
|
||||
this.prepareLoading(languages, namespaces, {
|
||||
reload: true
|
||||
}, callback);
|
||||
}
|
||||
}, {
|
||||
key: "loadOne",
|
||||
value: function loadOne(name) {
|
||||
var _this5 = this;
|
||||
|
||||
var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
||||
|
||||
var _name$split3 = name.split('|'),
|
||||
_name$split4 = (0, _slicedToArray2.default)(_name$split3, 2),
|
||||
lng = _name$split4[0],
|
||||
ns = _name$split4[1];
|
||||
|
||||
this.read(lng, ns, 'read', null, null, function (err, data) {
|
||||
if (err) _this5.logger.warn("".concat(prefix, "loading namespace ").concat(ns, " for language ").concat(lng, " failed"), err);
|
||||
if (!err && data) _this5.logger.log("".concat(prefix, "loaded namespace ").concat(ns, " for language ").concat(lng), data);
|
||||
|
||||
_this5.loaded(name, err, data);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "saveMissing",
|
||||
value: function saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
|
||||
var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
||||
|
||||
if (this.backend && this.backend.create) {
|
||||
this.backend.create(languages, namespace, key, fallbackValue, null
|
||||
/* unused callback */
|
||||
, (0, _objectSpread2.default)({}, options, {
|
||||
isUpdate: isUpdate
|
||||
}));
|
||||
} // write to store to avoid resending
|
||||
|
||||
|
||||
if (!languages || !languages[0]) return;
|
||||
this.store.addResource(languages[0], namespace, key, fallbackValue);
|
||||
}
|
||||
}]);
|
||||
return Connector;
|
||||
}(_EventEmitter2.default);
|
||||
|
||||
var _default = Connector;
|
||||
exports.default = _default;
|
82
node_modules/i18next/dist/commonjs/EventEmitter.js
generated
vendored
Normal file
82
node_modules/i18next/dist/commonjs/EventEmitter.js
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
||||
|
||||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
||||
|
||||
var EventEmitter =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function EventEmitter() {
|
||||
(0, _classCallCheck2.default)(this, EventEmitter);
|
||||
this.observers = {};
|
||||
}
|
||||
|
||||
(0, _createClass2.default)(EventEmitter, [{
|
||||
key: "on",
|
||||
value: function on(events, listener) {
|
||||
var _this = this;
|
||||
|
||||
events.split(' ').forEach(function (event) {
|
||||
_this.observers[event] = _this.observers[event] || [];
|
||||
|
||||
_this.observers[event].push(listener);
|
||||
});
|
||||
return this;
|
||||
}
|
||||
}, {
|
||||
key: "off",
|
||||
value: function off(event, listener) {
|
||||
var _this2 = this;
|
||||
|
||||
if (!this.observers[event]) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.observers[event].forEach(function () {
|
||||
if (!listener) {
|
||||
delete _this2.observers[event];
|
||||
} else {
|
||||
var index = _this2.observers[event].indexOf(listener);
|
||||
|
||||
if (index > -1) {
|
||||
_this2.observers[event].splice(index, 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "emit",
|
||||
value: function emit(event) {
|
||||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||||
args[_key - 1] = arguments[_key];
|
||||
}
|
||||
|
||||
if (this.observers[event]) {
|
||||
var cloned = [].concat(this.observers[event]);
|
||||
cloned.forEach(function (observer) {
|
||||
observer.apply(void 0, args);
|
||||
});
|
||||
}
|
||||
|
||||
if (this.observers['*']) {
|
||||
var _cloned = [].concat(this.observers['*']);
|
||||
|
||||
_cloned.forEach(function (observer) {
|
||||
observer.apply(observer, [event].concat(args));
|
||||
});
|
||||
}
|
||||
}
|
||||
}]);
|
||||
return EventEmitter;
|
||||
}();
|
||||
|
||||
var _default = EventEmitter;
|
||||
exports.default = _default;
|
203
node_modules/i18next/dist/commonjs/Interpolator.js
generated
vendored
Normal file
203
node_modules/i18next/dist/commonjs/Interpolator.js
generated
vendored
Normal file
@@ -0,0 +1,203 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread"));
|
||||
|
||||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
||||
|
||||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
||||
|
||||
var utils = _interopRequireWildcard(require("./utils.js"));
|
||||
|
||||
var _logger = _interopRequireDefault(require("./logger.js"));
|
||||
|
||||
var Interpolator =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function Interpolator() {
|
||||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
(0, _classCallCheck2.default)(this, Interpolator);
|
||||
this.logger = _logger.default.create('interpolator');
|
||||
this.init(options, true);
|
||||
}
|
||||
/* eslint no-param-reassign: 0 */
|
||||
|
||||
|
||||
(0, _createClass2.default)(Interpolator, [{
|
||||
key: "init",
|
||||
value: function init() {
|
||||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
var reset = arguments.length > 1 ? arguments[1] : undefined;
|
||||
|
||||
if (reset) {
|
||||
this.options = options;
|
||||
|
||||
this.format = options.interpolation && options.interpolation.format || function (value) {
|
||||
return value;
|
||||
};
|
||||
}
|
||||
|
||||
if (!options.interpolation) options.interpolation = {
|
||||
escapeValue: true
|
||||
};
|
||||
var iOpts = options.interpolation;
|
||||
this.escape = iOpts.escape !== undefined ? iOpts.escape : utils.escape;
|
||||
this.escapeValue = iOpts.escapeValue !== undefined ? iOpts.escapeValue : true;
|
||||
this.useRawValueToEscape = iOpts.useRawValueToEscape !== undefined ? iOpts.useRawValueToEscape : false;
|
||||
this.prefix = iOpts.prefix ? utils.regexEscape(iOpts.prefix) : iOpts.prefixEscaped || '{{';
|
||||
this.suffix = iOpts.suffix ? utils.regexEscape(iOpts.suffix) : iOpts.suffixEscaped || '}}';
|
||||
this.formatSeparator = iOpts.formatSeparator ? iOpts.formatSeparator : iOpts.formatSeparator || ',';
|
||||
this.unescapePrefix = iOpts.unescapeSuffix ? '' : iOpts.unescapePrefix || '-';
|
||||
this.unescapeSuffix = this.unescapePrefix ? '' : iOpts.unescapeSuffix || '';
|
||||
this.nestingPrefix = iOpts.nestingPrefix ? utils.regexEscape(iOpts.nestingPrefix) : iOpts.nestingPrefixEscaped || utils.regexEscape('$t(');
|
||||
this.nestingSuffix = iOpts.nestingSuffix ? utils.regexEscape(iOpts.nestingSuffix) : iOpts.nestingSuffixEscaped || utils.regexEscape(')');
|
||||
this.maxReplaces = iOpts.maxReplaces ? iOpts.maxReplaces : 1000; // the regexp
|
||||
|
||||
this.resetRegExp();
|
||||
}
|
||||
}, {
|
||||
key: "reset",
|
||||
value: function reset() {
|
||||
if (this.options) this.init(this.options);
|
||||
}
|
||||
}, {
|
||||
key: "resetRegExp",
|
||||
value: function resetRegExp() {
|
||||
// the regexp
|
||||
var regexpStr = "".concat(this.prefix, "(.+?)").concat(this.suffix);
|
||||
this.regexp = new RegExp(regexpStr, 'g');
|
||||
var regexpUnescapeStr = "".concat(this.prefix).concat(this.unescapePrefix, "(.+?)").concat(this.unescapeSuffix).concat(this.suffix);
|
||||
this.regexpUnescape = new RegExp(regexpUnescapeStr, 'g');
|
||||
var nestingRegexpStr = "".concat(this.nestingPrefix, "(.+?)").concat(this.nestingSuffix);
|
||||
this.nestingRegexp = new RegExp(nestingRegexpStr, 'g');
|
||||
}
|
||||
}, {
|
||||
key: "interpolate",
|
||||
value: function interpolate(str, data, lng, options) {
|
||||
var _this = this;
|
||||
|
||||
var match;
|
||||
var value;
|
||||
var replaces;
|
||||
|
||||
function regexSafe(val) {
|
||||
return val.replace(/\$/g, '$$$$');
|
||||
}
|
||||
|
||||
var handleFormat = function handleFormat(key) {
|
||||
if (key.indexOf(_this.formatSeparator) < 0) return utils.getPath(data, key);
|
||||
var p = key.split(_this.formatSeparator);
|
||||
var k = p.shift().trim();
|
||||
var f = p.join(_this.formatSeparator).trim();
|
||||
return _this.format(utils.getPath(data, k), f, lng);
|
||||
};
|
||||
|
||||
this.resetRegExp();
|
||||
var missingInterpolationHandler = options && options.missingInterpolationHandler || this.options.missingInterpolationHandler;
|
||||
replaces = 0; // unescape if has unescapePrefix/Suffix
|
||||
|
||||
/* eslint no-cond-assign: 0 */
|
||||
|
||||
while (match = this.regexpUnescape.exec(str)) {
|
||||
value = handleFormat(match[1].trim());
|
||||
str = str.replace(match[0], value);
|
||||
this.regexpUnescape.lastIndex = 0;
|
||||
replaces++;
|
||||
|
||||
if (replaces >= this.maxReplaces) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
replaces = 0; // regular escape on demand
|
||||
|
||||
while (match = this.regexp.exec(str)) {
|
||||
value = handleFormat(match[1].trim());
|
||||
|
||||
if (value === undefined) {
|
||||
if (typeof missingInterpolationHandler === 'function') {
|
||||
var temp = missingInterpolationHandler(str, match, options);
|
||||
value = typeof temp === 'string' ? temp : '';
|
||||
} else {
|
||||
this.logger.warn("missed to pass in variable ".concat(match[1], " for interpolating ").concat(str));
|
||||
value = '';
|
||||
}
|
||||
} else if (typeof value !== 'string' && !this.useRawValueToEscape) {
|
||||
value = utils.makeString(value);
|
||||
}
|
||||
|
||||
value = this.escapeValue ? regexSafe(this.escape(value)) : regexSafe(value);
|
||||
str = str.replace(match[0], value);
|
||||
this.regexp.lastIndex = 0;
|
||||
replaces++;
|
||||
|
||||
if (replaces >= this.maxReplaces) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
}, {
|
||||
key: "nest",
|
||||
value: function nest(str, fc) {
|
||||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
||||
var match;
|
||||
var value;
|
||||
var clonedOptions = (0, _objectSpread2.default)({}, options);
|
||||
clonedOptions.applyPostProcessor = false; // avoid post processing on nested lookup
|
||||
// if value is something like "myKey": "lorem $(anotherKey, { "count": {{aValueInOptions}} })"
|
||||
|
||||
function handleHasOptions(key, inheritedOptions) {
|
||||
if (key.indexOf(',') < 0) return key;
|
||||
var p = key.split(',');
|
||||
key = p.shift();
|
||||
var optionsString = p.join(',');
|
||||
optionsString = this.interpolate(optionsString, clonedOptions);
|
||||
optionsString = optionsString.replace(/'/g, '"');
|
||||
|
||||
try {
|
||||
clonedOptions = JSON.parse(optionsString);
|
||||
if (inheritedOptions) clonedOptions = (0, _objectSpread2.default)({}, inheritedOptions, clonedOptions);
|
||||
} catch (e) {
|
||||
this.logger.error("failed parsing options string in nesting for key ".concat(key), e);
|
||||
}
|
||||
|
||||
return key;
|
||||
} // regular escape on demand
|
||||
|
||||
|
||||
while (match = this.nestingRegexp.exec(str)) {
|
||||
value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions); // is only the nesting key (key1 = '$(key2)') return the value without stringify
|
||||
|
||||
if (value && match[0] === str && typeof value !== 'string') return value; // no string to include or empty
|
||||
|
||||
if (typeof value !== 'string') value = utils.makeString(value);
|
||||
|
||||
if (!value) {
|
||||
this.logger.warn("missed to resolve ".concat(match[1], " for nesting ").concat(str));
|
||||
value = '';
|
||||
} // Nested keys should not be escaped by default #854
|
||||
// value = this.escapeValue ? regexSafe(utils.escape(value)) : regexSafe(value);
|
||||
|
||||
|
||||
str = str.replace(match[0], value);
|
||||
this.regexp.lastIndex = 0;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
}]);
|
||||
return Interpolator;
|
||||
}();
|
||||
|
||||
var _default = Interpolator;
|
||||
exports.default = _default;
|
135
node_modules/i18next/dist/commonjs/LanguageUtils.js
generated
vendored
Normal file
135
node_modules/i18next/dist/commonjs/LanguageUtils.js
generated
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
||||
|
||||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
||||
|
||||
var _logger = _interopRequireDefault(require("./logger.js"));
|
||||
|
||||
function capitalize(string) {
|
||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||
}
|
||||
|
||||
var LanguageUtil =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function LanguageUtil(options) {
|
||||
(0, _classCallCheck2.default)(this, LanguageUtil);
|
||||
this.options = options;
|
||||
this.whitelist = this.options.whitelist || false;
|
||||
this.logger = _logger.default.create('languageUtils');
|
||||
}
|
||||
|
||||
(0, _createClass2.default)(LanguageUtil, [{
|
||||
key: "getScriptPartFromCode",
|
||||
value: function getScriptPartFromCode(code) {
|
||||
if (!code || code.indexOf('-') < 0) return null;
|
||||
var p = code.split('-');
|
||||
if (p.length === 2) return null;
|
||||
p.pop();
|
||||
return this.formatLanguageCode(p.join('-'));
|
||||
}
|
||||
}, {
|
||||
key: "getLanguagePartFromCode",
|
||||
value: function getLanguagePartFromCode(code) {
|
||||
if (!code || code.indexOf('-') < 0) return code;
|
||||
var p = code.split('-');
|
||||
return this.formatLanguageCode(p[0]);
|
||||
}
|
||||
}, {
|
||||
key: "formatLanguageCode",
|
||||
value: function formatLanguageCode(code) {
|
||||
// http://www.iana.org/assignments/language-tags/language-tags.xhtml
|
||||
if (typeof code === 'string' && code.indexOf('-') > -1) {
|
||||
var specialCases = ['hans', 'hant', 'latn', 'cyrl', 'cans', 'mong', 'arab'];
|
||||
var p = code.split('-');
|
||||
|
||||
if (this.options.lowerCaseLng) {
|
||||
p = p.map(function (part) {
|
||||
return part.toLowerCase();
|
||||
});
|
||||
} else if (p.length === 2) {
|
||||
p[0] = p[0].toLowerCase();
|
||||
p[1] = p[1].toUpperCase();
|
||||
if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
|
||||
} else if (p.length === 3) {
|
||||
p[0] = p[0].toLowerCase(); // if lenght 2 guess it's a country
|
||||
|
||||
if (p[1].length === 2) p[1] = p[1].toUpperCase();
|
||||
if (p[0] !== 'sgn' && p[2].length === 2) p[2] = p[2].toUpperCase();
|
||||
if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
|
||||
if (specialCases.indexOf(p[2].toLowerCase()) > -1) p[2] = capitalize(p[2].toLowerCase());
|
||||
}
|
||||
|
||||
return p.join('-');
|
||||
}
|
||||
|
||||
return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
|
||||
}
|
||||
}, {
|
||||
key: "isWhitelisted",
|
||||
value: function isWhitelisted(code) {
|
||||
if (this.options.load === 'languageOnly' || this.options.nonExplicitWhitelist) {
|
||||
code = this.getLanguagePartFromCode(code);
|
||||
}
|
||||
|
||||
return !this.whitelist || !this.whitelist.length || this.whitelist.indexOf(code) > -1;
|
||||
}
|
||||
}, {
|
||||
key: "getFallbackCodes",
|
||||
value: function getFallbackCodes(fallbacks, code) {
|
||||
if (!fallbacks) return [];
|
||||
if (typeof fallbacks === 'string') fallbacks = [fallbacks];
|
||||
if (Object.prototype.toString.apply(fallbacks) === '[object Array]') return fallbacks;
|
||||
if (!code) return fallbacks.default || []; // asume we have an object defining fallbacks
|
||||
|
||||
var found = fallbacks[code];
|
||||
if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
|
||||
if (!found) found = fallbacks[this.formatLanguageCode(code)];
|
||||
if (!found) found = fallbacks.default;
|
||||
return found || [];
|
||||
}
|
||||
}, {
|
||||
key: "toResolveHierarchy",
|
||||
value: function toResolveHierarchy(code, fallbackCode) {
|
||||
var _this = this;
|
||||
|
||||
var fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);
|
||||
var codes = [];
|
||||
|
||||
var addCode = function addCode(c) {
|
||||
if (!c) return;
|
||||
|
||||
if (_this.isWhitelisted(c)) {
|
||||
codes.push(c);
|
||||
} else {
|
||||
_this.logger.warn("rejecting non-whitelisted language code: ".concat(c));
|
||||
}
|
||||
};
|
||||
|
||||
if (typeof code === 'string' && code.indexOf('-') > -1) {
|
||||
if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));
|
||||
if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));
|
||||
if (this.options.load !== 'currentOnly') addCode(this.getLanguagePartFromCode(code));
|
||||
} else if (typeof code === 'string') {
|
||||
addCode(this.formatLanguageCode(code));
|
||||
}
|
||||
|
||||
fallbackCodes.forEach(function (fc) {
|
||||
if (codes.indexOf(fc) < 0) addCode(_this.formatLanguageCode(fc));
|
||||
});
|
||||
return codes;
|
||||
}
|
||||
}]);
|
||||
return LanguageUtil;
|
||||
}();
|
||||
|
||||
var _default = LanguageUtil;
|
||||
exports.default = _default;
|
289
node_modules/i18next/dist/commonjs/PluralResolver.js
generated
vendored
Normal file
289
node_modules/i18next/dist/commonjs/PluralResolver.js
generated
vendored
Normal file
@@ -0,0 +1,289 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
||||
|
||||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
||||
|
||||
var _logger = _interopRequireDefault(require("./logger.js"));
|
||||
|
||||
// definition http://translate.sourceforge.net/wiki/l10n/pluralforms
|
||||
|
||||
/* eslint-disable */
|
||||
var sets = [{
|
||||
lngs: ['ach', 'ak', 'am', 'arn', 'br', 'fil', 'gun', 'ln', 'mfe', 'mg', 'mi', 'oc', 'pt', 'pt-BR', 'tg', 'ti', 'tr', 'uz', 'wa'],
|
||||
nr: [1, 2],
|
||||
fc: 1
|
||||
}, {
|
||||
lngs: ['af', 'an', 'ast', 'az', 'bg', 'bn', 'ca', 'da', 'de', 'dev', 'el', 'en', 'eo', 'es', 'et', 'eu', 'fi', 'fo', 'fur', 'fy', 'gl', 'gu', 'ha', 'hi', 'hu', 'hy', 'ia', 'it', 'kn', 'ku', 'lb', 'mai', 'ml', 'mn', 'mr', 'nah', 'nap', 'nb', 'ne', 'nl', 'nn', 'no', 'nso', 'pa', 'pap', 'pms', 'ps', 'pt-PT', 'rm', 'sco', 'se', 'si', 'so', 'son', 'sq', 'sv', 'sw', 'ta', 'te', 'tk', 'ur', 'yo'],
|
||||
nr: [1, 2],
|
||||
fc: 2
|
||||
}, {
|
||||
lngs: ['ay', 'bo', 'cgg', 'fa', 'id', 'ja', 'jbo', 'ka', 'kk', 'km', 'ko', 'ky', 'lo', 'ms', 'sah', 'su', 'th', 'tt', 'ug', 'vi', 'wo', 'zh'],
|
||||
nr: [1],
|
||||
fc: 3
|
||||
}, {
|
||||
lngs: ['be', 'bs', 'dz', 'hr', 'ru', 'sr', 'uk'],
|
||||
nr: [1, 2, 5],
|
||||
fc: 4
|
||||
}, {
|
||||
lngs: ['ar'],
|
||||
nr: [0, 1, 2, 3, 11, 100],
|
||||
fc: 5
|
||||
}, {
|
||||
lngs: ['cs', 'sk'],
|
||||
nr: [1, 2, 5],
|
||||
fc: 6
|
||||
}, {
|
||||
lngs: ['csb', 'pl'],
|
||||
nr: [1, 2, 5],
|
||||
fc: 7
|
||||
}, {
|
||||
lngs: ['cy'],
|
||||
nr: [1, 2, 3, 8],
|
||||
fc: 8
|
||||
}, {
|
||||
lngs: ['fr'],
|
||||
nr: [1, 2],
|
||||
fc: 9
|
||||
}, {
|
||||
lngs: ['ga'],
|
||||
nr: [1, 2, 3, 7, 11],
|
||||
fc: 10
|
||||
}, {
|
||||
lngs: ['gd'],
|
||||
nr: [1, 2, 3, 20],
|
||||
fc: 11
|
||||
}, {
|
||||
lngs: ['is'],
|
||||
nr: [1, 2],
|
||||
fc: 12
|
||||
}, {
|
||||
lngs: ['jv'],
|
||||
nr: [0, 1],
|
||||
fc: 13
|
||||
}, {
|
||||
lngs: ['kw'],
|
||||
nr: [1, 2, 3, 4],
|
||||
fc: 14
|
||||
}, {
|
||||
lngs: ['lt'],
|
||||
nr: [1, 2, 10],
|
||||
fc: 15
|
||||
}, {
|
||||
lngs: ['lv'],
|
||||
nr: [1, 2, 0],
|
||||
fc: 16
|
||||
}, {
|
||||
lngs: ['mk'],
|
||||
nr: [1, 2],
|
||||
fc: 17
|
||||
}, {
|
||||
lngs: ['mnk'],
|
||||
nr: [0, 1, 2],
|
||||
fc: 18
|
||||
}, {
|
||||
lngs: ['mt'],
|
||||
nr: [1, 2, 11, 20],
|
||||
fc: 19
|
||||
}, {
|
||||
lngs: ['or'],
|
||||
nr: [2, 1],
|
||||
fc: 2
|
||||
}, {
|
||||
lngs: ['ro'],
|
||||
nr: [1, 2, 20],
|
||||
fc: 20
|
||||
}, {
|
||||
lngs: ['sl'],
|
||||
nr: [5, 1, 2, 3],
|
||||
fc: 21
|
||||
}, {
|
||||
lngs: ['he'],
|
||||
nr: [1, 2, 20, 21],
|
||||
fc: 22
|
||||
}];
|
||||
var _rulesPluralsTypes = {
|
||||
1: function _(n) {
|
||||
return Number(n > 1);
|
||||
},
|
||||
2: function _(n) {
|
||||
return Number(n != 1);
|
||||
},
|
||||
3: function _(n) {
|
||||
return 0;
|
||||
},
|
||||
4: function _(n) {
|
||||
return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
|
||||
},
|
||||
5: function _(n) {
|
||||
return Number(n === 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5);
|
||||
},
|
||||
6: function _(n) {
|
||||
return Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2);
|
||||
},
|
||||
7: function _(n) {
|
||||
return Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
|
||||
},
|
||||
8: function _(n) {
|
||||
return Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3);
|
||||
},
|
||||
9: function _(n) {
|
||||
return Number(n >= 2);
|
||||
},
|
||||
10: function _(n) {
|
||||
return Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4);
|
||||
},
|
||||
11: function _(n) {
|
||||
return Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3);
|
||||
},
|
||||
12: function _(n) {
|
||||
return Number(n % 10 != 1 || n % 100 == 11);
|
||||
},
|
||||
13: function _(n) {
|
||||
return Number(n !== 0);
|
||||
},
|
||||
14: function _(n) {
|
||||
return Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3);
|
||||
},
|
||||
15: function _(n) {
|
||||
return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
|
||||
},
|
||||
16: function _(n) {
|
||||
return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2);
|
||||
},
|
||||
17: function _(n) {
|
||||
return Number(n == 1 || n % 10 == 1 ? 0 : 1);
|
||||
},
|
||||
18: function _(n) {
|
||||
return Number(n == 0 ? 0 : n == 1 ? 1 : 2);
|
||||
},
|
||||
19: function _(n) {
|
||||
return Number(n == 1 ? 0 : n === 0 || n % 100 > 1 && n % 100 < 11 ? 1 : n % 100 > 10 && n % 100 < 20 ? 2 : 3);
|
||||
},
|
||||
20: function _(n) {
|
||||
return Number(n == 1 ? 0 : n === 0 || n % 100 > 0 && n % 100 < 20 ? 1 : 2);
|
||||
},
|
||||
21: function _(n) {
|
||||
return Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0);
|
||||
},
|
||||
22: function _(n) {
|
||||
return Number(n === 1 ? 0 : n === 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3);
|
||||
}
|
||||
};
|
||||
/* eslint-enable */
|
||||
|
||||
function createRules() {
|
||||
var rules = {};
|
||||
sets.forEach(function (set) {
|
||||
set.lngs.forEach(function (l) {
|
||||
rules[l] = {
|
||||
numbers: set.nr,
|
||||
plurals: _rulesPluralsTypes[set.fc]
|
||||
};
|
||||
});
|
||||
});
|
||||
return rules;
|
||||
}
|
||||
|
||||
var PluralResolver =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function PluralResolver(languageUtils) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
(0, _classCallCheck2.default)(this, PluralResolver);
|
||||
this.languageUtils = languageUtils;
|
||||
this.options = options;
|
||||
this.logger = _logger.default.create('pluralResolver');
|
||||
this.rules = createRules();
|
||||
}
|
||||
|
||||
(0, _createClass2.default)(PluralResolver, [{
|
||||
key: "addRule",
|
||||
value: function addRule(lng, obj) {
|
||||
this.rules[lng] = obj;
|
||||
}
|
||||
}, {
|
||||
key: "getRule",
|
||||
value: function getRule(code) {
|
||||
return this.rules[code] || this.rules[this.languageUtils.getLanguagePartFromCode(code)];
|
||||
}
|
||||
}, {
|
||||
key: "needsPlural",
|
||||
value: function needsPlural(code) {
|
||||
var rule = this.getRule(code);
|
||||
return rule && rule.numbers.length > 1;
|
||||
}
|
||||
}, {
|
||||
key: "getPluralFormsOfKey",
|
||||
value: function getPluralFormsOfKey(code, key) {
|
||||
var _this = this;
|
||||
|
||||
var ret = [];
|
||||
var rule = this.getRule(code);
|
||||
if (!rule) return ret;
|
||||
rule.numbers.forEach(function (n) {
|
||||
var suffix = _this.getSuffix(code, n);
|
||||
|
||||
ret.push("".concat(key).concat(suffix));
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
}, {
|
||||
key: "getSuffix",
|
||||
value: function getSuffix(code, count) {
|
||||
var _this2 = this;
|
||||
|
||||
var rule = this.getRule(code);
|
||||
|
||||
if (rule) {
|
||||
// if (rule.numbers.length === 1) return ''; // only singular
|
||||
var idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));
|
||||
var suffix = rule.numbers[idx]; // special treatment for lngs only having singular and plural
|
||||
|
||||
if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
|
||||
if (suffix === 2) {
|
||||
suffix = 'plural';
|
||||
} else if (suffix === 1) {
|
||||
suffix = '';
|
||||
}
|
||||
}
|
||||
|
||||
var returnSuffix = function returnSuffix() {
|
||||
return _this2.options.prepend && suffix.toString() ? _this2.options.prepend + suffix.toString() : suffix.toString();
|
||||
}; // COMPATIBILITY JSON
|
||||
// v1
|
||||
|
||||
|
||||
if (this.options.compatibilityJSON === 'v1') {
|
||||
if (suffix === 1) return '';
|
||||
if (typeof suffix === 'number') return "_plural_".concat(suffix.toString());
|
||||
return returnSuffix();
|
||||
} else if (
|
||||
/* v2 */
|
||||
this.options.compatibilityJSON === 'v2') {
|
||||
return returnSuffix();
|
||||
} else if (
|
||||
/* v3 - gettext index */
|
||||
this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
|
||||
return returnSuffix();
|
||||
}
|
||||
|
||||
return this.options.prepend && idx.toString() ? this.options.prepend + idx.toString() : idx.toString();
|
||||
}
|
||||
|
||||
this.logger.warn("no plural rule found for: ".concat(code));
|
||||
return '';
|
||||
}
|
||||
}]);
|
||||
return PluralResolver;
|
||||
}();
|
||||
|
||||
var _default = PluralResolver;
|
||||
exports.default = _default;
|
191
node_modules/i18next/dist/commonjs/ResourceStore.js
generated
vendored
Normal file
191
node_modules/i18next/dist/commonjs/ResourceStore.js
generated
vendored
Normal file
@@ -0,0 +1,191 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread"));
|
||||
|
||||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
||||
|
||||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
||||
|
||||
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
||||
|
||||
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
||||
|
||||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
||||
|
||||
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
||||
|
||||
var _EventEmitter2 = _interopRequireDefault(require("./EventEmitter.js"));
|
||||
|
||||
var utils = _interopRequireWildcard(require("./utils.js"));
|
||||
|
||||
var ResourceStore =
|
||||
/*#__PURE__*/
|
||||
function (_EventEmitter) {
|
||||
(0, _inherits2.default)(ResourceStore, _EventEmitter);
|
||||
|
||||
function ResourceStore(data) {
|
||||
var _this;
|
||||
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
||||
ns: ['translation'],
|
||||
defaultNS: 'translation'
|
||||
};
|
||||
(0, _classCallCheck2.default)(this, ResourceStore);
|
||||
_this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(ResourceStore).call(this));
|
||||
|
||||
_EventEmitter2.default.call((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this))); // <=IE10 fix (unable to call parent constructor)
|
||||
|
||||
|
||||
_this.data = data || {};
|
||||
_this.options = options;
|
||||
|
||||
if (_this.options.keySeparator === undefined) {
|
||||
_this.options.keySeparator = '.';
|
||||
}
|
||||
|
||||
return _this;
|
||||
}
|
||||
|
||||
(0, _createClass2.default)(ResourceStore, [{
|
||||
key: "addNamespaces",
|
||||
value: function addNamespaces(ns) {
|
||||
if (this.options.ns.indexOf(ns) < 0) {
|
||||
this.options.ns.push(ns);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "removeNamespaces",
|
||||
value: function removeNamespaces(ns) {
|
||||
var index = this.options.ns.indexOf(ns);
|
||||
|
||||
if (index > -1) {
|
||||
this.options.ns.splice(index, 1);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "getResource",
|
||||
value: function getResource(lng, ns, key) {
|
||||
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
||||
var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
|
||||
var path = [lng, ns];
|
||||
if (key && typeof key !== 'string') path = path.concat(key);
|
||||
if (key && typeof key === 'string') path = path.concat(keySeparator ? key.split(keySeparator) : key);
|
||||
|
||||
if (lng.indexOf('.') > -1) {
|
||||
path = lng.split('.');
|
||||
}
|
||||
|
||||
return utils.getPath(this.data, path);
|
||||
}
|
||||
}, {
|
||||
key: "addResource",
|
||||
value: function addResource(lng, ns, key, value) {
|
||||
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
|
||||
silent: false
|
||||
};
|
||||
var keySeparator = this.options.keySeparator;
|
||||
if (keySeparator === undefined) keySeparator = '.';
|
||||
var path = [lng, ns];
|
||||
if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
|
||||
|
||||
if (lng.indexOf('.') > -1) {
|
||||
path = lng.split('.');
|
||||
value = ns;
|
||||
ns = path[1];
|
||||
}
|
||||
|
||||
this.addNamespaces(ns);
|
||||
utils.setPath(this.data, path, value);
|
||||
if (!options.silent) this.emit('added', lng, ns, key, value);
|
||||
}
|
||||
}, {
|
||||
key: "addResources",
|
||||
value: function addResources(lng, ns, resources) {
|
||||
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
|
||||
silent: false
|
||||
};
|
||||
|
||||
/* eslint no-restricted-syntax: 0 */
|
||||
for (var m in resources) {
|
||||
if (typeof resources[m] === 'string' || Object.prototype.toString.apply(resources[m]) === '[object Array]') this.addResource(lng, ns, m, resources[m], {
|
||||
silent: true
|
||||
});
|
||||
}
|
||||
|
||||
if (!options.silent) this.emit('added', lng, ns, resources);
|
||||
}
|
||||
}, {
|
||||
key: "addResourceBundle",
|
||||
value: function addResourceBundle(lng, ns, resources, deep, overwrite) {
|
||||
var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {
|
||||
silent: false
|
||||
};
|
||||
var path = [lng, ns];
|
||||
|
||||
if (lng.indexOf('.') > -1) {
|
||||
path = lng.split('.');
|
||||
deep = resources;
|
||||
resources = ns;
|
||||
ns = path[1];
|
||||
}
|
||||
|
||||
this.addNamespaces(ns);
|
||||
var pack = utils.getPath(this.data, path) || {};
|
||||
|
||||
if (deep) {
|
||||
utils.deepExtend(pack, resources, overwrite);
|
||||
} else {
|
||||
pack = (0, _objectSpread2.default)({}, pack, resources);
|
||||
}
|
||||
|
||||
utils.setPath(this.data, path, pack);
|
||||
if (!options.silent) this.emit('added', lng, ns, resources);
|
||||
}
|
||||
}, {
|
||||
key: "removeResourceBundle",
|
||||
value: function removeResourceBundle(lng, ns) {
|
||||
if (this.hasResourceBundle(lng, ns)) {
|
||||
delete this.data[lng][ns];
|
||||
}
|
||||
|
||||
this.removeNamespaces(ns);
|
||||
this.emit('removed', lng, ns);
|
||||
}
|
||||
}, {
|
||||
key: "hasResourceBundle",
|
||||
value: function hasResourceBundle(lng, ns) {
|
||||
return this.getResource(lng, ns) !== undefined;
|
||||
}
|
||||
}, {
|
||||
key: "getResourceBundle",
|
||||
value: function getResourceBundle(lng, ns) {
|
||||
if (!ns) ns = this.options.defaultNS; // COMPATIBILITY: remove extend in v2.1.0
|
||||
|
||||
if (this.options.compatibilityAPI === 'v1') return (0, _objectSpread2.default)({}, {}, this.getResource(lng, ns));
|
||||
return this.getResource(lng, ns);
|
||||
}
|
||||
}, {
|
||||
key: "getDataByLanguage",
|
||||
value: function getDataByLanguage(lng) {
|
||||
return this.data[lng];
|
||||
}
|
||||
}, {
|
||||
key: "toJSON",
|
||||
value: function toJSON() {
|
||||
return this.data;
|
||||
}
|
||||
}]);
|
||||
return ResourceStore;
|
||||
}(_EventEmitter2.default);
|
||||
|
||||
var _default = ResourceStore;
|
||||
exports.default = _default;
|
375
node_modules/i18next/dist/commonjs/Translator.js
generated
vendored
Normal file
375
node_modules/i18next/dist/commonjs/Translator.js
generated
vendored
Normal file
@@ -0,0 +1,375 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread"));
|
||||
|
||||
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
||||
|
||||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
||||
|
||||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
||||
|
||||
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
||||
|
||||
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
||||
|
||||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
||||
|
||||
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
||||
|
||||
var _logger = _interopRequireDefault(require("./logger.js"));
|
||||
|
||||
var _EventEmitter2 = _interopRequireDefault(require("./EventEmitter.js"));
|
||||
|
||||
var _postProcessor = _interopRequireDefault(require("./postProcessor.js"));
|
||||
|
||||
var utils = _interopRequireWildcard(require("./utils.js"));
|
||||
|
||||
var Translator =
|
||||
/*#__PURE__*/
|
||||
function (_EventEmitter) {
|
||||
(0, _inherits2.default)(Translator, _EventEmitter);
|
||||
|
||||
function Translator(services) {
|
||||
var _this;
|
||||
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
(0, _classCallCheck2.default)(this, Translator);
|
||||
_this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(Translator).call(this));
|
||||
|
||||
_EventEmitter2.default.call((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this))); // <=IE10 fix (unable to call parent constructor)
|
||||
|
||||
|
||||
utils.copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat'], services, (0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
|
||||
_this.options = options;
|
||||
|
||||
if (_this.options.keySeparator === undefined) {
|
||||
_this.options.keySeparator = '.';
|
||||
}
|
||||
|
||||
_this.logger = _logger.default.create('translator');
|
||||
return _this;
|
||||
}
|
||||
|
||||
(0, _createClass2.default)(Translator, [{
|
||||
key: "changeLanguage",
|
||||
value: function changeLanguage(lng) {
|
||||
if (lng) this.language = lng;
|
||||
}
|
||||
}, {
|
||||
key: "exists",
|
||||
value: function exists(key) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
||||
interpolation: {}
|
||||
};
|
||||
var resolved = this.resolve(key, options);
|
||||
return resolved && resolved.res !== undefined;
|
||||
}
|
||||
}, {
|
||||
key: "extractFromKey",
|
||||
value: function extractFromKey(key, options) {
|
||||
var nsSeparator = options.nsSeparator || this.options.nsSeparator;
|
||||
if (nsSeparator === undefined) nsSeparator = ':';
|
||||
var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
|
||||
var namespaces = options.ns || this.options.defaultNS;
|
||||
|
||||
if (nsSeparator && key.indexOf(nsSeparator) > -1) {
|
||||
var parts = key.split(nsSeparator);
|
||||
if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
|
||||
key = parts.join(keySeparator);
|
||||
}
|
||||
|
||||
if (typeof namespaces === 'string') namespaces = [namespaces];
|
||||
return {
|
||||
key: key,
|
||||
namespaces: namespaces
|
||||
};
|
||||
}
|
||||
}, {
|
||||
key: "translate",
|
||||
value: function translate(keys, options) {
|
||||
var _this2 = this;
|
||||
|
||||
if ((0, _typeof2.default)(options) !== 'object' && this.options.overloadTranslationOptionHandler) {
|
||||
/* eslint prefer-rest-params: 0 */
|
||||
options = this.options.overloadTranslationOptionHandler(arguments);
|
||||
}
|
||||
|
||||
if (!options) options = {}; // non valid keys handling
|
||||
|
||||
if (keys === undefined || keys === null) return '';
|
||||
if (!Array.isArray(keys)) keys = [String(keys)]; // separators
|
||||
|
||||
var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator; // get namespace(s)
|
||||
|
||||
var _this$extractFromKey = this.extractFromKey(keys[keys.length - 1], options),
|
||||
key = _this$extractFromKey.key,
|
||||
namespaces = _this$extractFromKey.namespaces;
|
||||
|
||||
var namespace = namespaces[namespaces.length - 1]; // return key on CIMode
|
||||
|
||||
var lng = options.lng || this.language;
|
||||
var appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
|
||||
|
||||
if (lng && lng.toLowerCase() === 'cimode') {
|
||||
if (appendNamespaceToCIMode) {
|
||||
var nsSeparator = options.nsSeparator || this.options.nsSeparator;
|
||||
return namespace + nsSeparator + key;
|
||||
}
|
||||
|
||||
return key;
|
||||
} // resolve from store
|
||||
|
||||
|
||||
var resolved = this.resolve(keys, options);
|
||||
var res = resolved && resolved.res;
|
||||
var resUsedKey = resolved && resolved.usedKey || key;
|
||||
var resExactUsedKey = resolved && resolved.exactUsedKey || key;
|
||||
var resType = Object.prototype.toString.apply(res);
|
||||
var noObject = ['[object Number]', '[object Function]', '[object RegExp]'];
|
||||
var joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays; // object
|
||||
|
||||
var handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
|
||||
var handleAsObject = typeof res !== 'string' && typeof res !== 'boolean' && typeof res !== 'number';
|
||||
|
||||
if (handleAsObjectInI18nFormat && res && handleAsObject && noObject.indexOf(resType) < 0 && !(typeof joinArrays === 'string' && resType === '[object Array]')) {
|
||||
if (!options.returnObjects && !this.options.returnObjects) {
|
||||
this.logger.warn('accessing an object - but returnObjects options is not enabled!');
|
||||
return this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, options) : "key '".concat(key, " (").concat(this.language, ")' returned an object instead of string.");
|
||||
} // if we got a separator we loop over children - else we just return object as is
|
||||
// as having it set to false means no hierarchy so no lookup for nested values
|
||||
|
||||
|
||||
if (keySeparator) {
|
||||
var resTypeIsArray = resType === '[object Array]';
|
||||
var copy = resTypeIsArray ? [] : {}; // apply child translation on a copy
|
||||
|
||||
/* eslint no-restricted-syntax: 0 */
|
||||
|
||||
var newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
|
||||
|
||||
for (var m in res) {
|
||||
if (Object.prototype.hasOwnProperty.call(res, m)) {
|
||||
var deepKey = "".concat(newKeyToUse).concat(keySeparator).concat(m);
|
||||
copy[m] = this.translate(deepKey, (0, _objectSpread2.default)({}, options, {
|
||||
joinArrays: false,
|
||||
ns: namespaces
|
||||
}));
|
||||
if (copy[m] === deepKey) copy[m] = res[m]; // if nothing found use orginal value as fallback
|
||||
}
|
||||
}
|
||||
|
||||
res = copy;
|
||||
}
|
||||
} else if (handleAsObjectInI18nFormat && typeof joinArrays === 'string' && resType === '[object Array]') {
|
||||
// array special treatment
|
||||
res = res.join(joinArrays);
|
||||
if (res) res = this.extendTranslation(res, keys, options);
|
||||
} else {
|
||||
// string, empty or null
|
||||
var usedDefault = false;
|
||||
var usedKey = false; // fallback value
|
||||
|
||||
if (!this.isValidLookup(res) && options.defaultValue !== undefined) {
|
||||
usedDefault = true;
|
||||
|
||||
if (options.count !== undefined) {
|
||||
var suffix = this.pluralResolver.getSuffix(lng, options.count);
|
||||
res = options["defaultValue".concat(suffix)];
|
||||
}
|
||||
|
||||
if (!res) res = options.defaultValue;
|
||||
}
|
||||
|
||||
if (!this.isValidLookup(res)) {
|
||||
usedKey = true;
|
||||
res = key;
|
||||
} // save missing
|
||||
|
||||
|
||||
var updateMissing = options.defaultValue && options.defaultValue !== res && this.options.updateMissing;
|
||||
|
||||
if (usedKey || usedDefault || updateMissing) {
|
||||
this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? options.defaultValue : res);
|
||||
var lngs = [];
|
||||
var fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);
|
||||
|
||||
if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {
|
||||
for (var i = 0; i < fallbackLngs.length; i++) {
|
||||
lngs.push(fallbackLngs[i]);
|
||||
}
|
||||
} else if (this.options.saveMissingTo === 'all') {
|
||||
lngs = this.languageUtils.toResolveHierarchy(options.lng || this.language);
|
||||
} else {
|
||||
lngs.push(options.lng || this.language);
|
||||
}
|
||||
|
||||
var send = function send(l, k) {
|
||||
if (_this2.options.missingKeyHandler) {
|
||||
_this2.options.missingKeyHandler(l, namespace, k, updateMissing ? options.defaultValue : res, updateMissing, options);
|
||||
} else if (_this2.backendConnector && _this2.backendConnector.saveMissing) {
|
||||
_this2.backendConnector.saveMissing(l, namespace, k, updateMissing ? options.defaultValue : res, updateMissing, options);
|
||||
}
|
||||
|
||||
_this2.emit('missingKey', l, namespace, k, res);
|
||||
};
|
||||
|
||||
if (this.options.saveMissing) {
|
||||
var needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
|
||||
|
||||
if (this.options.saveMissingPlurals && needsPluralHandling) {
|
||||
lngs.forEach(function (l) {
|
||||
var plurals = _this2.pluralResolver.getPluralFormsOfKey(l, key);
|
||||
|
||||
plurals.forEach(function (p) {
|
||||
return send([l], p);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
send(lngs, key);
|
||||
}
|
||||
}
|
||||
} // extend
|
||||
|
||||
|
||||
res = this.extendTranslation(res, keys, options, resolved); // append namespace if still key
|
||||
|
||||
if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = "".concat(namespace, ":").concat(key); // parseMissingKeyHandler
|
||||
|
||||
if (usedKey && this.options.parseMissingKeyHandler) res = this.options.parseMissingKeyHandler(res);
|
||||
} // return
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
}, {
|
||||
key: "extendTranslation",
|
||||
value: function extendTranslation(res, key, options, resolved) {
|
||||
var _this3 = this;
|
||||
|
||||
if (this.i18nFormat && this.i18nFormat.parse) {
|
||||
res = this.i18nFormat.parse(res, options, resolved.usedLng, resolved.usedNS, resolved.usedKey, {
|
||||
resolved: resolved
|
||||
});
|
||||
} else if (!options.skipInterpolation) {
|
||||
// i18next.parsing
|
||||
if (options.interpolation) this.interpolator.init((0, _objectSpread2.default)({}, options, {
|
||||
interpolation: (0, _objectSpread2.default)({}, this.options.interpolation, options.interpolation)
|
||||
})); // interpolate
|
||||
|
||||
var data = options.replace && typeof options.replace !== 'string' ? options.replace : options;
|
||||
if (this.options.interpolation.defaultVariables) data = (0, _objectSpread2.default)({}, this.options.interpolation.defaultVariables, data);
|
||||
res = this.interpolator.interpolate(res, data, options.lng || this.language, options); // nesting
|
||||
|
||||
if (options.nest !== false) res = this.interpolator.nest(res, function () {
|
||||
return _this3.translate.apply(_this3, arguments);
|
||||
}, options);
|
||||
if (options.interpolation) this.interpolator.reset();
|
||||
} // post process
|
||||
|
||||
|
||||
var postProcess = options.postProcess || this.options.postProcess;
|
||||
var postProcessorNames = typeof postProcess === 'string' ? [postProcess] : postProcess;
|
||||
|
||||
if (res !== undefined && res !== null && postProcessorNames && postProcessorNames.length && options.applyPostProcessor !== false) {
|
||||
res = _postProcessor.default.handle(postProcessorNames, res, key, options, this);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}, {
|
||||
key: "resolve",
|
||||
value: function resolve(keys) {
|
||||
var _this4 = this;
|
||||
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
var found;
|
||||
var usedKey; // plain key
|
||||
|
||||
var exactUsedKey; // key with context / plural
|
||||
|
||||
var usedLng;
|
||||
var usedNS;
|
||||
if (typeof keys === 'string') keys = [keys]; // forEach possible key
|
||||
|
||||
keys.forEach(function (k) {
|
||||
if (_this4.isValidLookup(found)) return;
|
||||
|
||||
var extracted = _this4.extractFromKey(k, options);
|
||||
|
||||
var key = extracted.key;
|
||||
usedKey = key;
|
||||
var namespaces = extracted.namespaces;
|
||||
if (_this4.options.fallbackNS) namespaces = namespaces.concat(_this4.options.fallbackNS);
|
||||
var needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
|
||||
var needsContextHandling = options.context !== undefined && typeof options.context === 'string' && options.context !== '';
|
||||
var codes = options.lngs ? options.lngs : _this4.languageUtils.toResolveHierarchy(options.lng || _this4.language, options.fallbackLng);
|
||||
namespaces.forEach(function (ns) {
|
||||
if (_this4.isValidLookup(found)) return;
|
||||
usedNS = ns;
|
||||
codes.forEach(function (code) {
|
||||
if (_this4.isValidLookup(found)) return;
|
||||
usedLng = code;
|
||||
var finalKey = key;
|
||||
var finalKeys = [finalKey];
|
||||
|
||||
if (_this4.i18nFormat && _this4.i18nFormat.addLookupKeys) {
|
||||
_this4.i18nFormat.addLookupKeys(finalKeys, key, code, ns, options);
|
||||
} else {
|
||||
var pluralSuffix;
|
||||
if (needsPluralHandling) pluralSuffix = _this4.pluralResolver.getSuffix(code, options.count); // fallback for plural if context not found
|
||||
|
||||
if (needsPluralHandling && needsContextHandling) finalKeys.push(finalKey + pluralSuffix); // get key for context if needed
|
||||
|
||||
if (needsContextHandling) finalKeys.push(finalKey += "".concat(_this4.options.contextSeparator).concat(options.context)); // get key for plural if needed
|
||||
|
||||
if (needsPluralHandling) finalKeys.push(finalKey += pluralSuffix);
|
||||
} // iterate over finalKeys starting with most specific pluralkey (-> contextkey only) -> singularkey only
|
||||
|
||||
|
||||
var possibleKey;
|
||||
/* eslint no-cond-assign: 0 */
|
||||
|
||||
while (possibleKey = finalKeys.pop()) {
|
||||
if (!_this4.isValidLookup(found)) {
|
||||
exactUsedKey = possibleKey;
|
||||
found = _this4.getResource(code, ns, possibleKey, options);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
return {
|
||||
res: found,
|
||||
usedKey: usedKey,
|
||||
exactUsedKey: exactUsedKey,
|
||||
usedLng: usedLng,
|
||||
usedNS: usedNS
|
||||
};
|
||||
}
|
||||
}, {
|
||||
key: "isValidLookup",
|
||||
value: function isValidLookup(res) {
|
||||
return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === '');
|
||||
}
|
||||
}, {
|
||||
key: "getResource",
|
||||
value: function getResource(code, ns, key) {
|
||||
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
||||
if (this.i18nFormat && this.i18nFormat.getResource) return this.i18nFormat.getResource(code, ns, key, options);
|
||||
return this.resourceStore.getResource(code, ns, key, options);
|
||||
}
|
||||
}]);
|
||||
return Translator;
|
||||
}(_EventEmitter2.default);
|
||||
|
||||
var _default = Translator;
|
||||
exports.default = _default;
|
114
node_modules/i18next/dist/commonjs/defaults.js
generated
vendored
Normal file
114
node_modules/i18next/dist/commonjs/defaults.js
generated
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.get = get;
|
||||
exports.transformOptions = transformOptions;
|
||||
|
||||
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
||||
|
||||
function get() {
|
||||
return {
|
||||
debug: false,
|
||||
initImmediate: true,
|
||||
ns: ['translation'],
|
||||
defaultNS: ['translation'],
|
||||
fallbackLng: ['dev'],
|
||||
fallbackNS: false,
|
||||
// string or array of namespaces
|
||||
whitelist: false,
|
||||
// array with whitelisted languages
|
||||
nonExplicitWhitelist: false,
|
||||
load: 'all',
|
||||
// | currentOnly | languageOnly
|
||||
preload: false,
|
||||
// array with preload languages
|
||||
simplifyPluralSuffix: true,
|
||||
keySeparator: '.',
|
||||
nsSeparator: ':',
|
||||
pluralSeparator: '_',
|
||||
contextSeparator: '_',
|
||||
partialBundledLanguages: false,
|
||||
// allow bundling certain languages that are not remotely fetched
|
||||
saveMissing: false,
|
||||
// enable to send missing values
|
||||
updateMissing: false,
|
||||
// enable to update default values if different from translated value (only useful on initial development, or when keeping code as source of truth)
|
||||
saveMissingTo: 'fallback',
|
||||
// 'current' || 'all'
|
||||
saveMissingPlurals: true,
|
||||
// will save all forms not only singular key
|
||||
missingKeyHandler: false,
|
||||
// function(lng, ns, key, fallbackValue) -> override if prefer on handling
|
||||
missingInterpolationHandler: false,
|
||||
// function(str, match)
|
||||
postProcess: false,
|
||||
// string or array of postProcessor names
|
||||
returnNull: true,
|
||||
// allows null value as valid translation
|
||||
returnEmptyString: true,
|
||||
// allows empty string value as valid translation
|
||||
returnObjects: false,
|
||||
joinArrays: false,
|
||||
// or string to join array
|
||||
returnedObjectHandler: function returnedObjectHandler() {},
|
||||
// function(key, value, options) triggered if key returns object but returnObjects is set to false
|
||||
parseMissingKeyHandler: false,
|
||||
// function(key) parsed a key that was not found in t() before returning
|
||||
appendNamespaceToMissingKey: false,
|
||||
appendNamespaceToCIMode: false,
|
||||
overloadTranslationOptionHandler: function handle(args) {
|
||||
var ret = {};
|
||||
if ((0, _typeof2.default)(args[1]) === 'object') ret = args[1];
|
||||
if (typeof args[1] === 'string') ret.defaultValue = args[1];
|
||||
if (typeof args[2] === 'string') ret.tDescription = args[2];
|
||||
|
||||
if ((0, _typeof2.default)(args[2]) === 'object' || (0, _typeof2.default)(args[3]) === 'object') {
|
||||
var options = args[3] || args[2];
|
||||
Object.keys(options).forEach(function (key) {
|
||||
ret[key] = options[key];
|
||||
});
|
||||
}
|
||||
|
||||
return ret;
|
||||
},
|
||||
interpolation: {
|
||||
escapeValue: true,
|
||||
format: function format(value, _format, lng) {
|
||||
return value;
|
||||
},
|
||||
prefix: '{{',
|
||||
suffix: '}}',
|
||||
formatSeparator: ',',
|
||||
// prefixEscaped: '{{',
|
||||
// suffixEscaped: '}}',
|
||||
// unescapeSuffix: '',
|
||||
unescapePrefix: '-',
|
||||
nestingPrefix: '$t(',
|
||||
nestingSuffix: ')',
|
||||
// nestingPrefixEscaped: '$t(',
|
||||
// nestingSuffixEscaped: ')',
|
||||
// defaultVariables: undefined // object that can have values to interpolate on - extends passed in interpolation data
|
||||
maxReplaces: 1000 // max replaces to prevent endless loop
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
/* eslint no-param-reassign: 0 */
|
||||
|
||||
|
||||
function transformOptions(options) {
|
||||
// create namespace object if namespace is passed in as string
|
||||
if (typeof options.ns === 'string') options.ns = [options.ns];
|
||||
if (typeof options.fallbackLng === 'string') options.fallbackLng = [options.fallbackLng];
|
||||
if (typeof options.fallbackNS === 'string') options.fallbackNS = [options.fallbackNS]; // extend whitelist with cimode
|
||||
|
||||
if (options.whitelist && options.whitelist.indexOf('cimode') < 0) {
|
||||
options.whitelist = options.whitelist.concat(['cimode']);
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
479
node_modules/i18next/dist/commonjs/i18next.js
generated
vendored
Normal file
479
node_modules/i18next/dist/commonjs/i18next.js
generated
vendored
Normal file
@@ -0,0 +1,479 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
||||
|
||||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread"));
|
||||
|
||||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
||||
|
||||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
||||
|
||||
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
||||
|
||||
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
||||
|
||||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
||||
|
||||
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
||||
|
||||
var _logger = _interopRequireDefault(require("./logger.js"));
|
||||
|
||||
var _EventEmitter2 = _interopRequireDefault(require("./EventEmitter.js"));
|
||||
|
||||
var _ResourceStore = _interopRequireDefault(require("./ResourceStore.js"));
|
||||
|
||||
var _Translator = _interopRequireDefault(require("./Translator.js"));
|
||||
|
||||
var _LanguageUtils = _interopRequireDefault(require("./LanguageUtils.js"));
|
||||
|
||||
var _PluralResolver = _interopRequireDefault(require("./PluralResolver.js"));
|
||||
|
||||
var _Interpolator = _interopRequireDefault(require("./Interpolator.js"));
|
||||
|
||||
var _BackendConnector = _interopRequireDefault(require("./BackendConnector.js"));
|
||||
|
||||
var _defaults = require("./defaults.js");
|
||||
|
||||
var _postProcessor = _interopRequireDefault(require("./postProcessor.js"));
|
||||
|
||||
var _utils = require("./utils.js");
|
||||
|
||||
function noop() {}
|
||||
|
||||
var I18n =
|
||||
/*#__PURE__*/
|
||||
function (_EventEmitter) {
|
||||
(0, _inherits2.default)(I18n, _EventEmitter);
|
||||
|
||||
function I18n() {
|
||||
var _this;
|
||||
|
||||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
||||
(0, _classCallCheck2.default)(this, I18n);
|
||||
_this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(I18n).call(this));
|
||||
|
||||
_EventEmitter2.default.call((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this))); // <=IE10 fix (unable to call parent constructor)
|
||||
|
||||
|
||||
_this.options = (0, _defaults.transformOptions)(options);
|
||||
_this.services = {};
|
||||
_this.logger = _logger.default;
|
||||
_this.modules = {
|
||||
external: []
|
||||
};
|
||||
|
||||
if (callback && !_this.isInitialized && !options.isClone) {
|
||||
// https://github.com/i18next/i18next/issues/879
|
||||
if (!_this.options.initImmediate) {
|
||||
_this.init(options, callback);
|
||||
|
||||
return (0, _possibleConstructorReturn2.default)(_this, (0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
|
||||
}
|
||||
|
||||
setTimeout(function () {
|
||||
_this.init(options, callback);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
return _this;
|
||||
}
|
||||
|
||||
(0, _createClass2.default)(I18n, [{
|
||||
key: "init",
|
||||
value: function init() {
|
||||
var _this2 = this;
|
||||
|
||||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
||||
|
||||
if (typeof options === 'function') {
|
||||
callback = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
this.options = (0, _objectSpread2.default)({}, (0, _defaults.get)(), this.options, (0, _defaults.transformOptions)(options));
|
||||
this.format = this.options.interpolation.format;
|
||||
if (!callback) callback = noop;
|
||||
|
||||
function createClassOnDemand(ClassOrObject) {
|
||||
if (!ClassOrObject) return null;
|
||||
if (typeof ClassOrObject === 'function') return new ClassOrObject();
|
||||
return ClassOrObject;
|
||||
} // init services
|
||||
|
||||
|
||||
if (!this.options.isClone) {
|
||||
if (this.modules.logger) {
|
||||
_logger.default.init(createClassOnDemand(this.modules.logger), this.options);
|
||||
} else {
|
||||
_logger.default.init(null, this.options);
|
||||
}
|
||||
|
||||
var lu = new _LanguageUtils.default(this.options);
|
||||
this.store = new _ResourceStore.default(this.options.resources, this.options);
|
||||
var s = this.services;
|
||||
s.logger = _logger.default;
|
||||
s.resourceStore = this.store;
|
||||
s.languageUtils = lu;
|
||||
s.pluralResolver = new _PluralResolver.default(lu, {
|
||||
prepend: this.options.pluralSeparator,
|
||||
compatibilityJSON: this.options.compatibilityJSON,
|
||||
simplifyPluralSuffix: this.options.simplifyPluralSuffix
|
||||
});
|
||||
s.interpolator = new _Interpolator.default(this.options);
|
||||
s.backendConnector = new _BackendConnector.default(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options); // pipe events from backendConnector
|
||||
|
||||
s.backendConnector.on('*', function (event) {
|
||||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||||
args[_key - 1] = arguments[_key];
|
||||
}
|
||||
|
||||
_this2.emit.apply(_this2, [event].concat(args));
|
||||
});
|
||||
|
||||
if (this.modules.languageDetector) {
|
||||
s.languageDetector = createClassOnDemand(this.modules.languageDetector);
|
||||
s.languageDetector.init(s, this.options.detection, this.options);
|
||||
}
|
||||
|
||||
if (this.modules.i18nFormat) {
|
||||
s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
|
||||
if (s.i18nFormat.init) s.i18nFormat.init(this);
|
||||
}
|
||||
|
||||
this.translator = new _Translator.default(this.services, this.options); // pipe events from translator
|
||||
|
||||
this.translator.on('*', function (event) {
|
||||
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
||||
args[_key2 - 1] = arguments[_key2];
|
||||
}
|
||||
|
||||
_this2.emit.apply(_this2, [event].concat(args));
|
||||
});
|
||||
this.modules.external.forEach(function (m) {
|
||||
if (m.init) m.init(_this2);
|
||||
});
|
||||
} // append api
|
||||
|
||||
|
||||
var storeApi = ['getResource', 'addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];
|
||||
storeApi.forEach(function (fcName) {
|
||||
_this2[fcName] = function () {
|
||||
var _this2$store;
|
||||
|
||||
return (_this2$store = _this2.store)[fcName].apply(_this2$store, arguments);
|
||||
};
|
||||
});
|
||||
var deferred = (0, _utils.defer)();
|
||||
|
||||
var load = function load() {
|
||||
_this2.changeLanguage(_this2.options.lng, function (err, t) {
|
||||
_this2.isInitialized = true;
|
||||
|
||||
_this2.logger.log('initialized', _this2.options);
|
||||
|
||||
_this2.emit('initialized', _this2.options);
|
||||
|
||||
deferred.resolve(t); // not rejecting on err (as err is only a loading translation failed warning)
|
||||
|
||||
callback(err, t);
|
||||
});
|
||||
};
|
||||
|
||||
if (this.options.resources || !this.options.initImmediate) {
|
||||
load();
|
||||
} else {
|
||||
setTimeout(load, 0);
|
||||
}
|
||||
|
||||
return deferred;
|
||||
}
|
||||
/* eslint consistent-return: 0 */
|
||||
|
||||
}, {
|
||||
key: "loadResources",
|
||||
value: function loadResources() {
|
||||
var _this3 = this;
|
||||
|
||||
var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : noop;
|
||||
|
||||
if (!this.options.resources || this.options.partialBundledLanguages) {
|
||||
if (this.language && this.language.toLowerCase() === 'cimode') return callback(); // avoid loading resources for cimode
|
||||
|
||||
var toLoad = [];
|
||||
|
||||
var append = function append(lng) {
|
||||
if (!lng) return;
|
||||
|
||||
var lngs = _this3.services.languageUtils.toResolveHierarchy(lng);
|
||||
|
||||
lngs.forEach(function (l) {
|
||||
if (toLoad.indexOf(l) < 0) toLoad.push(l);
|
||||
});
|
||||
};
|
||||
|
||||
if (!this.language) {
|
||||
// at least load fallbacks in this case
|
||||
var fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
|
||||
fallbacks.forEach(function (l) {
|
||||
return append(l);
|
||||
});
|
||||
} else {
|
||||
append(this.language);
|
||||
}
|
||||
|
||||
if (this.options.preload) {
|
||||
this.options.preload.forEach(function (l) {
|
||||
return append(l);
|
||||
});
|
||||
}
|
||||
|
||||
this.services.backendConnector.load(toLoad, this.options.ns, callback);
|
||||
} else {
|
||||
callback(null);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "reloadResources",
|
||||
value: function reloadResources(lngs, ns, callback) {
|
||||
var deferred = (0, _utils.defer)();
|
||||
if (!lngs) lngs = this.languages;
|
||||
if (!ns) ns = this.options.ns;
|
||||
if (!callback) callback = noop;
|
||||
this.services.backendConnector.reload(lngs, ns, function (err) {
|
||||
deferred.resolve(); // not rejecting on err (as err is only a loading translation failed warning)
|
||||
|
||||
callback(err);
|
||||
});
|
||||
return deferred;
|
||||
}
|
||||
}, {
|
||||
key: "use",
|
||||
value: function use(module) {
|
||||
if (module.type === 'backend') {
|
||||
this.modules.backend = module;
|
||||
}
|
||||
|
||||
if (module.type === 'logger' || module.log && module.warn && module.error) {
|
||||
this.modules.logger = module;
|
||||
}
|
||||
|
||||
if (module.type === 'languageDetector') {
|
||||
this.modules.languageDetector = module;
|
||||
}
|
||||
|
||||
if (module.type === 'i18nFormat') {
|
||||
this.modules.i18nFormat = module;
|
||||
}
|
||||
|
||||
if (module.type === 'postProcessor') {
|
||||
_postProcessor.default.addPostProcessor(module);
|
||||
}
|
||||
|
||||
if (module.type === '3rdParty') {
|
||||
this.modules.external.push(module);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}, {
|
||||
key: "changeLanguage",
|
||||
value: function changeLanguage(lng, callback) {
|
||||
var _this4 = this;
|
||||
|
||||
var deferred = (0, _utils.defer)();
|
||||
|
||||
var done = function done(err, l) {
|
||||
_this4.translator.changeLanguage(l);
|
||||
|
||||
if (l) {
|
||||
_this4.emit('languageChanged', l);
|
||||
|
||||
_this4.logger.log('languageChanged', l);
|
||||
}
|
||||
|
||||
deferred.resolve(function () {
|
||||
return _this4.t.apply(_this4, arguments);
|
||||
});
|
||||
if (callback) callback(err, function () {
|
||||
return _this4.t.apply(_this4, arguments);
|
||||
});
|
||||
};
|
||||
|
||||
var setLng = function setLng(l) {
|
||||
if (l) {
|
||||
_this4.language = l;
|
||||
_this4.languages = _this4.services.languageUtils.toResolveHierarchy(l);
|
||||
if (!_this4.translator.language) _this4.translator.changeLanguage(l);
|
||||
if (_this4.services.languageDetector) _this4.services.languageDetector.cacheUserLanguage(l);
|
||||
}
|
||||
|
||||
_this4.loadResources(function (err) {
|
||||
done(err, l);
|
||||
});
|
||||
};
|
||||
|
||||
if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
|
||||
setLng(this.services.languageDetector.detect());
|
||||
} else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
|
||||
this.services.languageDetector.detect(setLng);
|
||||
} else {
|
||||
setLng(lng);
|
||||
}
|
||||
|
||||
return deferred;
|
||||
}
|
||||
}, {
|
||||
key: "getFixedT",
|
||||
value: function getFixedT(lng, ns) {
|
||||
var _this5 = this;
|
||||
|
||||
var fixedT = function fixedT(key, opts) {
|
||||
var options = (0, _objectSpread2.default)({}, opts);
|
||||
|
||||
if ((0, _typeof2.default)(opts) !== 'object') {
|
||||
for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
|
||||
rest[_key3 - 2] = arguments[_key3];
|
||||
}
|
||||
|
||||
options = _this5.options.overloadTranslationOptionHandler([key, opts].concat(rest));
|
||||
}
|
||||
|
||||
options.lng = options.lng || fixedT.lng;
|
||||
options.lngs = options.lngs || fixedT.lngs;
|
||||
options.ns = options.ns || fixedT.ns;
|
||||
return _this5.t(key, options);
|
||||
};
|
||||
|
||||
if (typeof lng === 'string') {
|
||||
fixedT.lng = lng;
|
||||
} else {
|
||||
fixedT.lngs = lng;
|
||||
}
|
||||
|
||||
fixedT.ns = ns;
|
||||
return fixedT;
|
||||
}
|
||||
}, {
|
||||
key: "t",
|
||||
value: function t() {
|
||||
var _this$translator;
|
||||
|
||||
return this.translator && (_this$translator = this.translator).translate.apply(_this$translator, arguments);
|
||||
}
|
||||
}, {
|
||||
key: "exists",
|
||||
value: function exists() {
|
||||
var _this$translator2;
|
||||
|
||||
return this.translator && (_this$translator2 = this.translator).exists.apply(_this$translator2, arguments);
|
||||
}
|
||||
}, {
|
||||
key: "setDefaultNamespace",
|
||||
value: function setDefaultNamespace(ns) {
|
||||
this.options.defaultNS = ns;
|
||||
}
|
||||
}, {
|
||||
key: "loadNamespaces",
|
||||
value: function loadNamespaces(ns, callback) {
|
||||
var _this6 = this;
|
||||
|
||||
var deferred = (0, _utils.defer)();
|
||||
|
||||
if (!this.options.ns) {
|
||||
callback && callback();
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (typeof ns === 'string') ns = [ns];
|
||||
ns.forEach(function (n) {
|
||||
if (_this6.options.ns.indexOf(n) < 0) _this6.options.ns.push(n);
|
||||
});
|
||||
this.loadResources(function (err) {
|
||||
deferred.resolve();
|
||||
if (callback) callback(err);
|
||||
});
|
||||
return deferred;
|
||||
}
|
||||
}, {
|
||||
key: "loadLanguages",
|
||||
value: function loadLanguages(lngs, callback) {
|
||||
var deferred = (0, _utils.defer)();
|
||||
if (typeof lngs === 'string') lngs = [lngs];
|
||||
var preloaded = this.options.preload || [];
|
||||
var newLngs = lngs.filter(function (lng) {
|
||||
return preloaded.indexOf(lng) < 0;
|
||||
}); // Exit early if all given languages are already preloaded
|
||||
|
||||
if (!newLngs.length) {
|
||||
if (callback) callback();
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
this.options.preload = preloaded.concat(newLngs);
|
||||
this.loadResources(function (err) {
|
||||
deferred.resolve();
|
||||
if (callback) callback(err);
|
||||
});
|
||||
return deferred;
|
||||
}
|
||||
}, {
|
||||
key: "dir",
|
||||
value: function dir(lng) {
|
||||
if (!lng) lng = this.languages && this.languages.length > 0 ? this.languages[0] : this.language;
|
||||
if (!lng) return 'rtl';
|
||||
var rtlLngs = ['ar', 'shu', 'sqr', 'ssh', 'xaa', 'yhd', 'yud', 'aao', 'abh', 'abv', 'acm', 'acq', 'acw', 'acx', 'acy', 'adf', 'ads', 'aeb', 'aec', 'afb', 'ajp', 'apc', 'apd', 'arb', 'arq', 'ars', 'ary', 'arz', 'auz', 'avl', 'ayh', 'ayl', 'ayn', 'ayp', 'bbz', 'pga', 'he', 'iw', 'ps', 'pbt', 'pbu', 'pst', 'prp', 'prd', 'ur', 'ydd', 'yds', 'yih', 'ji', 'yi', 'hbo', 'men', 'xmn', 'fa', 'jpr', 'peo', 'pes', 'prs', 'dv', 'sam'];
|
||||
return rtlLngs.indexOf(this.services.languageUtils.getLanguagePartFromCode(lng)) >= 0 ? 'rtl' : 'ltr';
|
||||
}
|
||||
/* eslint class-methods-use-this: 0 */
|
||||
|
||||
}, {
|
||||
key: "createInstance",
|
||||
value: function createInstance() {
|
||||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
||||
return new I18n(options, callback);
|
||||
}
|
||||
}, {
|
||||
key: "cloneInstance",
|
||||
value: function cloneInstance() {
|
||||
var _this7 = this;
|
||||
|
||||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
|
||||
var mergedOptions = (0, _objectSpread2.default)({}, this.options, options, {
|
||||
isClone: true
|
||||
});
|
||||
var clone = new I18n(mergedOptions);
|
||||
var membersToCopy = ['store', 'services', 'language'];
|
||||
membersToCopy.forEach(function (m) {
|
||||
clone[m] = _this7[m];
|
||||
});
|
||||
clone.translator = new _Translator.default(clone.services, clone.options);
|
||||
clone.translator.on('*', function (event) {
|
||||
for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
||||
args[_key4 - 1] = arguments[_key4];
|
||||
}
|
||||
|
||||
clone.emit.apply(clone, [event].concat(args));
|
||||
});
|
||||
clone.init(mergedOptions, callback);
|
||||
clone.translator.options = clone.options; // sync options
|
||||
|
||||
return clone;
|
||||
}
|
||||
}]);
|
||||
return I18n;
|
||||
}(_EventEmitter2.default);
|
||||
|
||||
var _default = new I18n();
|
||||
|
||||
exports.default = _default;
|
73
node_modules/i18next/dist/commonjs/index.js
generated
vendored
Normal file
73
node_modules/i18next/dist/commonjs/index.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.use = exports.t = exports.setDefaultNamespace = exports.on = exports.off = exports.loadResources = exports.loadNamespaces = exports.loadLanguages = exports.init = exports.getFixedT = exports.exists = exports.dir = exports.createInstance = exports.cloneInstance = exports.changeLanguage = exports.default = void 0;
|
||||
|
||||
var _i18next = _interopRequireDefault(require("./i18next.js"));
|
||||
|
||||
var _default = _i18next.default;
|
||||
exports.default = _default;
|
||||
|
||||
var changeLanguage = _i18next.default.changeLanguage.bind(_i18next.default);
|
||||
|
||||
exports.changeLanguage = changeLanguage;
|
||||
|
||||
var cloneInstance = _i18next.default.cloneInstance.bind(_i18next.default);
|
||||
|
||||
exports.cloneInstance = cloneInstance;
|
||||
|
||||
var createInstance = _i18next.default.createInstance.bind(_i18next.default);
|
||||
|
||||
exports.createInstance = createInstance;
|
||||
|
||||
var dir = _i18next.default.dir.bind(_i18next.default);
|
||||
|
||||
exports.dir = dir;
|
||||
|
||||
var exists = _i18next.default.exists.bind(_i18next.default);
|
||||
|
||||
exports.exists = exists;
|
||||
|
||||
var getFixedT = _i18next.default.getFixedT.bind(_i18next.default);
|
||||
|
||||
exports.getFixedT = getFixedT;
|
||||
|
||||
var init = _i18next.default.init.bind(_i18next.default);
|
||||
|
||||
exports.init = init;
|
||||
|
||||
var loadLanguages = _i18next.default.loadLanguages.bind(_i18next.default);
|
||||
|
||||
exports.loadLanguages = loadLanguages;
|
||||
|
||||
var loadNamespaces = _i18next.default.loadNamespaces.bind(_i18next.default);
|
||||
|
||||
exports.loadNamespaces = loadNamespaces;
|
||||
|
||||
var loadResources = _i18next.default.loadResources.bind(_i18next.default);
|
||||
|
||||
exports.loadResources = loadResources;
|
||||
|
||||
var off = _i18next.default.off.bind(_i18next.default);
|
||||
|
||||
exports.off = off;
|
||||
|
||||
var on = _i18next.default.on.bind(_i18next.default);
|
||||
|
||||
exports.on = on;
|
||||
|
||||
var setDefaultNamespace = _i18next.default.setDefaultNamespace.bind(_i18next.default);
|
||||
|
||||
exports.setDefaultNamespace = setDefaultNamespace;
|
||||
|
||||
var t = _i18next.default.t.bind(_i18next.default);
|
||||
|
||||
exports.t = t;
|
||||
|
||||
var use = _i18next.default.use.bind(_i18next.default);
|
||||
|
||||
exports.use = use;
|
116
node_modules/i18next/dist/commonjs/logger.js
generated
vendored
Normal file
116
node_modules/i18next/dist/commonjs/logger.js
generated
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread"));
|
||||
|
||||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
||||
|
||||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
||||
|
||||
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
||||
|
||||
var consoleLogger = {
|
||||
type: 'logger',
|
||||
log: function log(args) {
|
||||
this.output('log', args);
|
||||
},
|
||||
warn: function warn(args) {
|
||||
this.output('warn', args);
|
||||
},
|
||||
error: function error(args) {
|
||||
this.output('error', args);
|
||||
},
|
||||
output: function output(type, args) {
|
||||
var _console;
|
||||
|
||||
/* eslint no-console: 0 */
|
||||
if (console && console[type]) (_console = console)[type].apply(_console, (0, _toConsumableArray2.default)(args));
|
||||
}
|
||||
};
|
||||
|
||||
var Logger =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function Logger(concreteLogger) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
(0, _classCallCheck2.default)(this, Logger);
|
||||
this.init(concreteLogger, options);
|
||||
}
|
||||
|
||||
(0, _createClass2.default)(Logger, [{
|
||||
key: "init",
|
||||
value: function init(concreteLogger) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
this.prefix = options.prefix || 'i18next:';
|
||||
this.logger = concreteLogger || consoleLogger;
|
||||
this.options = options;
|
||||
this.debug = options.debug;
|
||||
}
|
||||
}, {
|
||||
key: "setDebug",
|
||||
value: function setDebug(bool) {
|
||||
this.debug = bool;
|
||||
}
|
||||
}, {
|
||||
key: "log",
|
||||
value: function log() {
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
return this.forward(args, 'log', '', true);
|
||||
}
|
||||
}, {
|
||||
key: "warn",
|
||||
value: function warn() {
|
||||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
||||
args[_key2] = arguments[_key2];
|
||||
}
|
||||
|
||||
return this.forward(args, 'warn', '', true);
|
||||
}
|
||||
}, {
|
||||
key: "error",
|
||||
value: function error() {
|
||||
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
||||
args[_key3] = arguments[_key3];
|
||||
}
|
||||
|
||||
return this.forward(args, 'error', '');
|
||||
}
|
||||
}, {
|
||||
key: "deprecate",
|
||||
value: function deprecate() {
|
||||
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
||||
args[_key4] = arguments[_key4];
|
||||
}
|
||||
|
||||
return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
|
||||
}
|
||||
}, {
|
||||
key: "forward",
|
||||
value: function forward(args, lvl, prefix, debugOnly) {
|
||||
if (debugOnly && !this.debug) return null;
|
||||
if (typeof args[0] === 'string') args[0] = "".concat(prefix).concat(this.prefix, " ").concat(args[0]);
|
||||
return this.logger[lvl](args);
|
||||
}
|
||||
}, {
|
||||
key: "create",
|
||||
value: function create(moduleName) {
|
||||
return new Logger(this.logger, (0, _objectSpread2.default)({}, {
|
||||
prefix: "".concat(this.prefix, ":").concat(moduleName, ":")
|
||||
}, this.options));
|
||||
}
|
||||
}]);
|
||||
return Logger;
|
||||
}();
|
||||
|
||||
var _default = new Logger();
|
||||
|
||||
exports.default = _default;
|
21
node_modules/i18next/dist/commonjs/postProcessor.js
generated
vendored
Normal file
21
node_modules/i18next/dist/commonjs/postProcessor.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _default = {
|
||||
processors: {},
|
||||
addPostProcessor: function addPostProcessor(module) {
|
||||
this.processors[module.name] = module;
|
||||
},
|
||||
handle: function handle(processors, value, key, options, translator) {
|
||||
var _this = this;
|
||||
|
||||
processors.forEach(function (processor) {
|
||||
if (_this.processors[processor]) value = _this.processors[processor].process(value, key, options, translator);
|
||||
});
|
||||
return value;
|
||||
}
|
||||
};
|
||||
exports.default = _default;
|
137
node_modules/i18next/dist/commonjs/utils.js
generated
vendored
Normal file
137
node_modules/i18next/dist/commonjs/utils.js
generated
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.defer = defer;
|
||||
exports.makeString = makeString;
|
||||
exports.copy = copy;
|
||||
exports.setPath = setPath;
|
||||
exports.pushPath = pushPath;
|
||||
exports.getPath = getPath;
|
||||
exports.deepExtend = deepExtend;
|
||||
exports.regexEscape = regexEscape;
|
||||
exports.escape = escape;
|
||||
|
||||
// http://lea.verou.me/2016/12/resolve-promises-externally-with-this-one-weird-trick/
|
||||
function defer() {
|
||||
var res;
|
||||
var rej;
|
||||
var promise = new Promise(function (resolve, reject) {
|
||||
res = resolve;
|
||||
rej = reject;
|
||||
});
|
||||
promise.resolve = res;
|
||||
promise.reject = rej;
|
||||
return promise;
|
||||
}
|
||||
|
||||
function makeString(object) {
|
||||
if (object == null) return '';
|
||||
/* eslint prefer-template: 0 */
|
||||
|
||||
return '' + object;
|
||||
}
|
||||
|
||||
function copy(a, s, t) {
|
||||
a.forEach(function (m) {
|
||||
if (s[m]) t[m] = s[m];
|
||||
});
|
||||
}
|
||||
|
||||
function getLastOfPath(object, path, Empty) {
|
||||
function cleanKey(key) {
|
||||
return key && key.indexOf('###') > -1 ? key.replace(/###/g, '.') : key;
|
||||
}
|
||||
|
||||
function canNotTraverseDeeper() {
|
||||
return !object || typeof object === 'string';
|
||||
}
|
||||
|
||||
var stack = typeof path !== 'string' ? [].concat(path) : path.split('.');
|
||||
|
||||
while (stack.length > 1) {
|
||||
if (canNotTraverseDeeper()) return {};
|
||||
var key = cleanKey(stack.shift());
|
||||
if (!object[key] && Empty) object[key] = new Empty();
|
||||
object = object[key];
|
||||
}
|
||||
|
||||
if (canNotTraverseDeeper()) return {};
|
||||
return {
|
||||
obj: object,
|
||||
k: cleanKey(stack.shift())
|
||||
};
|
||||
}
|
||||
|
||||
function setPath(object, path, newValue) {
|
||||
var _getLastOfPath = getLastOfPath(object, path, Object),
|
||||
obj = _getLastOfPath.obj,
|
||||
k = _getLastOfPath.k;
|
||||
|
||||
obj[k] = newValue;
|
||||
}
|
||||
|
||||
function pushPath(object, path, newValue, concat) {
|
||||
var _getLastOfPath2 = getLastOfPath(object, path, Object),
|
||||
obj = _getLastOfPath2.obj,
|
||||
k = _getLastOfPath2.k;
|
||||
|
||||
obj[k] = obj[k] || [];
|
||||
if (concat) obj[k] = obj[k].concat(newValue);
|
||||
if (!concat) obj[k].push(newValue);
|
||||
}
|
||||
|
||||
function getPath(object, path) {
|
||||
var _getLastOfPath3 = getLastOfPath(object, path),
|
||||
obj = _getLastOfPath3.obj,
|
||||
k = _getLastOfPath3.k;
|
||||
|
||||
if (!obj) return undefined;
|
||||
return obj[k];
|
||||
}
|
||||
|
||||
function deepExtend(target, source, overwrite) {
|
||||
/* eslint no-restricted-syntax: 0 */
|
||||
for (var prop in source) {
|
||||
if (prop in target) {
|
||||
// If we reached a leaf string in target or source then replace with source or skip depending on the 'overwrite' switch
|
||||
if (typeof target[prop] === 'string' || target[prop] instanceof String || typeof source[prop] === 'string' || source[prop] instanceof String) {
|
||||
if (overwrite) target[prop] = source[prop];
|
||||
} else {
|
||||
deepExtend(target[prop], source[prop], overwrite);
|
||||
}
|
||||
} else {
|
||||
target[prop] = source[prop];
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
function regexEscape(str) {
|
||||
/* eslint no-useless-escape: 0 */
|
||||
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
|
||||
}
|
||||
/* eslint-disable */
|
||||
|
||||
|
||||
var _entityMap = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
"'": ''',
|
||||
'/': '/'
|
||||
};
|
||||
/* eslint-enable */
|
||||
|
||||
function escape(data) {
|
||||
if (typeof data === 'string') {
|
||||
return data.replace(/[&<>"'\/]/g, function (s) {
|
||||
return _entityMap[s];
|
||||
});
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
258
node_modules/i18next/dist/es/BackendConnector.js
generated
vendored
Normal file
258
node_modules/i18next/dist/es/BackendConnector.js
generated
vendored
Normal file
@@ -0,0 +1,258 @@
|
||||
import _objectSpread from "@babel/runtime/helpers/objectSpread";
|
||||
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
||||
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
||||
import _createClass from "@babel/runtime/helpers/createClass";
|
||||
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
||||
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
||||
import _inherits from "@babel/runtime/helpers/inherits";
|
||||
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
||||
import * as utils from './utils.js';
|
||||
import baseLogger from './logger.js';
|
||||
import EventEmitter from './EventEmitter.js';
|
||||
|
||||
function remove(arr, what) {
|
||||
var found = arr.indexOf(what);
|
||||
|
||||
while (found !== -1) {
|
||||
arr.splice(found, 1);
|
||||
found = arr.indexOf(what);
|
||||
}
|
||||
}
|
||||
|
||||
var Connector =
|
||||
/*#__PURE__*/
|
||||
function (_EventEmitter) {
|
||||
_inherits(Connector, _EventEmitter);
|
||||
|
||||
function Connector(backend, store, services) {
|
||||
var _this;
|
||||
|
||||
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
||||
|
||||
_classCallCheck(this, Connector);
|
||||
|
||||
_this = _possibleConstructorReturn(this, _getPrototypeOf(Connector).call(this));
|
||||
EventEmitter.call(_assertThisInitialized(_assertThisInitialized(_this))); // <=IE10 fix (unable to call parent constructor)
|
||||
|
||||
_this.backend = backend;
|
||||
_this.store = store;
|
||||
_this.languageUtils = services.languageUtils;
|
||||
_this.options = options;
|
||||
_this.logger = baseLogger.create('backendConnector');
|
||||
_this.state = {};
|
||||
_this.queue = [];
|
||||
|
||||
if (_this.backend && _this.backend.init) {
|
||||
_this.backend.init(services, options.backend, options);
|
||||
}
|
||||
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(Connector, [{
|
||||
key: "queueLoad",
|
||||
value: function queueLoad(languages, namespaces, options, callback) {
|
||||
var _this2 = this;
|
||||
|
||||
// find what needs to be loaded
|
||||
var toLoad = [];
|
||||
var pending = [];
|
||||
var toLoadLanguages = [];
|
||||
var toLoadNamespaces = [];
|
||||
languages.forEach(function (lng) {
|
||||
var hasAllNamespaces = true;
|
||||
namespaces.forEach(function (ns) {
|
||||
var name = "".concat(lng, "|").concat(ns);
|
||||
|
||||
if (!options.reload && _this2.store.hasResourceBundle(lng, ns)) {
|
||||
_this2.state[name] = 2; // loaded
|
||||
} else if (_this2.state[name] < 0) {// nothing to do for err
|
||||
} else if (_this2.state[name] === 1) {
|
||||
if (pending.indexOf(name) < 0) pending.push(name);
|
||||
} else {
|
||||
_this2.state[name] = 1; // pending
|
||||
|
||||
hasAllNamespaces = false;
|
||||
if (pending.indexOf(name) < 0) pending.push(name);
|
||||
if (toLoad.indexOf(name) < 0) toLoad.push(name);
|
||||
if (toLoadNamespaces.indexOf(ns) < 0) toLoadNamespaces.push(ns);
|
||||
}
|
||||
});
|
||||
if (!hasAllNamespaces) toLoadLanguages.push(lng);
|
||||
});
|
||||
|
||||
if (toLoad.length || pending.length) {
|
||||
this.queue.push({
|
||||
pending: pending,
|
||||
loaded: {},
|
||||
errors: [],
|
||||
callback: callback
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
toLoad: toLoad,
|
||||
pending: pending,
|
||||
toLoadLanguages: toLoadLanguages,
|
||||
toLoadNamespaces: toLoadNamespaces
|
||||
};
|
||||
}
|
||||
}, {
|
||||
key: "loaded",
|
||||
value: function loaded(name, err, data) {
|
||||
var _name$split = name.split('|'),
|
||||
_name$split2 = _slicedToArray(_name$split, 2),
|
||||
lng = _name$split2[0],
|
||||
ns = _name$split2[1];
|
||||
|
||||
if (err) this.emit('failedLoading', lng, ns, err);
|
||||
|
||||
if (data) {
|
||||
this.store.addResourceBundle(lng, ns, data);
|
||||
} // set loaded
|
||||
|
||||
|
||||
this.state[name] = err ? -1 : 2; // consolidated loading done in this run - only emit once for a loaded namespace
|
||||
|
||||
var loaded = {}; // callback if ready
|
||||
|
||||
this.queue.forEach(function (q) {
|
||||
utils.pushPath(q.loaded, [lng], ns);
|
||||
remove(q.pending, name);
|
||||
if (err) q.errors.push(err);
|
||||
|
||||
if (q.pending.length === 0 && !q.done) {
|
||||
// only do once per loaded -> this.emit('loaded', q.loaded);
|
||||
Object.keys(q.loaded).forEach(function (l) {
|
||||
if (!loaded[l]) loaded[l] = [];
|
||||
|
||||
if (q.loaded[l].length) {
|
||||
q.loaded[l].forEach(function (ns) {
|
||||
if (loaded[l].indexOf(ns) < 0) loaded[l].push(ns);
|
||||
});
|
||||
}
|
||||
});
|
||||
/* eslint no-param-reassign: 0 */
|
||||
|
||||
q.done = true;
|
||||
|
||||
if (q.errors.length) {
|
||||
q.callback(q.errors);
|
||||
} else {
|
||||
q.callback();
|
||||
}
|
||||
}
|
||||
}); // emit consolidated loaded event
|
||||
|
||||
this.emit('loaded', loaded); // remove done load requests
|
||||
|
||||
this.queue = this.queue.filter(function (q) {
|
||||
return !q.done;
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "read",
|
||||
value: function read(lng, ns, fcName) {
|
||||
var _this3 = this;
|
||||
|
||||
var tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
||||
var wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 250;
|
||||
var callback = arguments.length > 5 ? arguments[5] : undefined;
|
||||
if (!lng.length) return callback(null, {}); // noting to load
|
||||
|
||||
return this.backend[fcName](lng, ns, function (err, data) {
|
||||
if (err && data
|
||||
/* = retryFlag */
|
||||
&& tried < 5) {
|
||||
setTimeout(function () {
|
||||
_this3.read.call(_this3, lng, ns, fcName, tried + 1, wait * 2, callback);
|
||||
}, wait);
|
||||
return;
|
||||
}
|
||||
|
||||
callback(err, data);
|
||||
});
|
||||
}
|
||||
/* eslint consistent-return: 0 */
|
||||
|
||||
}, {
|
||||
key: "prepareLoading",
|
||||
value: function prepareLoading(languages, namespaces) {
|
||||
var _this4 = this;
|
||||
|
||||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
||||
var callback = arguments.length > 3 ? arguments[3] : undefined;
|
||||
|
||||
if (!this.backend) {
|
||||
this.logger.warn('No backend was added via i18next.use. Will not load resources.');
|
||||
return callback && callback();
|
||||
}
|
||||
|
||||
if (typeof languages === 'string') languages = this.languageUtils.toResolveHierarchy(languages);
|
||||
if (typeof namespaces === 'string') namespaces = [namespaces];
|
||||
var toLoad = this.queueLoad(languages, namespaces, options, callback);
|
||||
|
||||
if (!toLoad.toLoad.length) {
|
||||
if (!toLoad.pending.length) callback(); // nothing to load and no pendings...callback now
|
||||
|
||||
return null; // pendings will trigger callback
|
||||
}
|
||||
|
||||
toLoad.toLoad.forEach(function (name) {
|
||||
_this4.loadOne(name);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "load",
|
||||
value: function load(languages, namespaces, callback) {
|
||||
this.prepareLoading(languages, namespaces, {}, callback);
|
||||
}
|
||||
}, {
|
||||
key: "reload",
|
||||
value: function reload(languages, namespaces, callback) {
|
||||
this.prepareLoading(languages, namespaces, {
|
||||
reload: true
|
||||
}, callback);
|
||||
}
|
||||
}, {
|
||||
key: "loadOne",
|
||||
value: function loadOne(name) {
|
||||
var _this5 = this;
|
||||
|
||||
var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
||||
|
||||
var _name$split3 = name.split('|'),
|
||||
_name$split4 = _slicedToArray(_name$split3, 2),
|
||||
lng = _name$split4[0],
|
||||
ns = _name$split4[1];
|
||||
|
||||
this.read(lng, ns, 'read', null, null, function (err, data) {
|
||||
if (err) _this5.logger.warn("".concat(prefix, "loading namespace ").concat(ns, " for language ").concat(lng, " failed"), err);
|
||||
if (!err && data) _this5.logger.log("".concat(prefix, "loaded namespace ").concat(ns, " for language ").concat(lng), data);
|
||||
|
||||
_this5.loaded(name, err, data);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "saveMissing",
|
||||
value: function saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
|
||||
var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
||||
|
||||
if (this.backend && this.backend.create) {
|
||||
this.backend.create(languages, namespace, key, fallbackValue, null
|
||||
/* unused callback */
|
||||
, _objectSpread({}, options, {
|
||||
isUpdate: isUpdate
|
||||
}));
|
||||
} // write to store to avoid resending
|
||||
|
||||
|
||||
if (!languages || !languages[0]) return;
|
||||
this.store.addResource(languages[0], namespace, key, fallbackValue);
|
||||
}
|
||||
}]);
|
||||
|
||||
return Connector;
|
||||
}(EventEmitter);
|
||||
|
||||
export default Connector;
|
73
node_modules/i18next/dist/es/EventEmitter.js
generated
vendored
Normal file
73
node_modules/i18next/dist/es/EventEmitter.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
||||
import _createClass from "@babel/runtime/helpers/createClass";
|
||||
|
||||
var EventEmitter =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function EventEmitter() {
|
||||
_classCallCheck(this, EventEmitter);
|
||||
|
||||
this.observers = {};
|
||||
}
|
||||
|
||||
_createClass(EventEmitter, [{
|
||||
key: "on",
|
||||
value: function on(events, listener) {
|
||||
var _this = this;
|
||||
|
||||
events.split(' ').forEach(function (event) {
|
||||
_this.observers[event] = _this.observers[event] || [];
|
||||
|
||||
_this.observers[event].push(listener);
|
||||
});
|
||||
return this;
|
||||
}
|
||||
}, {
|
||||
key: "off",
|
||||
value: function off(event, listener) {
|
||||
var _this2 = this;
|
||||
|
||||
if (!this.observers[event]) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.observers[event].forEach(function () {
|
||||
if (!listener) {
|
||||
delete _this2.observers[event];
|
||||
} else {
|
||||
var index = _this2.observers[event].indexOf(listener);
|
||||
|
||||
if (index > -1) {
|
||||
_this2.observers[event].splice(index, 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "emit",
|
||||
value: function emit(event) {
|
||||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||||
args[_key - 1] = arguments[_key];
|
||||
}
|
||||
|
||||
if (this.observers[event]) {
|
||||
var cloned = [].concat(this.observers[event]);
|
||||
cloned.forEach(function (observer) {
|
||||
observer.apply(void 0, args);
|
||||
});
|
||||
}
|
||||
|
||||
if (this.observers['*']) {
|
||||
var _cloned = [].concat(this.observers['*']);
|
||||
|
||||
_cloned.forEach(function (observer) {
|
||||
observer.apply(observer, [event].concat(args));
|
||||
});
|
||||
}
|
||||
}
|
||||
}]);
|
||||
|
||||
return EventEmitter;
|
||||
}();
|
||||
|
||||
export default EventEmitter;
|
192
node_modules/i18next/dist/es/Interpolator.js
generated
vendored
Normal file
192
node_modules/i18next/dist/es/Interpolator.js
generated
vendored
Normal file
@@ -0,0 +1,192 @@
|
||||
import _objectSpread from "@babel/runtime/helpers/objectSpread";
|
||||
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
||||
import _createClass from "@babel/runtime/helpers/createClass";
|
||||
import * as utils from './utils.js';
|
||||
import baseLogger from './logger.js';
|
||||
|
||||
var Interpolator =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function Interpolator() {
|
||||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
|
||||
_classCallCheck(this, Interpolator);
|
||||
|
||||
this.logger = baseLogger.create('interpolator');
|
||||
this.init(options, true);
|
||||
}
|
||||
/* eslint no-param-reassign: 0 */
|
||||
|
||||
|
||||
_createClass(Interpolator, [{
|
||||
key: "init",
|
||||
value: function init() {
|
||||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
var reset = arguments.length > 1 ? arguments[1] : undefined;
|
||||
|
||||
if (reset) {
|
||||
this.options = options;
|
||||
|
||||
this.format = options.interpolation && options.interpolation.format || function (value) {
|
||||
return value;
|
||||
};
|
||||
}
|
||||
|
||||
if (!options.interpolation) options.interpolation = {
|
||||
escapeValue: true
|
||||
};
|
||||
var iOpts = options.interpolation;
|
||||
this.escape = iOpts.escape !== undefined ? iOpts.escape : utils.escape;
|
||||
this.escapeValue = iOpts.escapeValue !== undefined ? iOpts.escapeValue : true;
|
||||
this.useRawValueToEscape = iOpts.useRawValueToEscape !== undefined ? iOpts.useRawValueToEscape : false;
|
||||
this.prefix = iOpts.prefix ? utils.regexEscape(iOpts.prefix) : iOpts.prefixEscaped || '{{';
|
||||
this.suffix = iOpts.suffix ? utils.regexEscape(iOpts.suffix) : iOpts.suffixEscaped || '}}';
|
||||
this.formatSeparator = iOpts.formatSeparator ? iOpts.formatSeparator : iOpts.formatSeparator || ',';
|
||||
this.unescapePrefix = iOpts.unescapeSuffix ? '' : iOpts.unescapePrefix || '-';
|
||||
this.unescapeSuffix = this.unescapePrefix ? '' : iOpts.unescapeSuffix || '';
|
||||
this.nestingPrefix = iOpts.nestingPrefix ? utils.regexEscape(iOpts.nestingPrefix) : iOpts.nestingPrefixEscaped || utils.regexEscape('$t(');
|
||||
this.nestingSuffix = iOpts.nestingSuffix ? utils.regexEscape(iOpts.nestingSuffix) : iOpts.nestingSuffixEscaped || utils.regexEscape(')');
|
||||
this.maxReplaces = iOpts.maxReplaces ? iOpts.maxReplaces : 1000; // the regexp
|
||||
|
||||
this.resetRegExp();
|
||||
}
|
||||
}, {
|
||||
key: "reset",
|
||||
value: function reset() {
|
||||
if (this.options) this.init(this.options);
|
||||
}
|
||||
}, {
|
||||
key: "resetRegExp",
|
||||
value: function resetRegExp() {
|
||||
// the regexp
|
||||
var regexpStr = "".concat(this.prefix, "(.+?)").concat(this.suffix);
|
||||
this.regexp = new RegExp(regexpStr, 'g');
|
||||
var regexpUnescapeStr = "".concat(this.prefix).concat(this.unescapePrefix, "(.+?)").concat(this.unescapeSuffix).concat(this.suffix);
|
||||
this.regexpUnescape = new RegExp(regexpUnescapeStr, 'g');
|
||||
var nestingRegexpStr = "".concat(this.nestingPrefix, "(.+?)").concat(this.nestingSuffix);
|
||||
this.nestingRegexp = new RegExp(nestingRegexpStr, 'g');
|
||||
}
|
||||
}, {
|
||||
key: "interpolate",
|
||||
value: function interpolate(str, data, lng, options) {
|
||||
var _this = this;
|
||||
|
||||
var match;
|
||||
var value;
|
||||
var replaces;
|
||||
|
||||
function regexSafe(val) {
|
||||
return val.replace(/\$/g, '$$$$');
|
||||
}
|
||||
|
||||
var handleFormat = function handleFormat(key) {
|
||||
if (key.indexOf(_this.formatSeparator) < 0) return utils.getPath(data, key);
|
||||
var p = key.split(_this.formatSeparator);
|
||||
var k = p.shift().trim();
|
||||
var f = p.join(_this.formatSeparator).trim();
|
||||
return _this.format(utils.getPath(data, k), f, lng);
|
||||
};
|
||||
|
||||
this.resetRegExp();
|
||||
var missingInterpolationHandler = options && options.missingInterpolationHandler || this.options.missingInterpolationHandler;
|
||||
replaces = 0; // unescape if has unescapePrefix/Suffix
|
||||
|
||||
/* eslint no-cond-assign: 0 */
|
||||
|
||||
while (match = this.regexpUnescape.exec(str)) {
|
||||
value = handleFormat(match[1].trim());
|
||||
str = str.replace(match[0], value);
|
||||
this.regexpUnescape.lastIndex = 0;
|
||||
replaces++;
|
||||
|
||||
if (replaces >= this.maxReplaces) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
replaces = 0; // regular escape on demand
|
||||
|
||||
while (match = this.regexp.exec(str)) {
|
||||
value = handleFormat(match[1].trim());
|
||||
|
||||
if (value === undefined) {
|
||||
if (typeof missingInterpolationHandler === 'function') {
|
||||
var temp = missingInterpolationHandler(str, match, options);
|
||||
value = typeof temp === 'string' ? temp : '';
|
||||
} else {
|
||||
this.logger.warn("missed to pass in variable ".concat(match[1], " for interpolating ").concat(str));
|
||||
value = '';
|
||||
}
|
||||
} else if (typeof value !== 'string' && !this.useRawValueToEscape) {
|
||||
value = utils.makeString(value);
|
||||
}
|
||||
|
||||
value = this.escapeValue ? regexSafe(this.escape(value)) : regexSafe(value);
|
||||
str = str.replace(match[0], value);
|
||||
this.regexp.lastIndex = 0;
|
||||
replaces++;
|
||||
|
||||
if (replaces >= this.maxReplaces) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
}, {
|
||||
key: "nest",
|
||||
value: function nest(str, fc) {
|
||||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
||||
var match;
|
||||
var value;
|
||||
|
||||
var clonedOptions = _objectSpread({}, options);
|
||||
|
||||
clonedOptions.applyPostProcessor = false; // avoid post processing on nested lookup
|
||||
// if value is something like "myKey": "lorem $(anotherKey, { "count": {{aValueInOptions}} })"
|
||||
|
||||
function handleHasOptions(key, inheritedOptions) {
|
||||
if (key.indexOf(',') < 0) return key;
|
||||
var p = key.split(',');
|
||||
key = p.shift();
|
||||
var optionsString = p.join(',');
|
||||
optionsString = this.interpolate(optionsString, clonedOptions);
|
||||
optionsString = optionsString.replace(/'/g, '"');
|
||||
|
||||
try {
|
||||
clonedOptions = JSON.parse(optionsString);
|
||||
if (inheritedOptions) clonedOptions = _objectSpread({}, inheritedOptions, clonedOptions);
|
||||
} catch (e) {
|
||||
this.logger.error("failed parsing options string in nesting for key ".concat(key), e);
|
||||
}
|
||||
|
||||
return key;
|
||||
} // regular escape on demand
|
||||
|
||||
|
||||
while (match = this.nestingRegexp.exec(str)) {
|
||||
value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions); // is only the nesting key (key1 = '$(key2)') return the value without stringify
|
||||
|
||||
if (value && match[0] === str && typeof value !== 'string') return value; // no string to include or empty
|
||||
|
||||
if (typeof value !== 'string') value = utils.makeString(value);
|
||||
|
||||
if (!value) {
|
||||
this.logger.warn("missed to resolve ".concat(match[1], " for nesting ").concat(str));
|
||||
value = '';
|
||||
} // Nested keys should not be escaped by default #854
|
||||
// value = this.escapeValue ? regexSafe(utils.escape(value)) : regexSafe(value);
|
||||
|
||||
|
||||
str = str.replace(match[0], value);
|
||||
this.regexp.lastIndex = 0;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Interpolator;
|
||||
}();
|
||||
|
||||
export default Interpolator;
|
125
node_modules/i18next/dist/es/LanguageUtils.js
generated
vendored
Normal file
125
node_modules/i18next/dist/es/LanguageUtils.js
generated
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
||||
import _createClass from "@babel/runtime/helpers/createClass";
|
||||
import baseLogger from './logger.js';
|
||||
|
||||
function capitalize(string) {
|
||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||
}
|
||||
|
||||
var LanguageUtil =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function LanguageUtil(options) {
|
||||
_classCallCheck(this, LanguageUtil);
|
||||
|
||||
this.options = options;
|
||||
this.whitelist = this.options.whitelist || false;
|
||||
this.logger = baseLogger.create('languageUtils');
|
||||
}
|
||||
|
||||
_createClass(LanguageUtil, [{
|
||||
key: "getScriptPartFromCode",
|
||||
value: function getScriptPartFromCode(code) {
|
||||
if (!code || code.indexOf('-') < 0) return null;
|
||||
var p = code.split('-');
|
||||
if (p.length === 2) return null;
|
||||
p.pop();
|
||||
return this.formatLanguageCode(p.join('-'));
|
||||
}
|
||||
}, {
|
||||
key: "getLanguagePartFromCode",
|
||||
value: function getLanguagePartFromCode(code) {
|
||||
if (!code || code.indexOf('-') < 0) return code;
|
||||
var p = code.split('-');
|
||||
return this.formatLanguageCode(p[0]);
|
||||
}
|
||||
}, {
|
||||
key: "formatLanguageCode",
|
||||
value: function formatLanguageCode(code) {
|
||||
// http://www.iana.org/assignments/language-tags/language-tags.xhtml
|
||||
if (typeof code === 'string' && code.indexOf('-') > -1) {
|
||||
var specialCases = ['hans', 'hant', 'latn', 'cyrl', 'cans', 'mong', 'arab'];
|
||||
var p = code.split('-');
|
||||
|
||||
if (this.options.lowerCaseLng) {
|
||||
p = p.map(function (part) {
|
||||
return part.toLowerCase();
|
||||
});
|
||||
} else if (p.length === 2) {
|
||||
p[0] = p[0].toLowerCase();
|
||||
p[1] = p[1].toUpperCase();
|
||||
if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
|
||||
} else if (p.length === 3) {
|
||||
p[0] = p[0].toLowerCase(); // if lenght 2 guess it's a country
|
||||
|
||||
if (p[1].length === 2) p[1] = p[1].toUpperCase();
|
||||
if (p[0] !== 'sgn' && p[2].length === 2) p[2] = p[2].toUpperCase();
|
||||
if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
|
||||
if (specialCases.indexOf(p[2].toLowerCase()) > -1) p[2] = capitalize(p[2].toLowerCase());
|
||||
}
|
||||
|
||||
return p.join('-');
|
||||
}
|
||||
|
||||
return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
|
||||
}
|
||||
}, {
|
||||
key: "isWhitelisted",
|
||||
value: function isWhitelisted(code) {
|
||||
if (this.options.load === 'languageOnly' || this.options.nonExplicitWhitelist) {
|
||||
code = this.getLanguagePartFromCode(code);
|
||||
}
|
||||
|
||||
return !this.whitelist || !this.whitelist.length || this.whitelist.indexOf(code) > -1;
|
||||
}
|
||||
}, {
|
||||
key: "getFallbackCodes",
|
||||
value: function getFallbackCodes(fallbacks, code) {
|
||||
if (!fallbacks) return [];
|
||||
if (typeof fallbacks === 'string') fallbacks = [fallbacks];
|
||||
if (Object.prototype.toString.apply(fallbacks) === '[object Array]') return fallbacks;
|
||||
if (!code) return fallbacks.default || []; // asume we have an object defining fallbacks
|
||||
|
||||
var found = fallbacks[code];
|
||||
if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
|
||||
if (!found) found = fallbacks[this.formatLanguageCode(code)];
|
||||
if (!found) found = fallbacks.default;
|
||||
return found || [];
|
||||
}
|
||||
}, {
|
||||
key: "toResolveHierarchy",
|
||||
value: function toResolveHierarchy(code, fallbackCode) {
|
||||
var _this = this;
|
||||
|
||||
var fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);
|
||||
var codes = [];
|
||||
|
||||
var addCode = function addCode(c) {
|
||||
if (!c) return;
|
||||
|
||||
if (_this.isWhitelisted(c)) {
|
||||
codes.push(c);
|
||||
} else {
|
||||
_this.logger.warn("rejecting non-whitelisted language code: ".concat(c));
|
||||
}
|
||||
};
|
||||
|
||||
if (typeof code === 'string' && code.indexOf('-') > -1) {
|
||||
if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));
|
||||
if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));
|
||||
if (this.options.load !== 'currentOnly') addCode(this.getLanguagePartFromCode(code));
|
||||
} else if (typeof code === 'string') {
|
||||
addCode(this.formatLanguageCode(code));
|
||||
}
|
||||
|
||||
fallbackCodes.forEach(function (fc) {
|
||||
if (codes.indexOf(fc) < 0) addCode(_this.formatLanguageCode(fc));
|
||||
});
|
||||
return codes;
|
||||
}
|
||||
}]);
|
||||
|
||||
return LanguageUtil;
|
||||
}();
|
||||
|
||||
export default LanguageUtil;
|
279
node_modules/i18next/dist/es/PluralResolver.js
generated
vendored
Normal file
279
node_modules/i18next/dist/es/PluralResolver.js
generated
vendored
Normal file
@@ -0,0 +1,279 @@
|
||||
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
||||
import _createClass from "@babel/runtime/helpers/createClass";
|
||||
import baseLogger from './logger.js'; // definition http://translate.sourceforge.net/wiki/l10n/pluralforms
|
||||
|
||||
/* eslint-disable */
|
||||
|
||||
var sets = [{
|
||||
lngs: ['ach', 'ak', 'am', 'arn', 'br', 'fil', 'gun', 'ln', 'mfe', 'mg', 'mi', 'oc', 'pt', 'pt-BR', 'tg', 'ti', 'tr', 'uz', 'wa'],
|
||||
nr: [1, 2],
|
||||
fc: 1
|
||||
}, {
|
||||
lngs: ['af', 'an', 'ast', 'az', 'bg', 'bn', 'ca', 'da', 'de', 'dev', 'el', 'en', 'eo', 'es', 'et', 'eu', 'fi', 'fo', 'fur', 'fy', 'gl', 'gu', 'ha', 'hi', 'hu', 'hy', 'ia', 'it', 'kn', 'ku', 'lb', 'mai', 'ml', 'mn', 'mr', 'nah', 'nap', 'nb', 'ne', 'nl', 'nn', 'no', 'nso', 'pa', 'pap', 'pms', 'ps', 'pt-PT', 'rm', 'sco', 'se', 'si', 'so', 'son', 'sq', 'sv', 'sw', 'ta', 'te', 'tk', 'ur', 'yo'],
|
||||
nr: [1, 2],
|
||||
fc: 2
|
||||
}, {
|
||||
lngs: ['ay', 'bo', 'cgg', 'fa', 'id', 'ja', 'jbo', 'ka', 'kk', 'km', 'ko', 'ky', 'lo', 'ms', 'sah', 'su', 'th', 'tt', 'ug', 'vi', 'wo', 'zh'],
|
||||
nr: [1],
|
||||
fc: 3
|
||||
}, {
|
||||
lngs: ['be', 'bs', 'dz', 'hr', 'ru', 'sr', 'uk'],
|
||||
nr: [1, 2, 5],
|
||||
fc: 4
|
||||
}, {
|
||||
lngs: ['ar'],
|
||||
nr: [0, 1, 2, 3, 11, 100],
|
||||
fc: 5
|
||||
}, {
|
||||
lngs: ['cs', 'sk'],
|
||||
nr: [1, 2, 5],
|
||||
fc: 6
|
||||
}, {
|
||||
lngs: ['csb', 'pl'],
|
||||
nr: [1, 2, 5],
|
||||
fc: 7
|
||||
}, {
|
||||
lngs: ['cy'],
|
||||
nr: [1, 2, 3, 8],
|
||||
fc: 8
|
||||
}, {
|
||||
lngs: ['fr'],
|
||||
nr: [1, 2],
|
||||
fc: 9
|
||||
}, {
|
||||
lngs: ['ga'],
|
||||
nr: [1, 2, 3, 7, 11],
|
||||
fc: 10
|
||||
}, {
|
||||
lngs: ['gd'],
|
||||
nr: [1, 2, 3, 20],
|
||||
fc: 11
|
||||
}, {
|
||||
lngs: ['is'],
|
||||
nr: [1, 2],
|
||||
fc: 12
|
||||
}, {
|
||||
lngs: ['jv'],
|
||||
nr: [0, 1],
|
||||
fc: 13
|
||||
}, {
|
||||
lngs: ['kw'],
|
||||
nr: [1, 2, 3, 4],
|
||||
fc: 14
|
||||
}, {
|
||||
lngs: ['lt'],
|
||||
nr: [1, 2, 10],
|
||||
fc: 15
|
||||
}, {
|
||||
lngs: ['lv'],
|
||||
nr: [1, 2, 0],
|
||||
fc: 16
|
||||
}, {
|
||||
lngs: ['mk'],
|
||||
nr: [1, 2],
|
||||
fc: 17
|
||||
}, {
|
||||
lngs: ['mnk'],
|
||||
nr: [0, 1, 2],
|
||||
fc: 18
|
||||
}, {
|
||||
lngs: ['mt'],
|
||||
nr: [1, 2, 11, 20],
|
||||
fc: 19
|
||||
}, {
|
||||
lngs: ['or'],
|
||||
nr: [2, 1],
|
||||
fc: 2
|
||||
}, {
|
||||
lngs: ['ro'],
|
||||
nr: [1, 2, 20],
|
||||
fc: 20
|
||||
}, {
|
||||
lngs: ['sl'],
|
||||
nr: [5, 1, 2, 3],
|
||||
fc: 21
|
||||
}, {
|
||||
lngs: ['he'],
|
||||
nr: [1, 2, 20, 21],
|
||||
fc: 22
|
||||
}];
|
||||
var _rulesPluralsTypes = {
|
||||
1: function _(n) {
|
||||
return Number(n > 1);
|
||||
},
|
||||
2: function _(n) {
|
||||
return Number(n != 1);
|
||||
},
|
||||
3: function _(n) {
|
||||
return 0;
|
||||
},
|
||||
4: function _(n) {
|
||||
return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
|
||||
},
|
||||
5: function _(n) {
|
||||
return Number(n === 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5);
|
||||
},
|
||||
6: function _(n) {
|
||||
return Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2);
|
||||
},
|
||||
7: function _(n) {
|
||||
return Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
|
||||
},
|
||||
8: function _(n) {
|
||||
return Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3);
|
||||
},
|
||||
9: function _(n) {
|
||||
return Number(n >= 2);
|
||||
},
|
||||
10: function _(n) {
|
||||
return Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4);
|
||||
},
|
||||
11: function _(n) {
|
||||
return Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3);
|
||||
},
|
||||
12: function _(n) {
|
||||
return Number(n % 10 != 1 || n % 100 == 11);
|
||||
},
|
||||
13: function _(n) {
|
||||
return Number(n !== 0);
|
||||
},
|
||||
14: function _(n) {
|
||||
return Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3);
|
||||
},
|
||||
15: function _(n) {
|
||||
return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
|
||||
},
|
||||
16: function _(n) {
|
||||
return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2);
|
||||
},
|
||||
17: function _(n) {
|
||||
return Number(n == 1 || n % 10 == 1 ? 0 : 1);
|
||||
},
|
||||
18: function _(n) {
|
||||
return Number(n == 0 ? 0 : n == 1 ? 1 : 2);
|
||||
},
|
||||
19: function _(n) {
|
||||
return Number(n == 1 ? 0 : n === 0 || n % 100 > 1 && n % 100 < 11 ? 1 : n % 100 > 10 && n % 100 < 20 ? 2 : 3);
|
||||
},
|
||||
20: function _(n) {
|
||||
return Number(n == 1 ? 0 : n === 0 || n % 100 > 0 && n % 100 < 20 ? 1 : 2);
|
||||
},
|
||||
21: function _(n) {
|
||||
return Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0);
|
||||
},
|
||||
22: function _(n) {
|
||||
return Number(n === 1 ? 0 : n === 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3);
|
||||
}
|
||||
};
|
||||
/* eslint-enable */
|
||||
|
||||
function createRules() {
|
||||
var rules = {};
|
||||
sets.forEach(function (set) {
|
||||
set.lngs.forEach(function (l) {
|
||||
rules[l] = {
|
||||
numbers: set.nr,
|
||||
plurals: _rulesPluralsTypes[set.fc]
|
||||
};
|
||||
});
|
||||
});
|
||||
return rules;
|
||||
}
|
||||
|
||||
var PluralResolver =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function PluralResolver(languageUtils) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
|
||||
_classCallCheck(this, PluralResolver);
|
||||
|
||||
this.languageUtils = languageUtils;
|
||||
this.options = options;
|
||||
this.logger = baseLogger.create('pluralResolver');
|
||||
this.rules = createRules();
|
||||
}
|
||||
|
||||
_createClass(PluralResolver, [{
|
||||
key: "addRule",
|
||||
value: function addRule(lng, obj) {
|
||||
this.rules[lng] = obj;
|
||||
}
|
||||
}, {
|
||||
key: "getRule",
|
||||
value: function getRule(code) {
|
||||
return this.rules[code] || this.rules[this.languageUtils.getLanguagePartFromCode(code)];
|
||||
}
|
||||
}, {
|
||||
key: "needsPlural",
|
||||
value: function needsPlural(code) {
|
||||
var rule = this.getRule(code);
|
||||
return rule && rule.numbers.length > 1;
|
||||
}
|
||||
}, {
|
||||
key: "getPluralFormsOfKey",
|
||||
value: function getPluralFormsOfKey(code, key) {
|
||||
var _this = this;
|
||||
|
||||
var ret = [];
|
||||
var rule = this.getRule(code);
|
||||
if (!rule) return ret;
|
||||
rule.numbers.forEach(function (n) {
|
||||
var suffix = _this.getSuffix(code, n);
|
||||
|
||||
ret.push("".concat(key).concat(suffix));
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
}, {
|
||||
key: "getSuffix",
|
||||
value: function getSuffix(code, count) {
|
||||
var _this2 = this;
|
||||
|
||||
var rule = this.getRule(code);
|
||||
|
||||
if (rule) {
|
||||
// if (rule.numbers.length === 1) return ''; // only singular
|
||||
var idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));
|
||||
var suffix = rule.numbers[idx]; // special treatment for lngs only having singular and plural
|
||||
|
||||
if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
|
||||
if (suffix === 2) {
|
||||
suffix = 'plural';
|
||||
} else if (suffix === 1) {
|
||||
suffix = '';
|
||||
}
|
||||
}
|
||||
|
||||
var returnSuffix = function returnSuffix() {
|
||||
return _this2.options.prepend && suffix.toString() ? _this2.options.prepend + suffix.toString() : suffix.toString();
|
||||
}; // COMPATIBILITY JSON
|
||||
// v1
|
||||
|
||||
|
||||
if (this.options.compatibilityJSON === 'v1') {
|
||||
if (suffix === 1) return '';
|
||||
if (typeof suffix === 'number') return "_plural_".concat(suffix.toString());
|
||||
return returnSuffix();
|
||||
} else if (
|
||||
/* v2 */
|
||||
this.options.compatibilityJSON === 'v2') {
|
||||
return returnSuffix();
|
||||
} else if (
|
||||
/* v3 - gettext index */
|
||||
this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
|
||||
return returnSuffix();
|
||||
}
|
||||
|
||||
return this.options.prepend && idx.toString() ? this.options.prepend + idx.toString() : idx.toString();
|
||||
}
|
||||
|
||||
this.logger.warn("no plural rule found for: ".concat(code));
|
||||
return '';
|
||||
}
|
||||
}]);
|
||||
|
||||
return PluralResolver;
|
||||
}();
|
||||
|
||||
export default PluralResolver;
|
172
node_modules/i18next/dist/es/ResourceStore.js
generated
vendored
Normal file
172
node_modules/i18next/dist/es/ResourceStore.js
generated
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
import _objectSpread from "@babel/runtime/helpers/objectSpread";
|
||||
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
||||
import _createClass from "@babel/runtime/helpers/createClass";
|
||||
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
||||
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
||||
import _inherits from "@babel/runtime/helpers/inherits";
|
||||
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
||||
import EventEmitter from './EventEmitter.js';
|
||||
import * as utils from './utils.js';
|
||||
|
||||
var ResourceStore =
|
||||
/*#__PURE__*/
|
||||
function (_EventEmitter) {
|
||||
_inherits(ResourceStore, _EventEmitter);
|
||||
|
||||
function ResourceStore(data) {
|
||||
var _this;
|
||||
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
||||
ns: ['translation'],
|
||||
defaultNS: 'translation'
|
||||
};
|
||||
|
||||
_classCallCheck(this, ResourceStore);
|
||||
|
||||
_this = _possibleConstructorReturn(this, _getPrototypeOf(ResourceStore).call(this));
|
||||
EventEmitter.call(_assertThisInitialized(_assertThisInitialized(_this))); // <=IE10 fix (unable to call parent constructor)
|
||||
|
||||
_this.data = data || {};
|
||||
_this.options = options;
|
||||
|
||||
if (_this.options.keySeparator === undefined) {
|
||||
_this.options.keySeparator = '.';
|
||||
}
|
||||
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(ResourceStore, [{
|
||||
key: "addNamespaces",
|
||||
value: function addNamespaces(ns) {
|
||||
if (this.options.ns.indexOf(ns) < 0) {
|
||||
this.options.ns.push(ns);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "removeNamespaces",
|
||||
value: function removeNamespaces(ns) {
|
||||
var index = this.options.ns.indexOf(ns);
|
||||
|
||||
if (index > -1) {
|
||||
this.options.ns.splice(index, 1);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "getResource",
|
||||
value: function getResource(lng, ns, key) {
|
||||
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
||||
var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
|
||||
var path = [lng, ns];
|
||||
if (key && typeof key !== 'string') path = path.concat(key);
|
||||
if (key && typeof key === 'string') path = path.concat(keySeparator ? key.split(keySeparator) : key);
|
||||
|
||||
if (lng.indexOf('.') > -1) {
|
||||
path = lng.split('.');
|
||||
}
|
||||
|
||||
return utils.getPath(this.data, path);
|
||||
}
|
||||
}, {
|
||||
key: "addResource",
|
||||
value: function addResource(lng, ns, key, value) {
|
||||
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
|
||||
silent: false
|
||||
};
|
||||
var keySeparator = this.options.keySeparator;
|
||||
if (keySeparator === undefined) keySeparator = '.';
|
||||
var path = [lng, ns];
|
||||
if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
|
||||
|
||||
if (lng.indexOf('.') > -1) {
|
||||
path = lng.split('.');
|
||||
value = ns;
|
||||
ns = path[1];
|
||||
}
|
||||
|
||||
this.addNamespaces(ns);
|
||||
utils.setPath(this.data, path, value);
|
||||
if (!options.silent) this.emit('added', lng, ns, key, value);
|
||||
}
|
||||
}, {
|
||||
key: "addResources",
|
||||
value: function addResources(lng, ns, resources) {
|
||||
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
|
||||
silent: false
|
||||
};
|
||||
|
||||
/* eslint no-restricted-syntax: 0 */
|
||||
for (var m in resources) {
|
||||
if (typeof resources[m] === 'string' || Object.prototype.toString.apply(resources[m]) === '[object Array]') this.addResource(lng, ns, m, resources[m], {
|
||||
silent: true
|
||||
});
|
||||
}
|
||||
|
||||
if (!options.silent) this.emit('added', lng, ns, resources);
|
||||
}
|
||||
}, {
|
||||
key: "addResourceBundle",
|
||||
value: function addResourceBundle(lng, ns, resources, deep, overwrite) {
|
||||
var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {
|
||||
silent: false
|
||||
};
|
||||
var path = [lng, ns];
|
||||
|
||||
if (lng.indexOf('.') > -1) {
|
||||
path = lng.split('.');
|
||||
deep = resources;
|
||||
resources = ns;
|
||||
ns = path[1];
|
||||
}
|
||||
|
||||
this.addNamespaces(ns);
|
||||
var pack = utils.getPath(this.data, path) || {};
|
||||
|
||||
if (deep) {
|
||||
utils.deepExtend(pack, resources, overwrite);
|
||||
} else {
|
||||
pack = _objectSpread({}, pack, resources);
|
||||
}
|
||||
|
||||
utils.setPath(this.data, path, pack);
|
||||
if (!options.silent) this.emit('added', lng, ns, resources);
|
||||
}
|
||||
}, {
|
||||
key: "removeResourceBundle",
|
||||
value: function removeResourceBundle(lng, ns) {
|
||||
if (this.hasResourceBundle(lng, ns)) {
|
||||
delete this.data[lng][ns];
|
||||
}
|
||||
|
||||
this.removeNamespaces(ns);
|
||||
this.emit('removed', lng, ns);
|
||||
}
|
||||
}, {
|
||||
key: "hasResourceBundle",
|
||||
value: function hasResourceBundle(lng, ns) {
|
||||
return this.getResource(lng, ns) !== undefined;
|
||||
}
|
||||
}, {
|
||||
key: "getResourceBundle",
|
||||
value: function getResourceBundle(lng, ns) {
|
||||
if (!ns) ns = this.options.defaultNS; // COMPATIBILITY: remove extend in v2.1.0
|
||||
|
||||
if (this.options.compatibilityAPI === 'v1') return _objectSpread({}, {}, this.getResource(lng, ns));
|
||||
return this.getResource(lng, ns);
|
||||
}
|
||||
}, {
|
||||
key: "getDataByLanguage",
|
||||
value: function getDataByLanguage(lng) {
|
||||
return this.data[lng];
|
||||
}
|
||||
}, {
|
||||
key: "toJSON",
|
||||
value: function toJSON() {
|
||||
return this.data;
|
||||
}
|
||||
}]);
|
||||
|
||||
return ResourceStore;
|
||||
}(EventEmitter);
|
||||
|
||||
export default ResourceStore;
|
353
node_modules/i18next/dist/es/Translator.js
generated
vendored
Normal file
353
node_modules/i18next/dist/es/Translator.js
generated
vendored
Normal file
@@ -0,0 +1,353 @@
|
||||
import _objectSpread from "@babel/runtime/helpers/objectSpread";
|
||||
import _typeof from "@babel/runtime/helpers/typeof";
|
||||
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
||||
import _createClass from "@babel/runtime/helpers/createClass";
|
||||
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
||||
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
||||
import _inherits from "@babel/runtime/helpers/inherits";
|
||||
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
||||
import baseLogger from './logger.js';
|
||||
import EventEmitter from './EventEmitter.js';
|
||||
import postProcessor from './postProcessor.js';
|
||||
import * as utils from './utils.js';
|
||||
|
||||
var Translator =
|
||||
/*#__PURE__*/
|
||||
function (_EventEmitter) {
|
||||
_inherits(Translator, _EventEmitter);
|
||||
|
||||
function Translator(services) {
|
||||
var _this;
|
||||
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
|
||||
_classCallCheck(this, Translator);
|
||||
|
||||
_this = _possibleConstructorReturn(this, _getPrototypeOf(Translator).call(this));
|
||||
EventEmitter.call(_assertThisInitialized(_assertThisInitialized(_this))); // <=IE10 fix (unable to call parent constructor)
|
||||
|
||||
utils.copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat'], services, _assertThisInitialized(_assertThisInitialized(_this)));
|
||||
_this.options = options;
|
||||
|
||||
if (_this.options.keySeparator === undefined) {
|
||||
_this.options.keySeparator = '.';
|
||||
}
|
||||
|
||||
_this.logger = baseLogger.create('translator');
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(Translator, [{
|
||||
key: "changeLanguage",
|
||||
value: function changeLanguage(lng) {
|
||||
if (lng) this.language = lng;
|
||||
}
|
||||
}, {
|
||||
key: "exists",
|
||||
value: function exists(key) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
||||
interpolation: {}
|
||||
};
|
||||
var resolved = this.resolve(key, options);
|
||||
return resolved && resolved.res !== undefined;
|
||||
}
|
||||
}, {
|
||||
key: "extractFromKey",
|
||||
value: function extractFromKey(key, options) {
|
||||
var nsSeparator = options.nsSeparator || this.options.nsSeparator;
|
||||
if (nsSeparator === undefined) nsSeparator = ':';
|
||||
var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
|
||||
var namespaces = options.ns || this.options.defaultNS;
|
||||
|
||||
if (nsSeparator && key.indexOf(nsSeparator) > -1) {
|
||||
var parts = key.split(nsSeparator);
|
||||
if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
|
||||
key = parts.join(keySeparator);
|
||||
}
|
||||
|
||||
if (typeof namespaces === 'string') namespaces = [namespaces];
|
||||
return {
|
||||
key: key,
|
||||
namespaces: namespaces
|
||||
};
|
||||
}
|
||||
}, {
|
||||
key: "translate",
|
||||
value: function translate(keys, options) {
|
||||
var _this2 = this;
|
||||
|
||||
if (_typeof(options) !== 'object' && this.options.overloadTranslationOptionHandler) {
|
||||
/* eslint prefer-rest-params: 0 */
|
||||
options = this.options.overloadTranslationOptionHandler(arguments);
|
||||
}
|
||||
|
||||
if (!options) options = {}; // non valid keys handling
|
||||
|
||||
if (keys === undefined || keys === null) return '';
|
||||
if (!Array.isArray(keys)) keys = [String(keys)]; // separators
|
||||
|
||||
var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator; // get namespace(s)
|
||||
|
||||
var _this$extractFromKey = this.extractFromKey(keys[keys.length - 1], options),
|
||||
key = _this$extractFromKey.key,
|
||||
namespaces = _this$extractFromKey.namespaces;
|
||||
|
||||
var namespace = namespaces[namespaces.length - 1]; // return key on CIMode
|
||||
|
||||
var lng = options.lng || this.language;
|
||||
var appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
|
||||
|
||||
if (lng && lng.toLowerCase() === 'cimode') {
|
||||
if (appendNamespaceToCIMode) {
|
||||
var nsSeparator = options.nsSeparator || this.options.nsSeparator;
|
||||
return namespace + nsSeparator + key;
|
||||
}
|
||||
|
||||
return key;
|
||||
} // resolve from store
|
||||
|
||||
|
||||
var resolved = this.resolve(keys, options);
|
||||
var res = resolved && resolved.res;
|
||||
var resUsedKey = resolved && resolved.usedKey || key;
|
||||
var resExactUsedKey = resolved && resolved.exactUsedKey || key;
|
||||
var resType = Object.prototype.toString.apply(res);
|
||||
var noObject = ['[object Number]', '[object Function]', '[object RegExp]'];
|
||||
var joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays; // object
|
||||
|
||||
var handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
|
||||
var handleAsObject = typeof res !== 'string' && typeof res !== 'boolean' && typeof res !== 'number';
|
||||
|
||||
if (handleAsObjectInI18nFormat && res && handleAsObject && noObject.indexOf(resType) < 0 && !(typeof joinArrays === 'string' && resType === '[object Array]')) {
|
||||
if (!options.returnObjects && !this.options.returnObjects) {
|
||||
this.logger.warn('accessing an object - but returnObjects options is not enabled!');
|
||||
return this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, options) : "key '".concat(key, " (").concat(this.language, ")' returned an object instead of string.");
|
||||
} // if we got a separator we loop over children - else we just return object as is
|
||||
// as having it set to false means no hierarchy so no lookup for nested values
|
||||
|
||||
|
||||
if (keySeparator) {
|
||||
var resTypeIsArray = resType === '[object Array]';
|
||||
var copy = resTypeIsArray ? [] : {}; // apply child translation on a copy
|
||||
|
||||
/* eslint no-restricted-syntax: 0 */
|
||||
|
||||
var newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
|
||||
|
||||
for (var m in res) {
|
||||
if (Object.prototype.hasOwnProperty.call(res, m)) {
|
||||
var deepKey = "".concat(newKeyToUse).concat(keySeparator).concat(m);
|
||||
copy[m] = this.translate(deepKey, _objectSpread({}, options, {
|
||||
joinArrays: false,
|
||||
ns: namespaces
|
||||
}));
|
||||
if (copy[m] === deepKey) copy[m] = res[m]; // if nothing found use orginal value as fallback
|
||||
}
|
||||
}
|
||||
|
||||
res = copy;
|
||||
}
|
||||
} else if (handleAsObjectInI18nFormat && typeof joinArrays === 'string' && resType === '[object Array]') {
|
||||
// array special treatment
|
||||
res = res.join(joinArrays);
|
||||
if (res) res = this.extendTranslation(res, keys, options);
|
||||
} else {
|
||||
// string, empty or null
|
||||
var usedDefault = false;
|
||||
var usedKey = false; // fallback value
|
||||
|
||||
if (!this.isValidLookup(res) && options.defaultValue !== undefined) {
|
||||
usedDefault = true;
|
||||
|
||||
if (options.count !== undefined) {
|
||||
var suffix = this.pluralResolver.getSuffix(lng, options.count);
|
||||
res = options["defaultValue".concat(suffix)];
|
||||
}
|
||||
|
||||
if (!res) res = options.defaultValue;
|
||||
}
|
||||
|
||||
if (!this.isValidLookup(res)) {
|
||||
usedKey = true;
|
||||
res = key;
|
||||
} // save missing
|
||||
|
||||
|
||||
var updateMissing = options.defaultValue && options.defaultValue !== res && this.options.updateMissing;
|
||||
|
||||
if (usedKey || usedDefault || updateMissing) {
|
||||
this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? options.defaultValue : res);
|
||||
var lngs = [];
|
||||
var fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);
|
||||
|
||||
if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {
|
||||
for (var i = 0; i < fallbackLngs.length; i++) {
|
||||
lngs.push(fallbackLngs[i]);
|
||||
}
|
||||
} else if (this.options.saveMissingTo === 'all') {
|
||||
lngs = this.languageUtils.toResolveHierarchy(options.lng || this.language);
|
||||
} else {
|
||||
lngs.push(options.lng || this.language);
|
||||
}
|
||||
|
||||
var send = function send(l, k) {
|
||||
if (_this2.options.missingKeyHandler) {
|
||||
_this2.options.missingKeyHandler(l, namespace, k, updateMissing ? options.defaultValue : res, updateMissing, options);
|
||||
} else if (_this2.backendConnector && _this2.backendConnector.saveMissing) {
|
||||
_this2.backendConnector.saveMissing(l, namespace, k, updateMissing ? options.defaultValue : res, updateMissing, options);
|
||||
}
|
||||
|
||||
_this2.emit('missingKey', l, namespace, k, res);
|
||||
};
|
||||
|
||||
if (this.options.saveMissing) {
|
||||
var needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
|
||||
|
||||
if (this.options.saveMissingPlurals && needsPluralHandling) {
|
||||
lngs.forEach(function (l) {
|
||||
var plurals = _this2.pluralResolver.getPluralFormsOfKey(l, key);
|
||||
|
||||
plurals.forEach(function (p) {
|
||||
return send([l], p);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
send(lngs, key);
|
||||
}
|
||||
}
|
||||
} // extend
|
||||
|
||||
|
||||
res = this.extendTranslation(res, keys, options, resolved); // append namespace if still key
|
||||
|
||||
if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = "".concat(namespace, ":").concat(key); // parseMissingKeyHandler
|
||||
|
||||
if (usedKey && this.options.parseMissingKeyHandler) res = this.options.parseMissingKeyHandler(res);
|
||||
} // return
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
}, {
|
||||
key: "extendTranslation",
|
||||
value: function extendTranslation(res, key, options, resolved) {
|
||||
var _this3 = this;
|
||||
|
||||
if (this.i18nFormat && this.i18nFormat.parse) {
|
||||
res = this.i18nFormat.parse(res, options, resolved.usedLng, resolved.usedNS, resolved.usedKey, {
|
||||
resolved: resolved
|
||||
});
|
||||
} else if (!options.skipInterpolation) {
|
||||
// i18next.parsing
|
||||
if (options.interpolation) this.interpolator.init(_objectSpread({}, options, {
|
||||
interpolation: _objectSpread({}, this.options.interpolation, options.interpolation)
|
||||
})); // interpolate
|
||||
|
||||
var data = options.replace && typeof options.replace !== 'string' ? options.replace : options;
|
||||
if (this.options.interpolation.defaultVariables) data = _objectSpread({}, this.options.interpolation.defaultVariables, data);
|
||||
res = this.interpolator.interpolate(res, data, options.lng || this.language, options); // nesting
|
||||
|
||||
if (options.nest !== false) res = this.interpolator.nest(res, function () {
|
||||
return _this3.translate.apply(_this3, arguments);
|
||||
}, options);
|
||||
if (options.interpolation) this.interpolator.reset();
|
||||
} // post process
|
||||
|
||||
|
||||
var postProcess = options.postProcess || this.options.postProcess;
|
||||
var postProcessorNames = typeof postProcess === 'string' ? [postProcess] : postProcess;
|
||||
|
||||
if (res !== undefined && res !== null && postProcessorNames && postProcessorNames.length && options.applyPostProcessor !== false) {
|
||||
res = postProcessor.handle(postProcessorNames, res, key, options, this);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}, {
|
||||
key: "resolve",
|
||||
value: function resolve(keys) {
|
||||
var _this4 = this;
|
||||
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
var found;
|
||||
var usedKey; // plain key
|
||||
|
||||
var exactUsedKey; // key with context / plural
|
||||
|
||||
var usedLng;
|
||||
var usedNS;
|
||||
if (typeof keys === 'string') keys = [keys]; // forEach possible key
|
||||
|
||||
keys.forEach(function (k) {
|
||||
if (_this4.isValidLookup(found)) return;
|
||||
|
||||
var extracted = _this4.extractFromKey(k, options);
|
||||
|
||||
var key = extracted.key;
|
||||
usedKey = key;
|
||||
var namespaces = extracted.namespaces;
|
||||
if (_this4.options.fallbackNS) namespaces = namespaces.concat(_this4.options.fallbackNS);
|
||||
var needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
|
||||
var needsContextHandling = options.context !== undefined && typeof options.context === 'string' && options.context !== '';
|
||||
var codes = options.lngs ? options.lngs : _this4.languageUtils.toResolveHierarchy(options.lng || _this4.language, options.fallbackLng);
|
||||
namespaces.forEach(function (ns) {
|
||||
if (_this4.isValidLookup(found)) return;
|
||||
usedNS = ns;
|
||||
codes.forEach(function (code) {
|
||||
if (_this4.isValidLookup(found)) return;
|
||||
usedLng = code;
|
||||
var finalKey = key;
|
||||
var finalKeys = [finalKey];
|
||||
|
||||
if (_this4.i18nFormat && _this4.i18nFormat.addLookupKeys) {
|
||||
_this4.i18nFormat.addLookupKeys(finalKeys, key, code, ns, options);
|
||||
} else {
|
||||
var pluralSuffix;
|
||||
if (needsPluralHandling) pluralSuffix = _this4.pluralResolver.getSuffix(code, options.count); // fallback for plural if context not found
|
||||
|
||||
if (needsPluralHandling && needsContextHandling) finalKeys.push(finalKey + pluralSuffix); // get key for context if needed
|
||||
|
||||
if (needsContextHandling) finalKeys.push(finalKey += "".concat(_this4.options.contextSeparator).concat(options.context)); // get key for plural if needed
|
||||
|
||||
if (needsPluralHandling) finalKeys.push(finalKey += pluralSuffix);
|
||||
} // iterate over finalKeys starting with most specific pluralkey (-> contextkey only) -> singularkey only
|
||||
|
||||
|
||||
var possibleKey;
|
||||
/* eslint no-cond-assign: 0 */
|
||||
|
||||
while (possibleKey = finalKeys.pop()) {
|
||||
if (!_this4.isValidLookup(found)) {
|
||||
exactUsedKey = possibleKey;
|
||||
found = _this4.getResource(code, ns, possibleKey, options);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
return {
|
||||
res: found,
|
||||
usedKey: usedKey,
|
||||
exactUsedKey: exactUsedKey,
|
||||
usedLng: usedLng,
|
||||
usedNS: usedNS
|
||||
};
|
||||
}
|
||||
}, {
|
||||
key: "isValidLookup",
|
||||
value: function isValidLookup(res) {
|
||||
return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === '');
|
||||
}
|
||||
}, {
|
||||
key: "getResource",
|
||||
value: function getResource(code, ns, key) {
|
||||
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
||||
if (this.i18nFormat && this.i18nFormat.getResource) return this.i18nFormat.getResource(code, ns, key, options);
|
||||
return this.resourceStore.getResource(code, ns, key, options);
|
||||
}
|
||||
}]);
|
||||
|
||||
return Translator;
|
||||
}(EventEmitter);
|
||||
|
||||
export default Translator;
|
102
node_modules/i18next/dist/es/defaults.js
generated
vendored
Normal file
102
node_modules/i18next/dist/es/defaults.js
generated
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
import _typeof from "@babel/runtime/helpers/typeof";
|
||||
export function get() {
|
||||
return {
|
||||
debug: false,
|
||||
initImmediate: true,
|
||||
ns: ['translation'],
|
||||
defaultNS: ['translation'],
|
||||
fallbackLng: ['dev'],
|
||||
fallbackNS: false,
|
||||
// string or array of namespaces
|
||||
whitelist: false,
|
||||
// array with whitelisted languages
|
||||
nonExplicitWhitelist: false,
|
||||
load: 'all',
|
||||
// | currentOnly | languageOnly
|
||||
preload: false,
|
||||
// array with preload languages
|
||||
simplifyPluralSuffix: true,
|
||||
keySeparator: '.',
|
||||
nsSeparator: ':',
|
||||
pluralSeparator: '_',
|
||||
contextSeparator: '_',
|
||||
partialBundledLanguages: false,
|
||||
// allow bundling certain languages that are not remotely fetched
|
||||
saveMissing: false,
|
||||
// enable to send missing values
|
||||
updateMissing: false,
|
||||
// enable to update default values if different from translated value (only useful on initial development, or when keeping code as source of truth)
|
||||
saveMissingTo: 'fallback',
|
||||
// 'current' || 'all'
|
||||
saveMissingPlurals: true,
|
||||
// will save all forms not only singular key
|
||||
missingKeyHandler: false,
|
||||
// function(lng, ns, key, fallbackValue) -> override if prefer on handling
|
||||
missingInterpolationHandler: false,
|
||||
// function(str, match)
|
||||
postProcess: false,
|
||||
// string or array of postProcessor names
|
||||
returnNull: true,
|
||||
// allows null value as valid translation
|
||||
returnEmptyString: true,
|
||||
// allows empty string value as valid translation
|
||||
returnObjects: false,
|
||||
joinArrays: false,
|
||||
// or string to join array
|
||||
returnedObjectHandler: function returnedObjectHandler() {},
|
||||
// function(key, value, options) triggered if key returns object but returnObjects is set to false
|
||||
parseMissingKeyHandler: false,
|
||||
// function(key) parsed a key that was not found in t() before returning
|
||||
appendNamespaceToMissingKey: false,
|
||||
appendNamespaceToCIMode: false,
|
||||
overloadTranslationOptionHandler: function handle(args) {
|
||||
var ret = {};
|
||||
if (_typeof(args[1]) === 'object') ret = args[1];
|
||||
if (typeof args[1] === 'string') ret.defaultValue = args[1];
|
||||
if (typeof args[2] === 'string') ret.tDescription = args[2];
|
||||
|
||||
if (_typeof(args[2]) === 'object' || _typeof(args[3]) === 'object') {
|
||||
var options = args[3] || args[2];
|
||||
Object.keys(options).forEach(function (key) {
|
||||
ret[key] = options[key];
|
||||
});
|
||||
}
|
||||
|
||||
return ret;
|
||||
},
|
||||
interpolation: {
|
||||
escapeValue: true,
|
||||
format: function format(value, _format, lng) {
|
||||
return value;
|
||||
},
|
||||
prefix: '{{',
|
||||
suffix: '}}',
|
||||
formatSeparator: ',',
|
||||
// prefixEscaped: '{{',
|
||||
// suffixEscaped: '}}',
|
||||
// unescapeSuffix: '',
|
||||
unescapePrefix: '-',
|
||||
nestingPrefix: '$t(',
|
||||
nestingSuffix: ')',
|
||||
// nestingPrefixEscaped: '$t(',
|
||||
// nestingSuffixEscaped: ')',
|
||||
// defaultVariables: undefined // object that can have values to interpolate on - extends passed in interpolation data
|
||||
maxReplaces: 1000 // max replaces to prevent endless loop
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
/* eslint no-param-reassign: 0 */
|
||||
|
||||
export function transformOptions(options) {
|
||||
// create namespace object if namespace is passed in as string
|
||||
if (typeof options.ns === 'string') options.ns = [options.ns];
|
||||
if (typeof options.fallbackLng === 'string') options.fallbackLng = [options.fallbackLng];
|
||||
if (typeof options.fallbackNS === 'string') options.fallbackNS = [options.fallbackNS]; // extend whitelist with cimode
|
||||
|
||||
if (options.whitelist && options.whitelist.indexOf('cimode') < 0) {
|
||||
options.whitelist = options.whitelist.concat(['cimode']);
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
453
node_modules/i18next/dist/es/i18next.js
generated
vendored
Normal file
453
node_modules/i18next/dist/es/i18next.js
generated
vendored
Normal file
@@ -0,0 +1,453 @@
|
||||
import _typeof from "@babel/runtime/helpers/typeof";
|
||||
import _objectSpread from "@babel/runtime/helpers/objectSpread";
|
||||
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
||||
import _createClass from "@babel/runtime/helpers/createClass";
|
||||
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
||||
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
||||
import _inherits from "@babel/runtime/helpers/inherits";
|
||||
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
||||
import baseLogger from './logger.js';
|
||||
import EventEmitter from './EventEmitter.js';
|
||||
import ResourceStore from './ResourceStore.js';
|
||||
import Translator from './Translator.js';
|
||||
import LanguageUtils from './LanguageUtils.js';
|
||||
import PluralResolver from './PluralResolver.js';
|
||||
import Interpolator from './Interpolator.js';
|
||||
import BackendConnector from './BackendConnector.js';
|
||||
import { get as getDefaults, transformOptions } from './defaults.js';
|
||||
import postProcessor from './postProcessor.js';
|
||||
import { defer } from './utils.js';
|
||||
|
||||
function noop() {}
|
||||
|
||||
var I18n =
|
||||
/*#__PURE__*/
|
||||
function (_EventEmitter) {
|
||||
_inherits(I18n, _EventEmitter);
|
||||
|
||||
function I18n() {
|
||||
var _this;
|
||||
|
||||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
||||
|
||||
_classCallCheck(this, I18n);
|
||||
|
||||
_this = _possibleConstructorReturn(this, _getPrototypeOf(I18n).call(this));
|
||||
EventEmitter.call(_assertThisInitialized(_assertThisInitialized(_this))); // <=IE10 fix (unable to call parent constructor)
|
||||
|
||||
_this.options = transformOptions(options);
|
||||
_this.services = {};
|
||||
_this.logger = baseLogger;
|
||||
_this.modules = {
|
||||
external: []
|
||||
};
|
||||
|
||||
if (callback && !_this.isInitialized && !options.isClone) {
|
||||
// https://github.com/i18next/i18next/issues/879
|
||||
if (!_this.options.initImmediate) {
|
||||
_this.init(options, callback);
|
||||
|
||||
return _possibleConstructorReturn(_this, _assertThisInitialized(_assertThisInitialized(_this)));
|
||||
}
|
||||
|
||||
setTimeout(function () {
|
||||
_this.init(options, callback);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(I18n, [{
|
||||
key: "init",
|
||||
value: function init() {
|
||||
var _this2 = this;
|
||||
|
||||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
||||
|
||||
if (typeof options === 'function') {
|
||||
callback = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
this.options = _objectSpread({}, getDefaults(), this.options, transformOptions(options));
|
||||
this.format = this.options.interpolation.format;
|
||||
if (!callback) callback = noop;
|
||||
|
||||
function createClassOnDemand(ClassOrObject) {
|
||||
if (!ClassOrObject) return null;
|
||||
if (typeof ClassOrObject === 'function') return new ClassOrObject();
|
||||
return ClassOrObject;
|
||||
} // init services
|
||||
|
||||
|
||||
if (!this.options.isClone) {
|
||||
if (this.modules.logger) {
|
||||
baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
|
||||
} else {
|
||||
baseLogger.init(null, this.options);
|
||||
}
|
||||
|
||||
var lu = new LanguageUtils(this.options);
|
||||
this.store = new ResourceStore(this.options.resources, this.options);
|
||||
var s = this.services;
|
||||
s.logger = baseLogger;
|
||||
s.resourceStore = this.store;
|
||||
s.languageUtils = lu;
|
||||
s.pluralResolver = new PluralResolver(lu, {
|
||||
prepend: this.options.pluralSeparator,
|
||||
compatibilityJSON: this.options.compatibilityJSON,
|
||||
simplifyPluralSuffix: this.options.simplifyPluralSuffix
|
||||
});
|
||||
s.interpolator = new Interpolator(this.options);
|
||||
s.backendConnector = new BackendConnector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options); // pipe events from backendConnector
|
||||
|
||||
s.backendConnector.on('*', function (event) {
|
||||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||||
args[_key - 1] = arguments[_key];
|
||||
}
|
||||
|
||||
_this2.emit.apply(_this2, [event].concat(args));
|
||||
});
|
||||
|
||||
if (this.modules.languageDetector) {
|
||||
s.languageDetector = createClassOnDemand(this.modules.languageDetector);
|
||||
s.languageDetector.init(s, this.options.detection, this.options);
|
||||
}
|
||||
|
||||
if (this.modules.i18nFormat) {
|
||||
s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
|
||||
if (s.i18nFormat.init) s.i18nFormat.init(this);
|
||||
}
|
||||
|
||||
this.translator = new Translator(this.services, this.options); // pipe events from translator
|
||||
|
||||
this.translator.on('*', function (event) {
|
||||
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
||||
args[_key2 - 1] = arguments[_key2];
|
||||
}
|
||||
|
||||
_this2.emit.apply(_this2, [event].concat(args));
|
||||
});
|
||||
this.modules.external.forEach(function (m) {
|
||||
if (m.init) m.init(_this2);
|
||||
});
|
||||
} // append api
|
||||
|
||||
|
||||
var storeApi = ['getResource', 'addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];
|
||||
storeApi.forEach(function (fcName) {
|
||||
_this2[fcName] = function () {
|
||||
var _this2$store;
|
||||
|
||||
return (_this2$store = _this2.store)[fcName].apply(_this2$store, arguments);
|
||||
};
|
||||
});
|
||||
var deferred = defer();
|
||||
|
||||
var load = function load() {
|
||||
_this2.changeLanguage(_this2.options.lng, function (err, t) {
|
||||
_this2.isInitialized = true;
|
||||
|
||||
_this2.logger.log('initialized', _this2.options);
|
||||
|
||||
_this2.emit('initialized', _this2.options);
|
||||
|
||||
deferred.resolve(t); // not rejecting on err (as err is only a loading translation failed warning)
|
||||
|
||||
callback(err, t);
|
||||
});
|
||||
};
|
||||
|
||||
if (this.options.resources || !this.options.initImmediate) {
|
||||
load();
|
||||
} else {
|
||||
setTimeout(load, 0);
|
||||
}
|
||||
|
||||
return deferred;
|
||||
}
|
||||
/* eslint consistent-return: 0 */
|
||||
|
||||
}, {
|
||||
key: "loadResources",
|
||||
value: function loadResources() {
|
||||
var _this3 = this;
|
||||
|
||||
var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : noop;
|
||||
|
||||
if (!this.options.resources || this.options.partialBundledLanguages) {
|
||||
if (this.language && this.language.toLowerCase() === 'cimode') return callback(); // avoid loading resources for cimode
|
||||
|
||||
var toLoad = [];
|
||||
|
||||
var append = function append(lng) {
|
||||
if (!lng) return;
|
||||
|
||||
var lngs = _this3.services.languageUtils.toResolveHierarchy(lng);
|
||||
|
||||
lngs.forEach(function (l) {
|
||||
if (toLoad.indexOf(l) < 0) toLoad.push(l);
|
||||
});
|
||||
};
|
||||
|
||||
if (!this.language) {
|
||||
// at least load fallbacks in this case
|
||||
var fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
|
||||
fallbacks.forEach(function (l) {
|
||||
return append(l);
|
||||
});
|
||||
} else {
|
||||
append(this.language);
|
||||
}
|
||||
|
||||
if (this.options.preload) {
|
||||
this.options.preload.forEach(function (l) {
|
||||
return append(l);
|
||||
});
|
||||
}
|
||||
|
||||
this.services.backendConnector.load(toLoad, this.options.ns, callback);
|
||||
} else {
|
||||
callback(null);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "reloadResources",
|
||||
value: function reloadResources(lngs, ns, callback) {
|
||||
var deferred = defer();
|
||||
if (!lngs) lngs = this.languages;
|
||||
if (!ns) ns = this.options.ns;
|
||||
if (!callback) callback = noop;
|
||||
this.services.backendConnector.reload(lngs, ns, function (err) {
|
||||
deferred.resolve(); // not rejecting on err (as err is only a loading translation failed warning)
|
||||
|
||||
callback(err);
|
||||
});
|
||||
return deferred;
|
||||
}
|
||||
}, {
|
||||
key: "use",
|
||||
value: function use(module) {
|
||||
if (module.type === 'backend') {
|
||||
this.modules.backend = module;
|
||||
}
|
||||
|
||||
if (module.type === 'logger' || module.log && module.warn && module.error) {
|
||||
this.modules.logger = module;
|
||||
}
|
||||
|
||||
if (module.type === 'languageDetector') {
|
||||
this.modules.languageDetector = module;
|
||||
}
|
||||
|
||||
if (module.type === 'i18nFormat') {
|
||||
this.modules.i18nFormat = module;
|
||||
}
|
||||
|
||||
if (module.type === 'postProcessor') {
|
||||
postProcessor.addPostProcessor(module);
|
||||
}
|
||||
|
||||
if (module.type === '3rdParty') {
|
||||
this.modules.external.push(module);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}, {
|
||||
key: "changeLanguage",
|
||||
value: function changeLanguage(lng, callback) {
|
||||
var _this4 = this;
|
||||
|
||||
var deferred = defer();
|
||||
|
||||
var done = function done(err, l) {
|
||||
_this4.translator.changeLanguage(l);
|
||||
|
||||
if (l) {
|
||||
_this4.emit('languageChanged', l);
|
||||
|
||||
_this4.logger.log('languageChanged', l);
|
||||
}
|
||||
|
||||
deferred.resolve(function () {
|
||||
return _this4.t.apply(_this4, arguments);
|
||||
});
|
||||
if (callback) callback(err, function () {
|
||||
return _this4.t.apply(_this4, arguments);
|
||||
});
|
||||
};
|
||||
|
||||
var setLng = function setLng(l) {
|
||||
if (l) {
|
||||
_this4.language = l;
|
||||
_this4.languages = _this4.services.languageUtils.toResolveHierarchy(l);
|
||||
if (!_this4.translator.language) _this4.translator.changeLanguage(l);
|
||||
if (_this4.services.languageDetector) _this4.services.languageDetector.cacheUserLanguage(l);
|
||||
}
|
||||
|
||||
_this4.loadResources(function (err) {
|
||||
done(err, l);
|
||||
});
|
||||
};
|
||||
|
||||
if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
|
||||
setLng(this.services.languageDetector.detect());
|
||||
} else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
|
||||
this.services.languageDetector.detect(setLng);
|
||||
} else {
|
||||
setLng(lng);
|
||||
}
|
||||
|
||||
return deferred;
|
||||
}
|
||||
}, {
|
||||
key: "getFixedT",
|
||||
value: function getFixedT(lng, ns) {
|
||||
var _this5 = this;
|
||||
|
||||
var fixedT = function fixedT(key, opts) {
|
||||
var options = _objectSpread({}, opts);
|
||||
|
||||
if (_typeof(opts) !== 'object') {
|
||||
for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
|
||||
rest[_key3 - 2] = arguments[_key3];
|
||||
}
|
||||
|
||||
options = _this5.options.overloadTranslationOptionHandler([key, opts].concat(rest));
|
||||
}
|
||||
|
||||
options.lng = options.lng || fixedT.lng;
|
||||
options.lngs = options.lngs || fixedT.lngs;
|
||||
options.ns = options.ns || fixedT.ns;
|
||||
return _this5.t(key, options);
|
||||
};
|
||||
|
||||
if (typeof lng === 'string') {
|
||||
fixedT.lng = lng;
|
||||
} else {
|
||||
fixedT.lngs = lng;
|
||||
}
|
||||
|
||||
fixedT.ns = ns;
|
||||
return fixedT;
|
||||
}
|
||||
}, {
|
||||
key: "t",
|
||||
value: function t() {
|
||||
var _this$translator;
|
||||
|
||||
return this.translator && (_this$translator = this.translator).translate.apply(_this$translator, arguments);
|
||||
}
|
||||
}, {
|
||||
key: "exists",
|
||||
value: function exists() {
|
||||
var _this$translator2;
|
||||
|
||||
return this.translator && (_this$translator2 = this.translator).exists.apply(_this$translator2, arguments);
|
||||
}
|
||||
}, {
|
||||
key: "setDefaultNamespace",
|
||||
value: function setDefaultNamespace(ns) {
|
||||
this.options.defaultNS = ns;
|
||||
}
|
||||
}, {
|
||||
key: "loadNamespaces",
|
||||
value: function loadNamespaces(ns, callback) {
|
||||
var _this6 = this;
|
||||
|
||||
var deferred = defer();
|
||||
|
||||
if (!this.options.ns) {
|
||||
callback && callback();
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (typeof ns === 'string') ns = [ns];
|
||||
ns.forEach(function (n) {
|
||||
if (_this6.options.ns.indexOf(n) < 0) _this6.options.ns.push(n);
|
||||
});
|
||||
this.loadResources(function (err) {
|
||||
deferred.resolve();
|
||||
if (callback) callback(err);
|
||||
});
|
||||
return deferred;
|
||||
}
|
||||
}, {
|
||||
key: "loadLanguages",
|
||||
value: function loadLanguages(lngs, callback) {
|
||||
var deferred = defer();
|
||||
if (typeof lngs === 'string') lngs = [lngs];
|
||||
var preloaded = this.options.preload || [];
|
||||
var newLngs = lngs.filter(function (lng) {
|
||||
return preloaded.indexOf(lng) < 0;
|
||||
}); // Exit early if all given languages are already preloaded
|
||||
|
||||
if (!newLngs.length) {
|
||||
if (callback) callback();
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
this.options.preload = preloaded.concat(newLngs);
|
||||
this.loadResources(function (err) {
|
||||
deferred.resolve();
|
||||
if (callback) callback(err);
|
||||
});
|
||||
return deferred;
|
||||
}
|
||||
}, {
|
||||
key: "dir",
|
||||
value: function dir(lng) {
|
||||
if (!lng) lng = this.languages && this.languages.length > 0 ? this.languages[0] : this.language;
|
||||
if (!lng) return 'rtl';
|
||||
var rtlLngs = ['ar', 'shu', 'sqr', 'ssh', 'xaa', 'yhd', 'yud', 'aao', 'abh', 'abv', 'acm', 'acq', 'acw', 'acx', 'acy', 'adf', 'ads', 'aeb', 'aec', 'afb', 'ajp', 'apc', 'apd', 'arb', 'arq', 'ars', 'ary', 'arz', 'auz', 'avl', 'ayh', 'ayl', 'ayn', 'ayp', 'bbz', 'pga', 'he', 'iw', 'ps', 'pbt', 'pbu', 'pst', 'prp', 'prd', 'ur', 'ydd', 'yds', 'yih', 'ji', 'yi', 'hbo', 'men', 'xmn', 'fa', 'jpr', 'peo', 'pes', 'prs', 'dv', 'sam'];
|
||||
return rtlLngs.indexOf(this.services.languageUtils.getLanguagePartFromCode(lng)) >= 0 ? 'rtl' : 'ltr';
|
||||
}
|
||||
/* eslint class-methods-use-this: 0 */
|
||||
|
||||
}, {
|
||||
key: "createInstance",
|
||||
value: function createInstance() {
|
||||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
||||
return new I18n(options, callback);
|
||||
}
|
||||
}, {
|
||||
key: "cloneInstance",
|
||||
value: function cloneInstance() {
|
||||
var _this7 = this;
|
||||
|
||||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
|
||||
|
||||
var mergedOptions = _objectSpread({}, this.options, options, {
|
||||
isClone: true
|
||||
});
|
||||
|
||||
var clone = new I18n(mergedOptions);
|
||||
var membersToCopy = ['store', 'services', 'language'];
|
||||
membersToCopy.forEach(function (m) {
|
||||
clone[m] = _this7[m];
|
||||
});
|
||||
clone.translator = new Translator(clone.services, clone.options);
|
||||
clone.translator.on('*', function (event) {
|
||||
for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
||||
args[_key4 - 1] = arguments[_key4];
|
||||
}
|
||||
|
||||
clone.emit.apply(clone, [event].concat(args));
|
||||
});
|
||||
clone.init(mergedOptions, callback);
|
||||
clone.translator.options = clone.options; // sync options
|
||||
|
||||
return clone;
|
||||
}
|
||||
}]);
|
||||
|
||||
return I18n;
|
||||
}(EventEmitter);
|
||||
|
||||
export default new I18n();
|
17
node_modules/i18next/dist/es/index.js
generated
vendored
Normal file
17
node_modules/i18next/dist/es/index.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import i18next from './i18next.js';
|
||||
export default i18next;
|
||||
export var changeLanguage = i18next.changeLanguage.bind(i18next);
|
||||
export var cloneInstance = i18next.cloneInstance.bind(i18next);
|
||||
export var createInstance = i18next.createInstance.bind(i18next);
|
||||
export var dir = i18next.dir.bind(i18next);
|
||||
export var exists = i18next.exists.bind(i18next);
|
||||
export var getFixedT = i18next.getFixedT.bind(i18next);
|
||||
export var init = i18next.init.bind(i18next);
|
||||
export var loadLanguages = i18next.loadLanguages.bind(i18next);
|
||||
export var loadNamespaces = i18next.loadNamespaces.bind(i18next);
|
||||
export var loadResources = i18next.loadResources.bind(i18next);
|
||||
export var off = i18next.off.bind(i18next);
|
||||
export var on = i18next.on.bind(i18next);
|
||||
export var setDefaultNamespace = i18next.setDefaultNamespace.bind(i18next);
|
||||
export var t = i18next.t.bind(i18next);
|
||||
export var use = i18next.use.bind(i18next);
|
104
node_modules/i18next/dist/es/logger.js
generated
vendored
Normal file
104
node_modules/i18next/dist/es/logger.js
generated
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
import _objectSpread from "@babel/runtime/helpers/objectSpread";
|
||||
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
||||
import _createClass from "@babel/runtime/helpers/createClass";
|
||||
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
||||
var consoleLogger = {
|
||||
type: 'logger',
|
||||
log: function log(args) {
|
||||
this.output('log', args);
|
||||
},
|
||||
warn: function warn(args) {
|
||||
this.output('warn', args);
|
||||
},
|
||||
error: function error(args) {
|
||||
this.output('error', args);
|
||||
},
|
||||
output: function output(type, args) {
|
||||
var _console;
|
||||
|
||||
/* eslint no-console: 0 */
|
||||
if (console && console[type]) (_console = console)[type].apply(_console, _toConsumableArray(args));
|
||||
}
|
||||
};
|
||||
|
||||
var Logger =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function Logger(concreteLogger) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
|
||||
_classCallCheck(this, Logger);
|
||||
|
||||
this.init(concreteLogger, options);
|
||||
}
|
||||
|
||||
_createClass(Logger, [{
|
||||
key: "init",
|
||||
value: function init(concreteLogger) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
this.prefix = options.prefix || 'i18next:';
|
||||
this.logger = concreteLogger || consoleLogger;
|
||||
this.options = options;
|
||||
this.debug = options.debug;
|
||||
}
|
||||
}, {
|
||||
key: "setDebug",
|
||||
value: function setDebug(bool) {
|
||||
this.debug = bool;
|
||||
}
|
||||
}, {
|
||||
key: "log",
|
||||
value: function log() {
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
return this.forward(args, 'log', '', true);
|
||||
}
|
||||
}, {
|
||||
key: "warn",
|
||||
value: function warn() {
|
||||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
||||
args[_key2] = arguments[_key2];
|
||||
}
|
||||
|
||||
return this.forward(args, 'warn', '', true);
|
||||
}
|
||||
}, {
|
||||
key: "error",
|
||||
value: function error() {
|
||||
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
||||
args[_key3] = arguments[_key3];
|
||||
}
|
||||
|
||||
return this.forward(args, 'error', '');
|
||||
}
|
||||
}, {
|
||||
key: "deprecate",
|
||||
value: function deprecate() {
|
||||
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
||||
args[_key4] = arguments[_key4];
|
||||
}
|
||||
|
||||
return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
|
||||
}
|
||||
}, {
|
||||
key: "forward",
|
||||
value: function forward(args, lvl, prefix, debugOnly) {
|
||||
if (debugOnly && !this.debug) return null;
|
||||
if (typeof args[0] === 'string') args[0] = "".concat(prefix).concat(this.prefix, " ").concat(args[0]);
|
||||
return this.logger[lvl](args);
|
||||
}
|
||||
}, {
|
||||
key: "create",
|
||||
value: function create(moduleName) {
|
||||
return new Logger(this.logger, _objectSpread({}, {
|
||||
prefix: "".concat(this.prefix, ":").concat(moduleName, ":")
|
||||
}, this.options));
|
||||
}
|
||||
}]);
|
||||
|
||||
return Logger;
|
||||
}();
|
||||
|
||||
export default new Logger();
|
14
node_modules/i18next/dist/es/postProcessor.js
generated
vendored
Normal file
14
node_modules/i18next/dist/es/postProcessor.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
export default {
|
||||
processors: {},
|
||||
addPostProcessor: function addPostProcessor(module) {
|
||||
this.processors[module.name] = module;
|
||||
},
|
||||
handle: function handle(processors, value, key, options, translator) {
|
||||
var _this = this;
|
||||
|
||||
processors.forEach(function (processor) {
|
||||
if (_this.processors[processor]) value = _this.processors[processor].process(value, key, options, translator);
|
||||
});
|
||||
return value;
|
||||
}
|
||||
};
|
115
node_modules/i18next/dist/es/utils.js
generated
vendored
Normal file
115
node_modules/i18next/dist/es/utils.js
generated
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
// http://lea.verou.me/2016/12/resolve-promises-externally-with-this-one-weird-trick/
|
||||
export function defer() {
|
||||
var res;
|
||||
var rej;
|
||||
var promise = new Promise(function (resolve, reject) {
|
||||
res = resolve;
|
||||
rej = reject;
|
||||
});
|
||||
promise.resolve = res;
|
||||
promise.reject = rej;
|
||||
return promise;
|
||||
}
|
||||
export function makeString(object) {
|
||||
if (object == null) return '';
|
||||
/* eslint prefer-template: 0 */
|
||||
|
||||
return '' + object;
|
||||
}
|
||||
export function copy(a, s, t) {
|
||||
a.forEach(function (m) {
|
||||
if (s[m]) t[m] = s[m];
|
||||
});
|
||||
}
|
||||
|
||||
function getLastOfPath(object, path, Empty) {
|
||||
function cleanKey(key) {
|
||||
return key && key.indexOf('###') > -1 ? key.replace(/###/g, '.') : key;
|
||||
}
|
||||
|
||||
function canNotTraverseDeeper() {
|
||||
return !object || typeof object === 'string';
|
||||
}
|
||||
|
||||
var stack = typeof path !== 'string' ? [].concat(path) : path.split('.');
|
||||
|
||||
while (stack.length > 1) {
|
||||
if (canNotTraverseDeeper()) return {};
|
||||
var key = cleanKey(stack.shift());
|
||||
if (!object[key] && Empty) object[key] = new Empty();
|
||||
object = object[key];
|
||||
}
|
||||
|
||||
if (canNotTraverseDeeper()) return {};
|
||||
return {
|
||||
obj: object,
|
||||
k: cleanKey(stack.shift())
|
||||
};
|
||||
}
|
||||
|
||||
export function setPath(object, path, newValue) {
|
||||
var _getLastOfPath = getLastOfPath(object, path, Object),
|
||||
obj = _getLastOfPath.obj,
|
||||
k = _getLastOfPath.k;
|
||||
|
||||
obj[k] = newValue;
|
||||
}
|
||||
export function pushPath(object, path, newValue, concat) {
|
||||
var _getLastOfPath2 = getLastOfPath(object, path, Object),
|
||||
obj = _getLastOfPath2.obj,
|
||||
k = _getLastOfPath2.k;
|
||||
|
||||
obj[k] = obj[k] || [];
|
||||
if (concat) obj[k] = obj[k].concat(newValue);
|
||||
if (!concat) obj[k].push(newValue);
|
||||
}
|
||||
export function getPath(object, path) {
|
||||
var _getLastOfPath3 = getLastOfPath(object, path),
|
||||
obj = _getLastOfPath3.obj,
|
||||
k = _getLastOfPath3.k;
|
||||
|
||||
if (!obj) return undefined;
|
||||
return obj[k];
|
||||
}
|
||||
export function deepExtend(target, source, overwrite) {
|
||||
/* eslint no-restricted-syntax: 0 */
|
||||
for (var prop in source) {
|
||||
if (prop in target) {
|
||||
// If we reached a leaf string in target or source then replace with source or skip depending on the 'overwrite' switch
|
||||
if (typeof target[prop] === 'string' || target[prop] instanceof String || typeof source[prop] === 'string' || source[prop] instanceof String) {
|
||||
if (overwrite) target[prop] = source[prop];
|
||||
} else {
|
||||
deepExtend(target[prop], source[prop], overwrite);
|
||||
}
|
||||
} else {
|
||||
target[prop] = source[prop];
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
export function regexEscape(str) {
|
||||
/* eslint no-useless-escape: 0 */
|
||||
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
|
||||
}
|
||||
/* eslint-disable */
|
||||
|
||||
var _entityMap = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
"'": ''',
|
||||
'/': '/'
|
||||
};
|
||||
/* eslint-enable */
|
||||
|
||||
export function escape(data) {
|
||||
if (typeof data === 'string') {
|
||||
return data.replace(/[&<>"'\/]/g, function (s) {
|
||||
return _entityMap[s];
|
||||
});
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
2344
node_modules/i18next/dist/umd/i18next.js
generated
vendored
Normal file
2344
node_modules/i18next/dist/umd/i18next.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/i18next/dist/umd/i18next.min.js
generated
vendored
Normal file
1
node_modules/i18next/dist/umd/i18next.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2344
node_modules/i18next/i18next.js
generated
vendored
Normal file
2344
node_modules/i18next/i18next.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/i18next/i18next.min.js
generated
vendored
Normal file
1
node_modules/i18next/i18next.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
841
node_modules/i18next/index.d.ts
generated
vendored
Normal file
841
node_modules/i18next/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,841 @@
|
||||
// Type definitions for i18next
|
||||
// Project: http://i18next.com
|
||||
// Definitions by: Michael Ledin <https://github.com/mxl>
|
||||
// Budi Irawan <https://github.com/deerawan>
|
||||
// Giedrius Grabauskas <https://github.com/GiedriusGrabauskas>
|
||||
// Silas Rech <https://github.com/lenovouser>
|
||||
// Philipp Katz <https://github.com/qqilihq>
|
||||
// Milan Konir <https://github.com/butchyyyy>
|
||||
// Takeo Kusama <https://github.com/tkow>
|
||||
|
||||
declare namespace i18next {
|
||||
interface FallbackLngObjList {
|
||||
[language: string]: string[];
|
||||
}
|
||||
|
||||
type FallbackLng = string | string[] | FallbackLngObjList;
|
||||
|
||||
type FormatFunction = (value: any, format?: string, lng?: string) => string;
|
||||
|
||||
interface InterpolationOptions {
|
||||
/**
|
||||
* Format function see formatting for details
|
||||
* @default noop
|
||||
*/
|
||||
format?: FormatFunction;
|
||||
/**
|
||||
* Used to separate format from interpolation value
|
||||
* @default ','
|
||||
*/
|
||||
formatSeparator?: string;
|
||||
/**
|
||||
* Escape function
|
||||
* @default str => str
|
||||
*/
|
||||
escape?(str: string): string;
|
||||
|
||||
/**
|
||||
* Escape passed in values to avoid xss injection
|
||||
* @default true
|
||||
*/
|
||||
escapeValue?: boolean;
|
||||
/**
|
||||
* If true, then value passed into escape function is not casted to string, use with custom escape function that does its own type check
|
||||
* @default false
|
||||
*/
|
||||
useRawValueToEscape?: boolean;
|
||||
/**
|
||||
* Prefix for interpolation
|
||||
* @default '{{'
|
||||
*/
|
||||
prefix?: string;
|
||||
/**
|
||||
* Suffix for interpolation
|
||||
* @default '}}'
|
||||
*/
|
||||
suffix?: string;
|
||||
/**
|
||||
* Escaped prefix for interpolation (regexSafe)
|
||||
* @default undefined
|
||||
*/
|
||||
prefixEscaped?: string;
|
||||
/**
|
||||
* Escaped suffix for interpolation (regexSafe)
|
||||
* @default undefined
|
||||
*/
|
||||
suffixEscaped?: string;
|
||||
/**
|
||||
* Suffix to unescaped mode
|
||||
* @default undefined
|
||||
*/
|
||||
unescapeSuffix?: string;
|
||||
/**
|
||||
* Prefix to unescaped mode
|
||||
* @default '-'
|
||||
*/
|
||||
unescapePrefix?: string;
|
||||
/**
|
||||
* Prefix for nesting
|
||||
* @default '$t('
|
||||
*/
|
||||
nestingPrefix?: string;
|
||||
/**
|
||||
* Suffix for nesting
|
||||
* @default ')'
|
||||
*/
|
||||
nestingSuffix?: string;
|
||||
/**
|
||||
* Escaped prefix for nesting (regexSafe)
|
||||
* @default undefined
|
||||
*/
|
||||
nestingPrefixEscaped?: string;
|
||||
/**
|
||||
* Escaped suffix for nesting (regexSafe)
|
||||
* @default undefined
|
||||
*/
|
||||
nestingSuffixEscaped?: string;
|
||||
/**
|
||||
* Global variables to use in interpolation replacements
|
||||
* @default undefined
|
||||
*/
|
||||
defaultVariables?: { [index: string]: any };
|
||||
/**
|
||||
* After how many interpolation runs to break out before throwing a stack overflow
|
||||
* @default 1000
|
||||
*/
|
||||
maxReplaces?: number;
|
||||
}
|
||||
|
||||
interface ReactOptions {
|
||||
/**
|
||||
* Set to true if you like to wait for loaded in every translated hoc
|
||||
* @default false
|
||||
*/
|
||||
wait?: boolean;
|
||||
/**
|
||||
* Set it to fallback to let passed namespaces to translated hoc act as fallbacks
|
||||
* @default 'default'
|
||||
*/
|
||||
nsMode?: 'default' | 'fallback';
|
||||
/**
|
||||
* Set it to the default parent element created by the Trans component.
|
||||
* @default 'div'
|
||||
*/
|
||||
defaultTransParent?: string;
|
||||
/**
|
||||
* Set which events trigger a re-render, can be set to false or string of events
|
||||
* @default 'languageChanged loaded'
|
||||
*/
|
||||
bindI18n?: string | false;
|
||||
/**
|
||||
* Set which events on store trigger a re-render, can be set to false or string of events
|
||||
* @default 'added removed'
|
||||
*/
|
||||
bindStore?: string | false;
|
||||
/**
|
||||
* Set fallback value for Trans components without children
|
||||
* @default undefined
|
||||
*/
|
||||
transEmptyNodeValue?: string;
|
||||
/**
|
||||
* Set it to false if you do not want to use Suspense
|
||||
* @default true
|
||||
*/
|
||||
useSuspense?: boolean;
|
||||
/**
|
||||
* Function to generate an i18nKey from the defaultValue (or Trans children)
|
||||
* when no key is provided.
|
||||
* By default, the defaultValue (Trans text) itself is used as the key.
|
||||
* If you want to require keys for all translations, supply a function
|
||||
* that always throws an error.
|
||||
* @default undefined
|
||||
*/
|
||||
hashTransKey?(defaultValue: TOptionsBase['defaultValue']): TOptionsBase['defaultValue'];
|
||||
}
|
||||
|
||||
interface InitOptions {
|
||||
/**
|
||||
* Logs info level to console output. Helps finding issues with loading not working.
|
||||
* @default false
|
||||
*/
|
||||
debug?: boolean;
|
||||
|
||||
/**
|
||||
* Resources to initialize with (if not using loading or not appending using addResourceBundle)
|
||||
* @default undefined
|
||||
*/
|
||||
resources?: Resource;
|
||||
|
||||
/**
|
||||
* Allow initializing with bundled resources while using a backend to load non bundled ones.
|
||||
* @default false
|
||||
*/
|
||||
partialBundledLanguages?: boolean;
|
||||
|
||||
/**
|
||||
* Language to use (overrides language detection)
|
||||
* @default undefined
|
||||
*/
|
||||
lng?: string;
|
||||
|
||||
/**
|
||||
* Language to use if translations in user language are not available.
|
||||
* @default 'dev'
|
||||
*/
|
||||
fallbackLng?: false | FallbackLng;
|
||||
|
||||
/**
|
||||
* Array of allowed languages
|
||||
* @default false
|
||||
*/
|
||||
whitelist?: false | string[];
|
||||
|
||||
/**
|
||||
* If true will pass eg. en-US if finding en in whitelist
|
||||
* @default false
|
||||
*/
|
||||
nonExplicitWhitelist?: boolean;
|
||||
|
||||
/**
|
||||
* Language codes to lookup, given set language is
|
||||
* 'en-US': 'all' --> ['en-US', 'en', 'dev'],
|
||||
* 'currentOnly' --> 'en-US',
|
||||
* 'languageOnly' --> 'en'
|
||||
* @default 'all'
|
||||
*/
|
||||
load?: 'all' | 'currentOnly' | 'languageOnly';
|
||||
|
||||
/**
|
||||
* Array of languages to preload. Important on server-side to assert translations are loaded before rendering views.
|
||||
* @default false
|
||||
*/
|
||||
preload?: false | string[];
|
||||
|
||||
/**
|
||||
* Language will be lowercased eg. en-US --> en-us
|
||||
* @default false
|
||||
*/
|
||||
lowerCaseLng?: boolean;
|
||||
|
||||
/**
|
||||
* String or array of namespaces to load
|
||||
* @default 'translation'
|
||||
*/
|
||||
ns?: string | string[];
|
||||
|
||||
/**
|
||||
* Default namespace used if not passed to translation function
|
||||
* @default 'translation'
|
||||
*/
|
||||
defaultNS?: string;
|
||||
|
||||
/**
|
||||
* String or array of namespaces to lookup key if not found in given namespace.
|
||||
* @default false
|
||||
*/
|
||||
fallbackNS?: false | string | string[];
|
||||
|
||||
/**
|
||||
* Calls save missing key function on backend if key not found
|
||||
* @default false
|
||||
*/
|
||||
saveMissing?: boolean;
|
||||
|
||||
/**
|
||||
* Experimental: enable to update default values using the saveMissing
|
||||
* (Works only if defaultValue different from translated value.
|
||||
* Only useful on initial development or when keeping code as source of truth not changing values outside of code.
|
||||
* Only supported if backend supports it already)
|
||||
* @default false
|
||||
*/
|
||||
updateMissing?: boolean;
|
||||
|
||||
/**
|
||||
* @default 'fallback'
|
||||
*/
|
||||
saveMissingTo?: 'current' | 'all' | 'fallback';
|
||||
|
||||
/**
|
||||
* Used for custom missing key handling (needs saveMissing set to true!)
|
||||
* @default false
|
||||
*/
|
||||
missingKeyHandler?:
|
||||
| false
|
||||
| ((lngs: string[], ns: string, key: string, fallbackValue: string) => void);
|
||||
|
||||
/**
|
||||
* Receives a key that was not found in `t()` and returns a value, that will be returned by `t()`
|
||||
* @default noop
|
||||
*/
|
||||
parseMissingKeyHandler?(key: string): any;
|
||||
|
||||
/**
|
||||
* Appends namespace to missing key
|
||||
* @default false
|
||||
*/
|
||||
appendNamespaceToMissingKey?: boolean;
|
||||
|
||||
/**
|
||||
* Gets called in case a interpolation value is undefined. This method will not be called if the value is empty string or null
|
||||
* @default noop
|
||||
*/
|
||||
missingInterpolationHandler?: (text: string, value: any, options: InitOptions) => any;
|
||||
|
||||
/**
|
||||
* Will use 'plural' as suffix for languages only having 1 plural form, setting it to false will suffix all with numbers
|
||||
* @default true
|
||||
*/
|
||||
simplifyPluralSuffix?: boolean;
|
||||
|
||||
/**
|
||||
* String or array of postProcessors to apply per default
|
||||
* @default false
|
||||
*/
|
||||
postProcess?: false | string | string[];
|
||||
|
||||
/**
|
||||
* Allows null values as valid translation
|
||||
* @default true
|
||||
*/
|
||||
returnNull?: boolean;
|
||||
|
||||
/**
|
||||
* Allows empty string as valid translation
|
||||
* @default true
|
||||
*/
|
||||
returnEmptyString?: boolean;
|
||||
|
||||
/**
|
||||
* Allows objects as valid translation result
|
||||
* @default false
|
||||
*/
|
||||
returnObjects?: boolean;
|
||||
|
||||
/**
|
||||
* Gets called if object was passed in as key but returnObjects was set to false
|
||||
* @default noop
|
||||
*/
|
||||
returnedObjectHandler?(key: string, value: string, options: any): void;
|
||||
|
||||
/**
|
||||
* Char, eg. '\n' that arrays will be joined by
|
||||
* @default false
|
||||
*/
|
||||
joinArrays?: false | string;
|
||||
|
||||
/**
|
||||
* Sets defaultValue
|
||||
* @default args => ({ defaultValue: args[1] })
|
||||
*/
|
||||
overloadTranslationOptionHandler?(args: string[]): TOptions;
|
||||
|
||||
/**
|
||||
* @see https://www.i18next.com/interpolation.html
|
||||
*/
|
||||
interpolation?: InterpolationOptions;
|
||||
|
||||
/**
|
||||
* Options for language detection - check documentation of plugin
|
||||
* @default undefined
|
||||
*/
|
||||
detection?: object;
|
||||
|
||||
/**
|
||||
* Options for backend - check documentation of plugin
|
||||
* @default undefined
|
||||
*/
|
||||
backend?: object;
|
||||
|
||||
/**
|
||||
* Options for cache layer - check documentation of plugin
|
||||
* @default undefined
|
||||
*/
|
||||
cache?: object;
|
||||
|
||||
/**
|
||||
* Options for i18n message format - check documentation of plugin
|
||||
* @default undefined
|
||||
*/
|
||||
i18nFormat?: object;
|
||||
|
||||
/**
|
||||
* Options for react - check documentation of plugin
|
||||
* @default undefined
|
||||
*/
|
||||
react?: ReactOptions;
|
||||
|
||||
/**
|
||||
* Triggers resource loading in init function inside a setTimeout (default async behaviour).
|
||||
* Set it to false if your backend loads resources sync - that way calling i18next.t after
|
||||
* init is possible without relaying on the init callback.
|
||||
* @default true
|
||||
*/
|
||||
initImmediate?: boolean;
|
||||
|
||||
/**
|
||||
* Char to separate keys
|
||||
* @default '.'
|
||||
*/
|
||||
keySeparator?: false | string;
|
||||
|
||||
/**
|
||||
* Char to split namespace from key
|
||||
* @default ':'
|
||||
*/
|
||||
nsSeparator?: false | string;
|
||||
|
||||
/**
|
||||
* Char to split plural from key
|
||||
* @default '_'
|
||||
*/
|
||||
pluralSeparator?: string;
|
||||
|
||||
/**
|
||||
* Char to split context from key
|
||||
* @default '_'
|
||||
*/
|
||||
contextSeparator?: string;
|
||||
|
||||
/**
|
||||
* Prefixes the namespace to the returned key when using `cimode`
|
||||
* @default false
|
||||
*/
|
||||
appendNamespaceToCIMode?: boolean;
|
||||
|
||||
/**
|
||||
* Compatibility JSON version
|
||||
* @default 'v3'
|
||||
*/
|
||||
compatibilityJSON?: 'v1' | 'v2' | 'v3';
|
||||
}
|
||||
|
||||
interface TOptionsBase {
|
||||
/**
|
||||
* Default value to return if a translation was not found
|
||||
*/
|
||||
defaultValue?: any;
|
||||
/**
|
||||
* Count value used for plurals
|
||||
*/
|
||||
count?: number;
|
||||
/**
|
||||
* Used for contexts (eg. male\female)
|
||||
*/
|
||||
context?: any;
|
||||
/**
|
||||
* Object with vars for interpolation - or put them directly in options
|
||||
*/
|
||||
replace?: any;
|
||||
/**
|
||||
* Override language to use
|
||||
*/
|
||||
lng?: string;
|
||||
/**
|
||||
* Override languages to use
|
||||
*/
|
||||
lngs?: string[];
|
||||
/**
|
||||
* Override language to lookup key if not found see fallbacks for details
|
||||
*/
|
||||
fallbackLng?: FallbackLng;
|
||||
/**
|
||||
* Override namespaces (string or array)
|
||||
*/
|
||||
ns?: string | string[];
|
||||
/**
|
||||
* Override char to separate keys
|
||||
*/
|
||||
keySeparator?: string;
|
||||
/**
|
||||
* Override char to split namespace from key
|
||||
*/
|
||||
nsSeparator?: string;
|
||||
/**
|
||||
* Accessing an object not a translation string (can be set globally too)
|
||||
*/
|
||||
returnObjects?: boolean;
|
||||
/**
|
||||
* Char, eg. '\n' that arrays will be joined by (can be set globally too)
|
||||
*/
|
||||
joinArrays?: string;
|
||||
/**
|
||||
* String or array of postProcessors to apply see interval plurals as a sample
|
||||
*/
|
||||
postProcess?: string | string[];
|
||||
/**
|
||||
* Override interpolation options
|
||||
*/
|
||||
interpolation?: InterpolationOptions;
|
||||
}
|
||||
|
||||
// indexer that is open to any value
|
||||
type StringMap = { [key: string]: any };
|
||||
|
||||
/**
|
||||
* Options that allow open ended values for interpolation unless type is provided.
|
||||
*/
|
||||
type TOptions<TInterpolationMap extends object = StringMap> = TOptionsBase & TInterpolationMap;
|
||||
|
||||
type Callback = (error: any, t: TFunction) => void;
|
||||
|
||||
/**
|
||||
* Uses similar args as the t function and returns true if a key exists.
|
||||
*/
|
||||
interface ExistsFunction<
|
||||
TKeys extends string = string,
|
||||
TInterpolationMap extends object = StringMap
|
||||
> {
|
||||
(key: TKeys | TKeys[], options?: TOptions<TInterpolationMap>): boolean;
|
||||
}
|
||||
|
||||
interface WithT {
|
||||
// Expose parameterized t in the i18next interface hierarchy
|
||||
t: TFunction;
|
||||
}
|
||||
|
||||
type TFunction = <
|
||||
TResult extends string | object | Array<string | object> | undefined = string,
|
||||
TKeys extends string | TemplateStringsArray = string,
|
||||
TInterpolationMap extends object = StringMap
|
||||
>(
|
||||
key: TKeys | TKeys[],
|
||||
options?: TOptions<TInterpolationMap> | string,
|
||||
) => TResult;
|
||||
|
||||
interface Resource {
|
||||
[language: string]: ResourceLanguage;
|
||||
}
|
||||
|
||||
interface ResourceLanguage {
|
||||
[namespace: string]: ResourceKey;
|
||||
}
|
||||
|
||||
interface ResourceKey {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface Interpolator {
|
||||
init(options: InterpolationOptions, reset: boolean): undefined;
|
||||
reset(): undefined;
|
||||
resetRegExp(): undefined;
|
||||
interpolate(str: string, data: object, lng: string, options: InterpolationOptions): string;
|
||||
nest(str: string, fc: (...args: any[]) => any, options: InterpolationOptions): string;
|
||||
}
|
||||
|
||||
interface Services {
|
||||
backendConnector: any;
|
||||
i18nFormat: any;
|
||||
interpolator: Interpolator;
|
||||
languageDetector: any;
|
||||
languageUtils: any;
|
||||
logger: any;
|
||||
pluralResolver: any;
|
||||
resourceStore: Resource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to load data for i18next.
|
||||
* Can be provided as a singleton or as a prototype constructor (preferred for supporting multiple instances of i18next).
|
||||
* For singleton set property `type` to `'backend'` For a prototype constructor set static property.
|
||||
*/
|
||||
interface BackendModule {
|
||||
type?: 'backend';
|
||||
init(services: Services, backendOptions: object, i18nextOptions: InitOptions): void;
|
||||
read(
|
||||
language: string,
|
||||
namespace: string,
|
||||
callback: (err: Error, data: ResourceLanguage) => void,
|
||||
): void;
|
||||
/** Save the missing translation */
|
||||
create(languages: string[], namespace: string, key: string, fallbackValue: string): void;
|
||||
/** Load multiple languages and namespaces. For backends supporting multiple resources loading */
|
||||
readMulti?(
|
||||
languages: string[],
|
||||
namespaces: string[],
|
||||
callback: (err: Error, data: Resource) => void,
|
||||
): void;
|
||||
/** Store the translation. For backends acting as cache layer */
|
||||
save?(language: string, namespace: string, data: ResourceLanguage): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to detect language in user land.
|
||||
* Can be provided as a singleton or as a prototype constructor (preferred for supporting multiple instances of i18next).
|
||||
* For singleton set property `type` to `'languageDetector'` For a prototype constructor set static property.
|
||||
*/
|
||||
interface LanguageDetectorModule {
|
||||
type?: 'languageDetector';
|
||||
init(services: Services, detectorOptions: object, i18nextOptions: InitOptions): void;
|
||||
/** Must return detected language */
|
||||
detect(): string;
|
||||
cacheUserLanguage(lng: string): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to detect language in user land.
|
||||
* Can be provided as a singleton or as a prototype constructor (preferred for supporting multiple instances of i18next).
|
||||
* For singleton set property `type` to `'languageDetector'` For a prototype constructor set static property.
|
||||
*/
|
||||
interface LanguageDetectorAsyncModule {
|
||||
type?: 'languageDetector';
|
||||
/** Set to true to enable async detection */
|
||||
async: true;
|
||||
init(services: Services, detectorOptions: object, i18nextOptions: InitOptions): void;
|
||||
/** Must call callback passing detected language */
|
||||
detect(callback: (lng: string) => void): void;
|
||||
cacheUserLanguage(lng: string): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to extend or manipulate the translated values before returning them in `t` function.
|
||||
* Need to be a singleton object.
|
||||
*/
|
||||
interface PostProcessorModule {
|
||||
/** Unique name */
|
||||
name: string;
|
||||
type: 'postProcessor';
|
||||
process(value: string, key: string, options: TOptions, translator: any): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the built-in console logger.
|
||||
* Do not need to be a prototype function.
|
||||
*/
|
||||
interface LoggerModule {
|
||||
type?: 'logger';
|
||||
log(...args: any[]): void;
|
||||
warn(...args: any[]): void;
|
||||
error(...args: any[]): void;
|
||||
}
|
||||
|
||||
interface I18nFormatModule {
|
||||
type?: 'i18nFormat';
|
||||
}
|
||||
|
||||
interface ThirdPartyModule {
|
||||
type: '3rdParty';
|
||||
init(i18n: i18n): void;
|
||||
}
|
||||
|
||||
interface Modules {
|
||||
backend?: BackendModule;
|
||||
logger?: LoggerModule;
|
||||
languageDetector?: LanguageDetectorModule | LanguageDetectorAsyncModule;
|
||||
i18nFormat?: I18nFormatModule;
|
||||
external: ThirdPartyModule[];
|
||||
}
|
||||
|
||||
interface i18n extends WithT {
|
||||
/**
|
||||
* The default export of the i18next module is an i18next instance ready to be initialized by calling init.
|
||||
* You can create additional instances using the createInstance function.
|
||||
*
|
||||
* @param options - Initial options.
|
||||
* @param callback - will be called after all translations were loaded or with an error when failed (in case of using a backend).
|
||||
*/
|
||||
init(callback?: Callback): Promise<TFunction>;
|
||||
init(options: InitOptions, callback?: Callback): Promise<TFunction>;
|
||||
|
||||
loadResources(callback?: (err: any) => void): void;
|
||||
|
||||
/**
|
||||
* The use function is there to load additional plugins to i18next.
|
||||
* For available module see the plugins page and don't forget to read the documentation of the plugin.
|
||||
*/
|
||||
use(module: any): i18n;
|
||||
|
||||
/**
|
||||
* List of modules used
|
||||
*/
|
||||
modules: Modules;
|
||||
|
||||
/**
|
||||
* Internal container for all used plugins and implementation details like languageUtils, pluralResolvers, etc.
|
||||
*/
|
||||
services: Services;
|
||||
|
||||
/**
|
||||
* Uses similar args as the t function and returns true if a key exists.
|
||||
*/
|
||||
exists: ExistsFunction;
|
||||
|
||||
/**
|
||||
* Returns a t function that defaults to given language or namespace.
|
||||
* Both params could be arrays of languages or namespaces and will be treated as fallbacks in that case.
|
||||
* On the returned function you can like in the t function override the languages or namespaces by passing them in options or by prepending namespace.
|
||||
*/
|
||||
getFixedT(lng: string | string[], ns?: string | string[]): TFunction;
|
||||
getFixedT(lng: null, ns: string | string[]): TFunction;
|
||||
|
||||
/**
|
||||
* Changes the language. The callback will be called as soon translations were loaded or an error occurs while loading.
|
||||
* HINT: For easy testing - setting lng to 'cimode' will set t function to always return the key.
|
||||
*/
|
||||
changeLanguage(lng: string, callback?: Callback): Promise<TFunction>;
|
||||
|
||||
/**
|
||||
* Is set to the current detected or set language.
|
||||
* If you need the primary used language depending on your configuration (whilelist, load) you will prefer using i18next.languages[0].
|
||||
*/
|
||||
language: string;
|
||||
|
||||
/**
|
||||
* Is set to an array of language-codes that will be used it order to lookup the translation value.
|
||||
*/
|
||||
languages: string[];
|
||||
|
||||
/**
|
||||
* Loads additional namespaces not defined in init options.
|
||||
*/
|
||||
loadNamespaces(ns: string | string[], callback?: Callback): Promise<void>;
|
||||
|
||||
/**
|
||||
* Loads additional languages not defined in init options (preload).
|
||||
*/
|
||||
loadLanguages(lngs: string | string[], callback?: Callback): Promise<void>;
|
||||
|
||||
/**
|
||||
* Reloads resources on given state. Optionally you can pass an array of languages and namespaces as params if you don't want to reload all.
|
||||
*/
|
||||
reloadResources(
|
||||
lngs?: string | string[],
|
||||
ns?: string | string[],
|
||||
callback?: () => void,
|
||||
): Promise<void>;
|
||||
reloadResources(lngs: null, ns: string | string[], callback?: () => void): Promise<void>;
|
||||
|
||||
/**
|
||||
* Changes the default namespace.
|
||||
*/
|
||||
setDefaultNamespace(ns: string): void;
|
||||
|
||||
/**
|
||||
* Returns rtl or ltr depending on languages read direction.
|
||||
*/
|
||||
dir(lng?: string): 'ltr' | 'rtl';
|
||||
|
||||
/**
|
||||
* Exposes interpolation.format function added on init.
|
||||
*/
|
||||
format: FormatFunction;
|
||||
|
||||
/**
|
||||
* Will return a new i18next instance.
|
||||
* Please read the options page for details on configuration options.
|
||||
* Providing a callback will automatically call init.
|
||||
* The callback will be called after all translations were loaded or with an error when failed (in case of using a backend).
|
||||
*/
|
||||
createInstance(options?: InitOptions, callback?: Callback): i18n;
|
||||
|
||||
/**
|
||||
* Creates a clone of the current instance. Shares store, plugins and initial configuration.
|
||||
* Can be used to create an instance sharing storage but being independent on set language or namespaces.
|
||||
*/
|
||||
cloneInstance(options?: InitOptions, callback?: Callback): i18n;
|
||||
|
||||
/**
|
||||
* Gets fired after initialization.
|
||||
*/
|
||||
on(event: 'initialized', callback: (options: InitOptions) => void): void;
|
||||
|
||||
/**
|
||||
* Gets fired on loaded resources.
|
||||
*/
|
||||
on(event: 'loaded', callback: (loaded: boolean) => void): void;
|
||||
|
||||
/**
|
||||
* Gets fired if loading resources failed.
|
||||
*/
|
||||
on(event: 'failedLoading', callback: (lng: string, ns: string, msg: string) => void): void;
|
||||
|
||||
/**
|
||||
* Gets fired on accessing a key not existing.
|
||||
*/
|
||||
on(
|
||||
event: 'missingKey',
|
||||
callback: (lngs: string[], namespace: string, key: string, res: string) => void,
|
||||
): void;
|
||||
|
||||
/**
|
||||
* Gets fired when resources got added or removed.
|
||||
*/
|
||||
on(event: 'added' | 'removed', callback: (lng: string, ns: string) => void): void;
|
||||
|
||||
/**
|
||||
* Gets fired when changeLanguage got called.
|
||||
*/
|
||||
on(event: 'languageChanged', callback: (lng: string) => void): void;
|
||||
|
||||
/**
|
||||
* Event listener
|
||||
*/
|
||||
on(event: string, listener: (...args: any[]) => void): void;
|
||||
|
||||
/**
|
||||
* Remove event listener
|
||||
*/
|
||||
off(event: string, listener: (...args: any[]) => void): void;
|
||||
|
||||
/**
|
||||
* Gets one value by given key.
|
||||
*/
|
||||
getResource(lng: string, ns: string, key: string, options?: { keySeparator?: string }): any;
|
||||
|
||||
/**
|
||||
* Adds one key/value.
|
||||
*/
|
||||
addResource(
|
||||
lng: string,
|
||||
ns: string,
|
||||
key: string,
|
||||
value: string,
|
||||
options?: { keySeparator?: string; silent?: boolean },
|
||||
): void;
|
||||
|
||||
/**
|
||||
* Adds multiple key/values.
|
||||
*/
|
||||
addResources(lng: string, ns: string, resources: any): void;
|
||||
|
||||
/**
|
||||
* Adds a complete bundle.
|
||||
* Setting deep param to true will extend existing translations in that file.
|
||||
* Setting overwrite to true it will overwrite existing translations in that file.
|
||||
*/
|
||||
addResourceBundle(
|
||||
lng: string,
|
||||
ns: string,
|
||||
resources: any,
|
||||
deep?: boolean,
|
||||
overwrite?: boolean,
|
||||
): void;
|
||||
|
||||
/**
|
||||
* Checks if a resource bundle exists.
|
||||
*/
|
||||
hasResourceBundle(lng: string, ns: string): boolean;
|
||||
|
||||
/**
|
||||
* Returns a resource bundle.
|
||||
*/
|
||||
getResourceBundle(lng: string, ns: string): any;
|
||||
|
||||
/**
|
||||
* Removes an existing bundle.
|
||||
*/
|
||||
removeResourceBundle(lng: string, ns: string): void;
|
||||
|
||||
/**
|
||||
* Current options
|
||||
*/
|
||||
options: InitOptions;
|
||||
|
||||
/**
|
||||
* Is initialized
|
||||
*/
|
||||
isInitialized: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
declare const i18next: i18next.i18n;
|
||||
export default i18next;
|
5
node_modules/i18next/index.js
generated
vendored
Normal file
5
node_modules/i18next/index.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/* eslint no-var: 0 */
|
||||
var main = require('./dist/commonjs/index.js').default;
|
||||
|
||||
module.exports = main;
|
||||
module.exports.default = main;
|
50
node_modules/i18next/karma.backward.conf.js
generated
vendored
Normal file
50
node_modules/i18next/karma.backward.conf.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
module.exports = function(karma) {
|
||||
karma.set({
|
||||
frameworks: ['mocha', 'expect', 'sinon', 'browserify'],
|
||||
|
||||
files: [
|
||||
//'vendor/external.js',
|
||||
'test/backward/**/*.compat.js',
|
||||
{ pattern: 'test/backward/locales/**/*.json', watched: true, included: false, served: true },
|
||||
],
|
||||
|
||||
proxies: {
|
||||
'/locales': 'http://localhost:9877/base/test/backward/locales',
|
||||
},
|
||||
|
||||
reporters: ['spec'],
|
||||
|
||||
preprocessors: {
|
||||
'test/backward/**/*.compat.js': ['browserify'],
|
||||
'test/backward/compatibility/**/*.js': ['browserify'],
|
||||
},
|
||||
|
||||
browsers: ['HeadlessChrome'],
|
||||
customLaunchers: {
|
||||
HeadlessChrome: {
|
||||
base: 'ChromeHeadless',
|
||||
flags: ['—no-sandbox'],
|
||||
},
|
||||
},
|
||||
|
||||
port: 9877,
|
||||
|
||||
//logLevel: 'LOG_DEBUG',
|
||||
|
||||
//singleRun: true,
|
||||
//autoWatch: false,
|
||||
//
|
||||
// client: {
|
||||
// mocha: {
|
||||
// reporter: 'spec', // change Karma's debug.html to the mocha web reporter
|
||||
// ui: 'tdd'
|
||||
// }
|
||||
// },
|
||||
|
||||
// browserify configuration
|
||||
browserify: {
|
||||
debug: true,
|
||||
transform: [['babelify', { presets: ['@babel/preset-env'] }] /*, 'brfs' */],
|
||||
},
|
||||
});
|
||||
};
|
157
node_modules/i18next/package.json
generated
vendored
Normal file
157
node_modules/i18next/package.json
generated
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
{
|
||||
"_from": "i18next@^15.0.9",
|
||||
"_id": "i18next@15.0.9",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-IdVj7DqErUuMbGuj2dFT431T7zKlmDci63eae6pNA/bMwgBZKT74/KnwHXE0WH7ivo2EV/LNme4pP4Yw6vB79w==",
|
||||
"_location": "/i18next",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "i18next@^15.0.9",
|
||||
"name": "i18next",
|
||||
"escapedName": "i18next",
|
||||
"rawSpec": "^15.0.9",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^15.0.9"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/i18next/-/i18next-15.0.9.tgz",
|
||||
"_shasum": "42536407a921bb5a8535a4c090a26f16827a1884",
|
||||
"_spec": "i18next@^15.0.9",
|
||||
"_where": "/home/s2/tmp/vanillajs-seed",
|
||||
"author": {
|
||||
"name": "Jan Mühlemann",
|
||||
"email": "jan.muehlemann@gmail.com",
|
||||
"url": "https://github.com/jamuhl"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/i18next/i18next/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.3.1"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "i18next internationalization framework",
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.2.3",
|
||||
"@babel/core": "^7.2.2",
|
||||
"@babel/plugin-proposal-async-generator-functions": "^7.2.0",
|
||||
"@babel/plugin-proposal-object-rest-spread": "^7.3.2",
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.2.0",
|
||||
"@babel/plugin-transform-runtime": "^7.2.0",
|
||||
"@babel/polyfill": "^7.2.5",
|
||||
"@babel/preset-env": "^7.3.1",
|
||||
"@babel/preset-react": "^7.0.0",
|
||||
"@babel/register": "^7.0.0",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"babelify": "^10.0.0",
|
||||
"browserify": "14.0.0",
|
||||
"browserify-istanbul": "2.0.0",
|
||||
"chai": "3.5.0",
|
||||
"coveralls": "2.11.16",
|
||||
"dtslint": "^0.4.2",
|
||||
"eslint": "3.15.0",
|
||||
"eslint-config-airbnb": "14.1.0",
|
||||
"eslint-config-prettier": "^3.6.0",
|
||||
"eslint-plugin-import": "2.2.0",
|
||||
"eslint-plugin-jsx-a11y": "4.0.0",
|
||||
"eslint-plugin-react": "6.9.0",
|
||||
"husky": "^1.3.1",
|
||||
"i18next-browser-languagedetector": "1.0.1",
|
||||
"i18next-localstorage-cache": "0.3.0",
|
||||
"i18next-sprintf-postprocessor": "0.2.2",
|
||||
"i18next-xhr-backend": "1.3.0",
|
||||
"istanbul": "github:gotwarlost/istanbul#source-map",
|
||||
"karma": "2.0.0",
|
||||
"karma-browserify": "5.1.1",
|
||||
"karma-chai": "0.1.0",
|
||||
"karma-chrome-launcher": "2.2.0",
|
||||
"karma-cli": "1.0.1",
|
||||
"karma-coverage": "github:douglasduteil/karma-coverage#next",
|
||||
"karma-coveralls": "1.1.2",
|
||||
"karma-expect": "1.1.3",
|
||||
"karma-mocha": "1.3.0",
|
||||
"karma-rollup-preprocessor": "3.0.3",
|
||||
"karma-sinon": "1.0.5",
|
||||
"karma-spec-reporter": "0.0.26",
|
||||
"lint-staged": "^8.1.0",
|
||||
"mkdirp": "0.5.1",
|
||||
"mocha": "3.2.0",
|
||||
"prettier": "^1.15.3",
|
||||
"rimraf": "2.5.4",
|
||||
"rollup": "1.1.2",
|
||||
"rollup-plugin-babel": "^4.3.2",
|
||||
"rollup-plugin-commonjs": "^9.2.0",
|
||||
"rollup-plugin-node-resolve": "4.0.0",
|
||||
"rollup-plugin-terser": "^4.0.4",
|
||||
"sinon": "1.17.7",
|
||||
"tslint": "^5.12.1",
|
||||
"typescript": "^3.2.4",
|
||||
"watchify": "3.9.0",
|
||||
"yargs": "6.6.0"
|
||||
},
|
||||
"homepage": "http://i18next.com",
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "lint-staged"
|
||||
}
|
||||
},
|
||||
"jsnext:main": "dist/es/index.js",
|
||||
"keywords": [
|
||||
"i18next",
|
||||
"internationalization",
|
||||
"i18n",
|
||||
"translation",
|
||||
"localization",
|
||||
"l10n",
|
||||
"globalization",
|
||||
"gettext"
|
||||
],
|
||||
"license": "MIT",
|
||||
"lint-staged": {
|
||||
"linters": {
|
||||
"*.{ts,tsx,js,json,md}": [
|
||||
"prettier --write",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
"ignore": [
|
||||
"**/dist/**/*.js",
|
||||
"**/i18next.js",
|
||||
"**/i18next.min.js"
|
||||
]
|
||||
},
|
||||
"main": "./index.js",
|
||||
"module": "dist/es/index.js",
|
||||
"name": "i18next",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/i18next/i18next.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npm run clean && npm run build:cjs && npm run build:es && npm run build:umd && npm run copy",
|
||||
"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: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/i18next.min.js ./i18next.min.js && cp ./dist/umd/i18next.js ./i18next.js",
|
||||
"postversion": "git push && git push --tags",
|
||||
"pretest": "npm run test:typescript",
|
||||
"prettier": "prettier --write \"{,**/}*.{ts,tsx,js,json,md}\"",
|
||||
"preversion": "npm run test && npm run build && git push",
|
||||
"tdd": "karma start karma.conf.js",
|
||||
"tdd:compat": "karma start karma.backward.conf.js",
|
||||
"test": "npm run test:new && npm run test:compat",
|
||||
"test:compat": "karma start karma.backward.conf.js --singleRun",
|
||||
"test:new": "karma start karma.conf.js --singleRun",
|
||||
"test:typescript": "tslint --project tsconfig.json"
|
||||
},
|
||||
"types": "index.d.ts",
|
||||
"version": "15.0.9"
|
||||
}
|
42
node_modules/i18next/rollup.config.js
generated
vendored
Normal file
42
node_modules/i18next/rollup.config.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
import babel from 'rollup-plugin-babel';
|
||||
import commonjs from 'rollup-plugin-commonjs';
|
||||
import nodeResolve from 'rollup-plugin-node-resolve';
|
||||
import { terser } from 'rollup-plugin-terser';
|
||||
import { argv } from 'yargs';
|
||||
|
||||
const format = argv.format || argv.f || 'iife';
|
||||
const compress = argv.uglify;
|
||||
|
||||
const babelOptions = {
|
||||
presets: [
|
||||
[
|
||||
'@babel/preset-env',
|
||||
{
|
||||
targets: {
|
||||
esmodules: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
babelrc: false,
|
||||
};
|
||||
|
||||
const file = {
|
||||
amd: `dist/amd/i18next${compress ? '.min' : ''}.js`,
|
||||
umd: `dist/umd/i18next${compress ? '.min' : ''}.js`,
|
||||
iife: `dist/iife/i18next${compress ? '.min' : ''}.js`,
|
||||
}[format];
|
||||
|
||||
export default {
|
||||
input: 'src/i18next.js',
|
||||
plugins: [babel(babelOptions), nodeResolve({ jsnext: true, main: true }), commonjs({})].concat(
|
||||
compress ? terser() : [],
|
||||
),
|
||||
external: ['react', 'react-dom'],
|
||||
// moduleId: 'i18next',
|
||||
output: {
|
||||
name: 'i18next',
|
||||
format,
|
||||
file,
|
||||
},
|
||||
};
|
7
node_modules/i18next/tslint.json
generated
vendored
Normal file
7
node_modules/i18next/tslint.json
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"defaultSeverity": "error",
|
||||
"extends": "dtslint/dtslint.json",
|
||||
"rules": {
|
||||
"semicolon": false
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user