@tolgee/i18next
Advanced tools
Comparing version 4.9.2 to 4.10.0-rc.14ca700.0
@@ -1,1 +0,1 @@ | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import '@testing-library/jest-dom'; |
@@ -5,1 +5,4 @@ export * from './withTolgee'; | ||
export * from './tolgeeBackend'; | ||
export * from './I18nextPlugin'; | ||
export * from '@tolgee/core'; | ||
export * from '@tolgee/devtools-web'; |
@@ -5,21 +5,22 @@ 'use strict'; | ||
var devtoolsWeb = require('@tolgee/devtools-web'); | ||
var core = require('@tolgee/core'); | ||
function _interopNamespace(e) { | ||
if (e && e.__esModule) return e; | ||
var n = Object.create(null); | ||
if (e) { | ||
Object.keys(e).forEach(function (k) { | ||
if (k !== 'default') { | ||
var d = Object.getOwnPropertyDescriptor(e, k); | ||
Object.defineProperty(n, k, d.get ? d : { | ||
enumerable: true, | ||
get: function () { return e[k]; } | ||
}); | ||
} | ||
var tolgeeApply = function (tolgee, i18n) { | ||
var updateTranslations = function () { | ||
tolgee.getAllRecords().forEach(function (_a) { | ||
var language = _a.language, namespace = _a.namespace, data = _a.data; | ||
var ns = namespace || 'translation'; | ||
i18n.removeResourceBundle(language, ns); | ||
i18n.addResources(language, ns, Object.fromEntries(data)); | ||
}); | ||
} | ||
n["default"] = e; | ||
return Object.freeze(n); | ||
} | ||
}; | ||
tolgee.onKeyUpdate(updateTranslations); | ||
i18n.on('languageChanged', function (lang) { | ||
if (lang && tolgee.getLanguage() !== lang) { | ||
tolgee.changeLanguage(lang); | ||
} | ||
}); | ||
i18n.tolgee = tolgee; | ||
}; | ||
@@ -117,18 +118,2 @@ /****************************************************************************** | ||
var tolgeeApply = function (tolgee, i18n) { | ||
var updateTranslations = function () { | ||
tolgee.getCachedTranslations().forEach(function (translations, lang) { | ||
i18n.removeResourceBundle(lang, 'translation'); | ||
i18n.addResources(lang, 'translation', translations); | ||
}); | ||
}; | ||
tolgee.onTranslationChange.subscribe(updateTranslations); | ||
i18n.on('languageChanged', function (lang) { | ||
if (lang && tolgee.lang !== lang) { | ||
tolgee.changeLanguage(lang); | ||
} | ||
}); | ||
i18n.tolgee = tolgee; | ||
}; | ||
var tolgeeBackend = function (tolgee) { | ||
@@ -141,14 +126,19 @@ return { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var translations; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
var translations, e_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_b.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, tolgee.loadTranslations(language)]; | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, tolgee.loadRecord({ | ||
language: language, | ||
namespace: ns === 'translation' ? '' : undefined, | ||
})]; | ||
case 1: | ||
translations = _b.sent(); | ||
callback(null, translations); | ||
translations = _a.sent(); | ||
callback(null, Object.fromEntries(translations)); | ||
return [3 /*break*/, 3]; | ||
case 2: | ||
_b.sent(); | ||
e_1 = _a.sent(); | ||
// eslint-disable-next-line no-console | ||
console.error(e_1); | ||
callback(true); | ||
@@ -170,3 +160,7 @@ return [3 /*break*/, 3]; | ||
process: function (value, key, options) { | ||
return tolgee.wrap(key.join('.'), undefined, options.defaultValue, value); | ||
return tolgee.wrap({ | ||
key: key.join('.'), | ||
defaultValue: options.defaultValue, | ||
translation: value, | ||
}); | ||
}, | ||
@@ -196,8 +190,3 @@ }; | ||
var withTolgee = function (i18n, config) { | ||
var tolgee = core.Tolgee.init(__assign({ wrapperMode: 'invisible', enableLanguageDetection: false, enableLanguageStore: false, ui: process.env.NODE_ENV !== 'development' | ||
? undefined | ||
: typeof require !== 'undefined' | ||
? require('@tolgee/ui') | ||
: Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@tolgee/ui')); }) }, config)); | ||
var withTolgee = function (i18n, tolgee) { | ||
i18n.use(tolgeeBackend(tolgee)); | ||
@@ -225,3 +214,3 @@ i18n.use(tolgeeProcessor(tolgee)); | ||
if (language) { | ||
tolgee.lang = language; | ||
tolgee.changeLanguage(language); | ||
} | ||
@@ -235,2 +224,12 @@ tolgee.run(); | ||
var I18nextPlugin = function (props) { | ||
return function (tolgee) { | ||
return tolgee | ||
.use(devtoolsWeb.BrowserExtensionPlugin()) | ||
.use(devtoolsWeb.DevTools({ observer: props })) | ||
.init({ ns: [] }); | ||
}; | ||
}; | ||
exports.I18nextPlugin = I18nextPlugin; | ||
exports.tolgeeApply = tolgeeApply; | ||
@@ -240,2 +239,14 @@ exports.tolgeeBackend = tolgeeBackend; | ||
exports.withTolgee = withTolgee; | ||
Object.keys(devtoolsWeb).forEach(function (k) { | ||
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { | ||
enumerable: true, | ||
get: function () { return devtoolsWeb[k]; } | ||
}); | ||
}); | ||
Object.keys(core).forEach(function (k) { | ||
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { | ||
enumerable: true, | ||
get: function () { return core[k]; } | ||
}); | ||
}); | ||
//# sourceMappingURL=tolgee-i18next.cjs.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@tolgee/core");function n(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var t=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,t.get?t:{enumerable:!0,get:function(){return e[r]}})}})),n.default=e,Object.freeze(n)}var r=function(){return r=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var o in n=arguments[r])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e},r.apply(this,arguments)};function t(e,n,r,t){return new(r||(r=Promise))((function(o,a){function i(e){try{l(t.next(e))}catch(e){a(e)}}function u(e){try{l(t.throw(e))}catch(e){a(e)}}function l(e){var n;e.done?o(e.value):(n=e.value,n instanceof r?n:new r((function(e){e(n)}))).then(i,u)}l((t=t.apply(e,n||[])).next())}))}function o(e,n){var r,t,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,t&&(o=2&a[0]?t.return:a[0]?t.throw||((o=t.return)&&o.call(t),0):t.next)&&!(o=o.call(t,a[1])).done)return o;switch(t=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,t=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=n.call(e,i)}catch(e){a=[6,e],t=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function a(e,n,r){if(r||2===arguments.length)for(var t,o=0,a=n.length;o<a;o++)!t&&o in n||(t||(t=Array.prototype.slice.call(n,0,o)),t[o]=n[o]);return e.concat(t||Array.prototype.slice.call(n))}var i=function(e,n){e.onTranslationChange.subscribe((function(){e.getCachedTranslations().forEach((function(e,r){n.removeResourceBundle(r,"translation"),n.addResources(r,"translation",e)}))})),n.on("languageChanged",(function(n){n&&e.lang!==n&&e.changeLanguage(n)})),n.tolgee=e},u=function(e){return{type:"backend",name:"TolgeeBackend",init:function(){},read:function(n,r,a){return t(this,void 0,void 0,(function(){var r;return o(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,e.loadTranslations(n)];case 1:return r=t.sent(),a(null,r),[3,3];case 2:return t.sent(),a(!0),[3,3];case 3:return[2]}}))}))}}},l=function(e,n){var t,o,i;return i="string"==typeof n.postProcess?[n.postProcess,"tolgeeProcessor"]:Array.isArray(n.postProcess)?a(a([],function(e,n){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var t,o,a=r.call(e),i=[];try{for(;(void 0===n||n-- >0)&&!(t=a.next()).done;)i.push(t.value)}catch(e){o={error:e}}finally{try{t&&!t.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i}(n.postProcess),!1),["tolgeeProcessor"],!1):["tolgeeProcessor"],r(r({},n),{postProcess:i,i18nFormat:r(r({},null==n?void 0:n.i18nFormat),{bindI18nStore:"added "+(null===(t=n.i18nFormat)||void 0===t?void 0:t.bindI18nStore)||""}),react:r(r({},null==n?void 0:n.react),{bindI18nStore:"added "+(null===(o=n.react)||void 0===o?void 0:o.bindI18nStore)||""})})};exports.tolgeeApply=i,exports.tolgeeBackend=u,exports.tolgeeOptions=l,exports.withTolgee=function(t,o){var a=e.Tolgee.init(r({wrapperMode:"invisible",enableLanguageDetection:!1,enableLanguageStore:!1,ui:"development"!==process.env.NODE_ENV?void 0:"undefined"!=typeof require?require("@tolgee/ui"):Promise.resolve().then((function(){return n(require("@tolgee/ui"))}))},o));t.use(u(a)),t.use(function(e){return{type:"postProcessor",name:"tolgeeProcessor",process:function(n,r,t){return e.wrap(r.join("."),void 0,t.defaultValue,n)}}}(a));var c=t.init;return t.init=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];i(a,t);var r={},o=void 0;"object"==typeof e[0]?(r=e[0],o=e[1]):o=e[0];var u=l(0,r),s=c(u,o),f=t.language||r.lng;return f&&(a.lang=f),a.run(),s},t}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@tolgee/devtools-web"),n=require("@tolgee/core"),r=function(e,n){e.onKeyUpdate((function(){e.getAllRecords().forEach((function(e){var r=e.language,t=e.namespace,o=e.data,a=t||"translation";n.removeResourceBundle(r,a),n.addResources(r,a,Object.fromEntries(o))}))})),n.on("languageChanged",(function(n){n&&e.getLanguage()!==n&&e.changeLanguage(n)})),n.tolgee=e},t=function(){return t=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var o in n=arguments[r])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e},t.apply(this,arguments)};function o(e,n,r,t){return new(r||(r=Promise))((function(o,a){function u(e){try{c(t.next(e))}catch(e){a(e)}}function i(e){try{c(t.throw(e))}catch(e){a(e)}}function c(e){var n;e.done?o(e.value):(n=e.value,n instanceof r?n:new r((function(e){e(n)}))).then(u,i)}c((t=t.apply(e,n||[])).next())}))}function a(e,n){var r,t,o,a,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,t&&(o=2&a[0]?t.return:a[0]?t.throw||((o=t.return)&&o.call(t),0):t.next)&&!(o=o.call(t,a[1])).done)return o;switch(t=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,t=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=n.call(e,u)}catch(e){a=[6,e],t=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,i])}}}function u(e,n,r){if(r||2===arguments.length)for(var t,o=0,a=n.length;o<a;o++)!t&&o in n||(t||(t=Array.prototype.slice.call(n,0,o)),t[o]=n[o]);return e.concat(t||Array.prototype.slice.call(n))}var i=function(e){return{type:"backend",name:"TolgeeBackend",init:function(){},read:function(n,r,t){return o(this,void 0,void 0,(function(){var o,u;return a(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,e.loadRecord({language:n,namespace:"translation"===r?"":void 0})];case 1:return o=a.sent(),t(null,Object.fromEntries(o)),[3,3];case 2:return u=a.sent(),console.error(u),t(!0),[3,3];case 3:return[2]}}))}))}}},c=function(e,n){var r,o,a;return a="string"==typeof n.postProcess?[n.postProcess,"tolgeeProcessor"]:Array.isArray(n.postProcess)?u(u([],function(e,n){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var t,o,a=r.call(e),u=[];try{for(;(void 0===n||n-- >0)&&!(t=a.next()).done;)u.push(t.value)}catch(e){o={error:e}}finally{try{t&&!t.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return u}(n.postProcess),!1),["tolgeeProcessor"],!1):["tolgeeProcessor"],t(t({},n),{postProcess:a,i18nFormat:t(t({},null==n?void 0:n.i18nFormat),{bindI18nStore:"added "+(null===(r=n.i18nFormat)||void 0===r?void 0:r.bindI18nStore)||""}),react:t(t({},null==n?void 0:n.react),{bindI18nStore:"added "+(null===(o=n.react)||void 0===o?void 0:o.bindI18nStore)||""})})};exports.I18nextPlugin=function(n){return function(r){return r.use(e.BrowserExtensionPlugin()).use(e.DevTools({observer:n})).init({ns:[]})}},exports.tolgeeApply=r,exports.tolgeeBackend=i,exports.tolgeeOptions=c,exports.withTolgee=function(e,n){e.use(i(n)),e.use(function(e){return{type:"postProcessor",name:"tolgeeProcessor",process:function(n,r,t){return e.wrap({key:r.join("."),defaultValue:t.defaultValue,translation:n})}}}(n));var t=e.init;return e.init=function(){for(var o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];r(n,e);var u={},i=void 0;"object"==typeof o[0]?(u=o[0],i=o[1]):i=o[0];var l=c(0,u),s=t(l,i),f=e.language||u.lng;return f&&n.changeLanguage(f),n.run(),s},e},Object.keys(e).forEach((function(n){"default"===n||exports.hasOwnProperty(n)||Object.defineProperty(exports,n,{enumerable:!0,get:function(){return e[n]}})})),Object.keys(n).forEach((function(e){"default"===e||exports.hasOwnProperty(e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return n[e]}})})); | ||
//# sourceMappingURL=tolgee-i18next.cjs.min.js.map |
@@ -1,3 +0,23 @@ | ||
import { Tolgee } from '@tolgee/core'; | ||
import { BrowserExtensionPlugin, DevTools } from '@tolgee/devtools-web'; | ||
export * from '@tolgee/devtools-web'; | ||
export * from '@tolgee/core'; | ||
var tolgeeApply = function (tolgee, i18n) { | ||
var updateTranslations = function () { | ||
tolgee.getAllRecords().forEach(function (_a) { | ||
var language = _a.language, namespace = _a.namespace, data = _a.data; | ||
var ns = namespace || 'translation'; | ||
i18n.removeResourceBundle(language, ns); | ||
i18n.addResources(language, ns, Object.fromEntries(data)); | ||
}); | ||
}; | ||
tolgee.onKeyUpdate(updateTranslations); | ||
i18n.on('languageChanged', function (lang) { | ||
if (lang && tolgee.getLanguage() !== lang) { | ||
tolgee.changeLanguage(lang); | ||
} | ||
}); | ||
i18n.tolgee = tolgee; | ||
}; | ||
/****************************************************************************** | ||
@@ -94,18 +114,2 @@ Copyright (c) Microsoft Corporation. | ||
var tolgeeApply = function (tolgee, i18n) { | ||
var updateTranslations = function () { | ||
tolgee.getCachedTranslations().forEach(function (translations, lang) { | ||
i18n.removeResourceBundle(lang, 'translation'); | ||
i18n.addResources(lang, 'translation', translations); | ||
}); | ||
}; | ||
tolgee.onTranslationChange.subscribe(updateTranslations); | ||
i18n.on('languageChanged', function (lang) { | ||
if (lang && tolgee.lang !== lang) { | ||
tolgee.changeLanguage(lang); | ||
} | ||
}); | ||
i18n.tolgee = tolgee; | ||
}; | ||
var tolgeeBackend = function (tolgee) { | ||
@@ -118,14 +122,19 @@ return { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var translations; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
var translations, e_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_b.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, tolgee.loadTranslations(language)]; | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, tolgee.loadRecord({ | ||
language: language, | ||
namespace: ns === 'translation' ? '' : undefined, | ||
})]; | ||
case 1: | ||
translations = _b.sent(); | ||
callback(null, translations); | ||
translations = _a.sent(); | ||
callback(null, Object.fromEntries(translations)); | ||
return [3 /*break*/, 3]; | ||
case 2: | ||
_b.sent(); | ||
e_1 = _a.sent(); | ||
// eslint-disable-next-line no-console | ||
console.error(e_1); | ||
callback(true); | ||
@@ -147,3 +156,7 @@ return [3 /*break*/, 3]; | ||
process: function (value, key, options) { | ||
return tolgee.wrap(key.join('.'), undefined, options.defaultValue, value); | ||
return tolgee.wrap({ | ||
key: key.join('.'), | ||
defaultValue: options.defaultValue, | ||
translation: value, | ||
}); | ||
}, | ||
@@ -173,8 +186,3 @@ }; | ||
var withTolgee = function (i18n, config) { | ||
var tolgee = Tolgee.init(__assign({ wrapperMode: 'invisible', enableLanguageDetection: false, enableLanguageStore: false, ui: process.env.NODE_ENV !== 'development' | ||
? undefined | ||
: typeof require !== 'undefined' | ||
? require('@tolgee/ui') | ||
: import('@tolgee/ui') }, config)); | ||
var withTolgee = function (i18n, tolgee) { | ||
i18n.use(tolgeeBackend(tolgee)); | ||
@@ -202,3 +210,3 @@ i18n.use(tolgeeProcessor(tolgee)); | ||
if (language) { | ||
tolgee.lang = language; | ||
tolgee.changeLanguage(language); | ||
} | ||
@@ -212,3 +220,12 @@ tolgee.run(); | ||
export { tolgeeApply, tolgeeBackend, tolgeeOptions, withTolgee }; | ||
var I18nextPlugin = function (props) { | ||
return function (tolgee) { | ||
return tolgee | ||
.use(BrowserExtensionPlugin()) | ||
.use(DevTools({ observer: props })) | ||
.init({ ns: [] }); | ||
}; | ||
}; | ||
export { I18nextPlugin, tolgeeApply, tolgeeBackend, tolgeeOptions, withTolgee }; | ||
//# sourceMappingURL=tolgee-i18next.esm.js.map |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tolgee/core')) : | ||
typeof define === 'function' && define.amd ? define(['exports', '@tolgee/core'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@tolgee/i18next"] = {}, global["@tolgee/core"])); | ||
})(this, (function (exports, core) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tolgee/devtools-web'), require('@tolgee/core')) : | ||
typeof define === 'function' && define.amd ? define(['exports', '@tolgee/devtools-web', '@tolgee/core'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@tolgee/i18next"] = {}, global["@tolgee/devtools-web"], global["@tolgee/core"])); | ||
})(this, (function (exports, devtoolsWeb, core) { 'use strict'; | ||
var tolgeeApply = function (tolgee, i18n) { | ||
var updateTranslations = function () { | ||
tolgee.getAllRecords().forEach(function (_a) { | ||
var language = _a.language, namespace = _a.namespace, data = _a.data; | ||
var ns = namespace || 'translation'; | ||
i18n.removeResourceBundle(language, ns); | ||
i18n.addResources(language, ns, Object.fromEntries(data)); | ||
}); | ||
}; | ||
tolgee.onKeyUpdate(updateTranslations); | ||
i18n.on('languageChanged', function (lang) { | ||
if (lang && tolgee.getLanguage() !== lang) { | ||
tolgee.changeLanguage(lang); | ||
} | ||
}); | ||
i18n.tolgee = tolgee; | ||
}; | ||
/****************************************************************************** | ||
@@ -98,18 +116,2 @@ Copyright (c) Microsoft Corporation. | ||
var tolgeeApply = function (tolgee, i18n) { | ||
var updateTranslations = function () { | ||
tolgee.getCachedTranslations().forEach(function (translations, lang) { | ||
i18n.removeResourceBundle(lang, 'translation'); | ||
i18n.addResources(lang, 'translation', translations); | ||
}); | ||
}; | ||
tolgee.onTranslationChange.subscribe(updateTranslations); | ||
i18n.on('languageChanged', function (lang) { | ||
if (lang && tolgee.lang !== lang) { | ||
tolgee.changeLanguage(lang); | ||
} | ||
}); | ||
i18n.tolgee = tolgee; | ||
}; | ||
var tolgeeBackend = function (tolgee) { | ||
@@ -122,14 +124,19 @@ return { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var translations; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
var translations, e_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_b.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, tolgee.loadTranslations(language)]; | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, tolgee.loadRecord({ | ||
language: language, | ||
namespace: ns === 'translation' ? '' : undefined, | ||
})]; | ||
case 1: | ||
translations = _b.sent(); | ||
callback(null, translations); | ||
translations = _a.sent(); | ||
callback(null, Object.fromEntries(translations)); | ||
return [3 /*break*/, 3]; | ||
case 2: | ||
_b.sent(); | ||
e_1 = _a.sent(); | ||
// eslint-disable-next-line no-console | ||
console.error(e_1); | ||
callback(true); | ||
@@ -151,3 +158,7 @@ return [3 /*break*/, 3]; | ||
process: function (value, key, options) { | ||
return tolgee.wrap(key.join('.'), undefined, options.defaultValue, value); | ||
return tolgee.wrap({ | ||
key: key.join('.'), | ||
defaultValue: options.defaultValue, | ||
translation: value, | ||
}); | ||
}, | ||
@@ -177,8 +188,3 @@ }; | ||
var withTolgee = function (i18n, config) { | ||
var tolgee = core.Tolgee.init(__assign({ wrapperMode: 'invisible', enableLanguageDetection: false, enableLanguageStore: false, ui: process.env.NODE_ENV !== 'development' | ||
? undefined | ||
: typeof require !== 'undefined' | ||
? require('@tolgee/ui') | ||
: import('@tolgee/ui') }, config)); | ||
var withTolgee = function (i18n, tolgee) { | ||
i18n.use(tolgeeBackend(tolgee)); | ||
@@ -206,3 +212,3 @@ i18n.use(tolgeeProcessor(tolgee)); | ||
if (language) { | ||
tolgee.lang = language; | ||
tolgee.changeLanguage(language); | ||
} | ||
@@ -216,2 +222,12 @@ tolgee.run(); | ||
var I18nextPlugin = function (props) { | ||
return function (tolgee) { | ||
return tolgee | ||
.use(devtoolsWeb.BrowserExtensionPlugin()) | ||
.use(devtoolsWeb.DevTools({ observer: props })) | ||
.init({ ns: [] }); | ||
}; | ||
}; | ||
exports.I18nextPlugin = I18nextPlugin; | ||
exports.tolgeeApply = tolgeeApply; | ||
@@ -221,2 +237,14 @@ exports.tolgeeBackend = tolgeeBackend; | ||
exports.withTolgee = withTolgee; | ||
Object.keys(devtoolsWeb).forEach(function (k) { | ||
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { | ||
enumerable: true, | ||
get: function () { return devtoolsWeb[k]; } | ||
}); | ||
}); | ||
Object.keys(core).forEach(function (k) { | ||
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { | ||
enumerable: true, | ||
get: function () { return core[k]; } | ||
}); | ||
}); | ||
@@ -223,0 +251,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@tolgee/core")):"function"==typeof define&&define.amd?define(["exports","@tolgee/core"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self)["@tolgee/i18next"]={},e["@tolgee/core"])}(this,(function(e,n){"use strict";var t=function(){return t=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e},t.apply(this,arguments)};function r(e,n,t,r){return new(t||(t=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function l(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,l)}u((r=r.apply(e,n||[])).next())}))}function o(e,n){var t,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(t)throw new TypeError("Generator is already executing.");for(;a;)try{if(t=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=n.call(e,a)}catch(e){i=[6,e],r=0}finally{t=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}function i(e,n,t){if(t||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return e.concat(r||Array.prototype.slice.call(n))}var a=function(e,n){e.onTranslationChange.subscribe((function(){e.getCachedTranslations().forEach((function(e,t){n.removeResourceBundle(t,"translation"),n.addResources(t,"translation",e)}))})),n.on("languageChanged",(function(n){n&&e.lang!==n&&e.changeLanguage(n)})),n.tolgee=e},l=function(e){return{type:"backend",name:"TolgeeBackend",init:function(){},read:function(n,t,i){return r(this,void 0,void 0,(function(){var t;return o(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,e.loadTranslations(n)];case 1:return t=r.sent(),i(null,t),[3,3];case 2:return r.sent(),i(!0),[3,3];case 3:return[2]}}))}))}}},u="tolgeeProcessor",c=function(e,n){var r,o,a;return a="string"==typeof n.postProcess?[n.postProcess,u]:Array.isArray(n.postProcess)?i(i([],function(e,n){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var r,o,i=t.call(e),a=[];try{for(;(void 0===n||n-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return a}(n.postProcess),!1),[u],!1):[u],t(t({},n),{postProcess:a,i18nFormat:t(t({},null==n?void 0:n.i18nFormat),{bindI18nStore:"added "+(null===(r=n.i18nFormat)||void 0===r?void 0:r.bindI18nStore)||""}),react:t(t({},null==n?void 0:n.react),{bindI18nStore:"added "+(null===(o=n.react)||void 0===o?void 0:o.bindI18nStore)||""})})};e.tolgeeApply=a,e.tolgeeBackend=l,e.tolgeeOptions=c,e.withTolgee=function(e,r){var o=n.Tolgee.init(t({wrapperMode:"invisible",enableLanguageDetection:!1,enableLanguageStore:!1,ui:"development"!==process.env.NODE_ENV?void 0:"undefined"!=typeof require?require("@tolgee/ui"):import("@tolgee/ui")},r));e.use(l(o)),e.use(function(e){return{type:"postProcessor",name:"tolgeeProcessor",process:function(n,t,r){return e.wrap(t.join("."),void 0,r.defaultValue,n)}}}(o));var i=e.init;return e.init=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];a(o,e);var r={},l=void 0;"object"==typeof n[0]?(r=n[0],l=n[1]):l=n[0];var u=c(0,r),s=i(u,l),f=e.language||r.lng;return f&&(o.lang=f),o.run(),s},e},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@tolgee/devtools-web"),require("@tolgee/core")):"function"==typeof define&&define.amd?define(["exports","@tolgee/devtools-web","@tolgee/core"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self)["@tolgee/i18next"]={},e["@tolgee/devtools-web"],e["@tolgee/core"])}(this,(function(e,n,t){"use strict";var r=function(e,n){e.onKeyUpdate((function(){e.getAllRecords().forEach((function(e){var t=e.language,r=e.namespace,o=e.data,a=r||"translation";n.removeResourceBundle(t,a),n.addResources(t,a,Object.fromEntries(o))}))})),n.on("languageChanged",(function(n){n&&e.getLanguage()!==n&&e.changeLanguage(n)})),n.tolgee=e},o=function(){return o=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e},o.apply(this,arguments)};function a(e,n,t,r){return new(t||(t=Promise))((function(o,a){function i(e){try{l(r.next(e))}catch(e){a(e)}}function u(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(i,u)}l((r=r.apply(e,n||[])).next())}))}function i(e,n){var t,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(t)throw new TypeError("Generator is already executing.");for(;i;)try{if(t=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=n.call(e,i)}catch(e){a=[6,e],r=0}finally{t=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function u(e,n,t){if(t||2===arguments.length)for(var r,o=0,a=n.length;o<a;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return e.concat(r||Array.prototype.slice.call(n))}var l=function(e){return{type:"backend",name:"TolgeeBackend",init:function(){},read:function(n,t,r){return a(this,void 0,void 0,(function(){var o,a;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,e.loadRecord({language:n,namespace:"translation"===t?"":void 0})];case 1:return o=i.sent(),r(null,Object.fromEntries(o)),[3,3];case 2:return a=i.sent(),console.error(a),r(!0),[3,3];case 3:return[2]}}))}))}}},c="tolgeeProcessor",s=function(e,n){var t,r,a;return a="string"==typeof n.postProcess?[n.postProcess,c]:Array.isArray(n.postProcess)?u(u([],function(e,n){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var r,o,a=t.call(e),i=[];try{for(;(void 0===n||n-- >0)&&!(r=a.next()).done;)i.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(t=a.return)&&t.call(a)}finally{if(o)throw o.error}}return i}(n.postProcess),!1),[c],!1):[c],o(o({},n),{postProcess:a,i18nFormat:o(o({},null==n?void 0:n.i18nFormat),{bindI18nStore:"added "+(null===(t=n.i18nFormat)||void 0===t?void 0:t.bindI18nStore)||""}),react:o(o({},null==n?void 0:n.react),{bindI18nStore:"added "+(null===(r=n.react)||void 0===r?void 0:r.bindI18nStore)||""})})};e.I18nextPlugin=function(e){return function(t){return t.use(n.BrowserExtensionPlugin()).use(n.DevTools({observer:e})).init({ns:[]})}},e.tolgeeApply=r,e.tolgeeBackend=l,e.tolgeeOptions=s,e.withTolgee=function(e,n){e.use(l(n)),e.use(function(e){return{type:"postProcessor",name:"tolgeeProcessor",process:function(n,t,r){return e.wrap({key:t.join("."),defaultValue:r.defaultValue,translation:n})}}}(n));var t=e.init;return e.init=function(){for(var o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];r(n,e);var i={},u=void 0;"object"==typeof o[0]?(i=o[0],u=o[1]):u=o[0];var l=s(0,i),c=t(l,u),f=e.language||i.lng;return f&&n.changeLanguage(f),n.run(),c},e},Object.keys(n).forEach((function(t){"default"===t||e.hasOwnProperty(t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})})),Object.keys(t).forEach((function(n){"default"===n||e.hasOwnProperty(n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})),Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=tolgee-i18next.umd.min.js.map |
@@ -1,8 +0,8 @@ | ||
import { Tolgee } from '@tolgee/core'; | ||
import { TolgeeInstance } from '@tolgee/core'; | ||
import { i18n } from 'i18next'; | ||
export declare const tolgeeApply: (tolgee: Tolgee, i18n: i18n) => void; | ||
export declare const tolgeeApply: (tolgee: TolgeeInstance, i18n: i18n) => void; | ||
declare module 'i18next' { | ||
interface i18n { | ||
tolgee: Tolgee; | ||
tolgee: TolgeeInstance; | ||
} | ||
} |
@@ -1,3 +0,3 @@ | ||
import { Tolgee } from '@tolgee/core'; | ||
import { TolgeeInstance } from '@tolgee/core'; | ||
import { Module } from 'i18next'; | ||
export declare const tolgeeBackend: (tolgee: Tolgee) => Module; | ||
export declare const tolgeeBackend: (tolgee: TolgeeInstance) => Module; |
@@ -1,4 +0,4 @@ | ||
import { Tolgee } from '@tolgee/core'; | ||
import { TolgeeInstance } from '@tolgee/core'; | ||
import { InitOptions } from 'i18next'; | ||
export declare const tolgeeOptions: (tolgee: Tolgee, options?: InitOptions) => { | ||
export declare const tolgeeOptions: (tolgee: TolgeeInstance, options?: InitOptions) => { | ||
postProcess: string[]; | ||
@@ -5,0 +5,0 @@ i18nFormat: { |
@@ -1,4 +0,4 @@ | ||
import { Tolgee } from '@tolgee/core'; | ||
import { TolgeeInstance } from '@tolgee/core'; | ||
import { Module } from 'i18next'; | ||
export declare const TOLGEE_PROCESSOR_NAME = "tolgeeProcessor"; | ||
export declare const tolgeeProcessor: (tolgee: Tolgee) => Module; | ||
export declare const tolgeeProcessor: (tolgee: TolgeeInstance) => Module; |
@@ -1,3 +0,3 @@ | ||
import { TolgeeConfig } from '@tolgee/core'; | ||
import { TolgeeInstance } from '@tolgee/core'; | ||
import { i18n } from 'i18next'; | ||
export declare const withTolgee: (i18n: i18n, config: TolgeeConfig) => i18n; | ||
export declare const withTolgee: (i18n: i18n, tolgee: TolgeeInstance) => i18n; |
@@ -5,1 +5,4 @@ export * from './withTolgee'; | ||
export * from './tolgeeBackend'; | ||
export * from './I18nextPlugin'; | ||
export * from '@tolgee/core'; | ||
export * from '@tolgee/devtools-web'; |
@@ -1,8 +0,8 @@ | ||
import { Tolgee } from '@tolgee/core'; | ||
import { TolgeeInstance } from '@tolgee/core'; | ||
import { i18n } from 'i18next'; | ||
export declare const tolgeeApply: (tolgee: Tolgee, i18n: i18n) => void; | ||
export declare const tolgeeApply: (tolgee: TolgeeInstance, i18n: i18n) => void; | ||
declare module 'i18next' { | ||
interface i18n { | ||
tolgee: Tolgee; | ||
tolgee: TolgeeInstance; | ||
} | ||
} |
@@ -1,3 +0,3 @@ | ||
import { Tolgee } from '@tolgee/core'; | ||
import { TolgeeInstance } from '@tolgee/core'; | ||
import { Module } from 'i18next'; | ||
export declare const tolgeeBackend: (tolgee: Tolgee) => Module; | ||
export declare const tolgeeBackend: (tolgee: TolgeeInstance) => Module; |
@@ -1,4 +0,4 @@ | ||
import { Tolgee } from '@tolgee/core'; | ||
import { TolgeeInstance } from '@tolgee/core'; | ||
import { InitOptions } from 'i18next'; | ||
export declare const tolgeeOptions: (tolgee: Tolgee, options?: InitOptions) => { | ||
export declare const tolgeeOptions: (tolgee: TolgeeInstance, options?: InitOptions) => { | ||
postProcess: string[]; | ||
@@ -5,0 +5,0 @@ i18nFormat: { |
@@ -1,4 +0,4 @@ | ||
import { Tolgee } from '@tolgee/core'; | ||
import { TolgeeInstance } from '@tolgee/core'; | ||
import { Module } from 'i18next'; | ||
export declare const TOLGEE_PROCESSOR_NAME = "tolgeeProcessor"; | ||
export declare const tolgeeProcessor: (tolgee: Tolgee) => Module; | ||
export declare const tolgeeProcessor: (tolgee: TolgeeInstance) => Module; |
@@ -1,3 +0,3 @@ | ||
import { TolgeeConfig } from '@tolgee/core'; | ||
import { TolgeeInstance } from '@tolgee/core'; | ||
import { i18n } from 'i18next'; | ||
export declare const withTolgee: (i18n: i18n, config: TolgeeConfig) => i18n; | ||
export declare const withTolgee: (i18n: i18n, tolgee: TolgeeInstance) => i18n; |
{ | ||
"name": "@tolgee/i18next", | ||
"version": "4.9.2", | ||
"version": "4.10.0-rc.14ca700.0", | ||
"description": "Tolgee i18n integration.", | ||
@@ -61,6 +61,3 @@ "main": "index.js", | ||
}, | ||
"gitHead": "dcbded7f7d158facb5eac126baf2ec1e1dc5699e", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"gitHead": "b1d3f9ef8bd9aa70bf0e3acbdaff6043021a2fee", | ||
"peerDependencies": { | ||
@@ -74,5 +71,8 @@ "i18next": "^21.5.4" | ||
"dependencies": { | ||
"@tolgee/core": "^4.9.2", | ||
"@tolgee/ui": "^4.9.2" | ||
"@tolgee/core": "^4.10.0-rc.14ca700.0", | ||
"@tolgee/devtools-web": "^4.10.0-rc.14ca700.0" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
165043
31
965
1
3
+ Added@tolgee/core@4.10.0-rc.f068ae1.0(transitive)
- Removed@tolgee/ui@^4.9.2
- Removed@tolgee/core@4.9.2(transitive)
- Removed@tolgee/ui@4.9.2(transitive)