@pinuts/bsr-uikit-relaunch 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/i18n.js ADDED
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "Trans", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _reactI18next.Trans;
10
+ }
11
+ });
12
+ exports.default = exports.addResourceBundleToLibI18n = void 0;
13
+ Object.defineProperty(exports, "i18n", {
14
+ enumerable: true,
15
+ get: function () {
16
+ return _i18next.default;
17
+ }
18
+ });
19
+ exports.setLanguage = void 0;
20
+ Object.defineProperty(exports, "useTranslation", {
21
+ enumerable: true,
22
+ get: function () {
23
+ return _reactI18next.useTranslation;
24
+ }
25
+ });
26
+ Object.defineProperty(exports, "withTranslation", {
27
+ enumerable: true,
28
+ get: function () {
29
+ return _reactI18next.withTranslation;
30
+ }
31
+ });
32
+ var _i18next = _interopRequireDefault(require("i18next"));
33
+ var _reactI18next = require("react-i18next");
34
+ var _locales = require("./locales.js");
35
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
36
+ // import Backend from 'i18next-xhr-backend';
37
+ // not like to use this?
38
+ // have a look at the Quick start guide
39
+ // for passing in lng and translations on init
40
+
41
+ _i18next.default
42
+ // load translation using xhr -> see /public/locales (i.e. https://github.com/i18next/react-i18next/tree/master/example/react/public/locales)
43
+ // learn more: https://github.com/i18next/i18next-xhr-backend
44
+ // .use(Backend)
45
+ // detect user language
46
+ // learn more: https://github.com/i18next/i18next-browser-languageDetector
47
+ // pass the i18n instance to react-i18next.
48
+ .use(_reactI18next.initReactI18next)
49
+ // init i18next
50
+ // for all options read: https://www.i18next.com/overview/configuration-options
51
+ .init({
52
+ resources: _locales.resources,
53
+ fallbackLng: 'de',
54
+ // debug: true,
55
+ ns: ['base'],
56
+ defaultNS: 'base',
57
+ fallbackNS: 'base',
58
+ lng: 'de',
59
+ interpolation: {
60
+ escapeValue: false // not needed for react as it escapes by default
61
+ }
62
+ });
63
+ const addResourceBundleToLibI18n = resources => {
64
+ if (resources?.de?.base) {
65
+ _i18next.default.addResourceBundle('de', 'base', resources.de.base, true, true);
66
+ }
67
+ if (resources?.en?.base) {
68
+ _i18next.default.addResourceBundle('en', 'base', resources.en.base, true, true);
69
+ }
70
+ };
71
+ exports.addResourceBundleToLibI18n = addResourceBundleToLibI18n;
72
+ const setLanguage = language => {
73
+ _i18next.default.changeLanguage(language).then(() => {});
74
+ };
75
+ exports.setLanguage = setLanguage;
76
+ var _default = exports.default = _i18next.default;