@spscommerce/i18n 5.5.0-ie → 5.7.0

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.
@@ -18,4 +18,4 @@ export interface ILocalizeOptions extends InitOptions {
18
18
  }>;
19
19
  translationPath?: string;
20
20
  }
21
- export declare function localize({ detectorConfig, translationPath, customDetectors, ...i18nConfig }: ILocalizeOptions): any;
21
+ export declare function localize({ detectorConfig, translationPath, customDetectors, ...i18nConfig }: ILocalizeOptions): Promise<import("i18next").TFunction>;
@@ -1 +1 @@
1
- export declare function useSpsLanguage(ns?: string, options?: any): any;
1
+ export declare function useSpsLanguage(ns?: string, options?: any): import("react-i18next").UseTranslationResponse<string[]>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@spscommerce/i18n",
3
3
  "description": "SPS Design System React components",
4
- "version": "5.5.0-ie",
4
+ "version": "5.7.0",
5
5
  "author": "SPS Commerce",
6
6
  "license": "UNLICENSED",
7
7
  "repository": "https://github.com/spscommerce/design-system/tree/main/packages/@spscommerce/i18n",
@@ -30,12 +30,12 @@
30
30
  "typescript": "^4.4.4"
31
31
  },
32
32
  "scripts": {
33
- "build": "pnpm run build:es5 && pnpm run build:js && pnpm run build:types",
34
- "build:es5": "tsc -p tsconfig.json",
33
+ "build": "pnpm run build:js && pnpm run build:types",
35
34
  "build:js": "vite build",
36
35
  "build:types": "tsc --emitDeclarationOnly --declaration --declarationDir lib",
37
36
  "watch": "vite build --watch",
38
37
  "clean": "git clean -fdX",
39
38
  "pub": "pnpm pack && node ../../scripts/publish-package.js"
40
- }
39
+ },
40
+ "readme": "[//]: # \"START_AUTOGENERATED\"\n\n## [@spscommerce/i18n](https://github.com/spscommerce/ui-angular/tree/master/packages/@spscommerce/i18n#readme)\n\n![release: 1.1.0](https://img.shields.io/badge/release-1.1.0-blue.svg?style=flat-square)\n![build: passing](https://img.shields.io/badge/build-passing-green.svg?style=flat-square)\n![tests: failing](https://img.shields.io/badge/tests-failing-red.svg?style=flat-square)\n\nSPS Design System React components \n \n ### Installation \n \n ```shell\nnpm install --save @spscommerce/i18n\n```\n\n#### Peer Dependencies\n\n<div class=\"row\">\n <div class=\"col-5\"> \n <table class=\"sps-table\">\n <thead class=\"sps-table__head\">\n <tr class=\"sps-table__row\">\n <th class=\"sps-table__header\">\n <span class=\"sps-table__header-cell-body\"> \n Package\n </span>\n </th>\n <th class=\"sps-table__header text-right\">\n <span class=\"sps-table__header-cell-body\"> \n Version\n </span>\n </th>\n </tr>\n </thead>\n <tbody class=\"sps-table__body\">\n <tr class=\"sps-table__row\"><td class=\"sps-table__cell\"><a href=\"https://reactjs.org/\">react</a></td><td class=\"sps-table__cell text-right\">^16.9.0</td></tr>\n </tbody>\n </table>\n </div>\n <div class=\"col-7\">\n &nbsp;\n </div>\n</div>\n\n[//]: # \"END_AUTOGENERATED\"\n"
41
41
  }
package/vite.config.js CHANGED
@@ -7,7 +7,7 @@ import pkg from './package.json';
7
7
  export default defineConfig({
8
8
  build: {
9
9
  lib: {
10
- entry: path.resolve(__dirname, 'dist/out-tsc/index.js'),
10
+ entry: path.resolve(__dirname, 'src/index.ts'),
11
11
  formats: ['es', 'cjs'],
12
12
  fileName: (format) => `index.${format}.js`,
13
13
  },
package/.pnpm-debug.log DELETED
@@ -1,20 +0,0 @@
1
- {
2
- "0 debug pnpm:scope": {
3
- "selected": 1,
4
- "workspacePrefix": "/Users/kkorth/experiments/stupid-stuff-i-hate/design-system"
5
- },
6
- "1 error pnpm": {
7
- "errno": 2,
8
- "code": "ELIFECYCLE",
9
- "pkgid": "@spscommerce/i18n@5.5.0",
10
- "stage": "build:es5",
11
- "script": "tsc -p tsconfig.json",
12
- "pkgname": "@spscommerce/i18n",
13
- "err": {
14
- "name": "pnpm",
15
- "message": "@spscommerce/i18n@5.5.0 build:es5: `tsc -p tsconfig.json`\nExit status 2",
16
- "code": "ELIFECYCLE",
17
- "stack": "pnpm: @spscommerce/i18n@5.5.0 build:es5: `tsc -p tsconfig.json`\nExit status 2\n at EventEmitter.<anonymous> (/Users/kkorth/.nvm/versions/node/v14.17.2/lib/node_modules/pnpm/dist/pnpm.cjs:105913:20)\n at EventEmitter.emit (events.js:375:28)\n at ChildProcess.<anonymous> (/Users/kkorth/.nvm/versions/node/v14.17.2/lib/node_modules/pnpm/dist/pnpm.cjs:93853:18)\n at ChildProcess.emit (events.js:375:28)\n at maybeClose (internal/child_process.js:1055:16)\n at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)"
18
- }
19
- }
20
- }
@@ -1,29 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __rest = (this && this.__rest) || function (s, e) {
13
- var t = {};
14
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
- t[p] = s[p];
16
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
- t[p[i]] = s[p[i]];
20
- }
21
- return t;
22
- };
23
- import * as React from "react";
24
- import { Trans } from "react-i18next";
25
- export function SpsLanguage(_a) {
26
- var children = _a.children, rest = __rest(_a, ["children"]);
27
- return React.createElement(Trans, __assign({}, rest), children);
28
- }
29
- //# sourceMappingURL=SpsLanguage.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SpsLanguage.js","sourceRoot":"","sources":["../../src/SpsLanguage.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAqD,MAAM,eAAe,CAAC;AAEzF,MAAM,UAAU,WAAW,CAIzB,EAA0C;IAAxC,IAAA,QAAQ,cAAA,EAAK,IAAI,cAAnB,YAAqB,CAAF;IACnB,OAAO,oBAAC,KAAK,eAAK,IAAI,GAAG,QAAQ,CAAS,CAAC;AAC7C,CAAC"}
@@ -1,4 +0,0 @@
1
- export * from "./localize";
2
- export * from "./SpsLanguage";
3
- export * from "./useSpsLanguage";
4
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC"}
@@ -1,100 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __rest = (this && this.__rest) || function (s, e) {
13
- var t = {};
14
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
- t[p] = s[p];
16
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
- t[p[i]] = s[p[i]];
20
- }
21
- return t;
22
- };
23
- import i18n from "i18next";
24
- import { initReactI18next } from "react-i18next";
25
- import Backend from "i18next-http-backend";
26
- import LanguageDetector from "i18next-browser-languagedetector";
27
- export function localize(_a) {
28
- var detectorConfig = _a.detectorConfig, translationPath = _a.translationPath, customDetectors = _a.customDetectors, i18nConfig = __rest(_a, ["detectorConfig", "translationPath", "customDetectors"]);
29
- var languageDetector = new LanguageDetector();
30
- // The default querystring detector does not support hash routing
31
- var hashRouterQuerystringDetector = {
32
- name: "hashRouterQuerystringDetector",
33
- lookup: function (options) {
34
- try {
35
- var lookupQuerystring = (options && options.lookupQuerystring) || "lang";
36
- var regex = new RegExp("[?&]".concat(lookupQuerystring, "(=([^&#]*)|&|#|$)"));
37
- var results = regex.exec(window.location.href);
38
- if (results && results[2]) {
39
- var lang = decodeURIComponent(results[2].replace(/\+/g, " "));
40
- if (lang) {
41
- return lang;
42
- }
43
- }
44
- }
45
- catch (err) {
46
- console.error(err);
47
- }
48
- return undefined;
49
- },
50
- };
51
- languageDetector.addDetector(hashRouterQuerystringDetector);
52
- if (Array.isArray(customDetectors)) {
53
- customDetectors.forEach(function (customDetector) {
54
- languageDetector.addDetector(customDetector);
55
- });
56
- }
57
- var detectionObject = detectorConfig || {
58
- // order and from where user language should be detected
59
- order: ["querystring",
60
- "hashRouterQuerystringDetector",
61
- "cookie",
62
- "localStorage"],
63
- // keys or params to lookup language from
64
- lookupQuerystring: "lang",
65
- lookupCookie: "lang",
66
- lookupSessionStorage: "lang",
67
- lookupLocalStorage: "lang",
68
- // cache user language on
69
- caches: ["localStorage", "cookie"],
70
- // languages to not persist (cookie, localStorage)
71
- excludeCacheFor: ["cimode"],
72
- // optional set cookie options, reference:[MDN Set-Cookie docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie)
73
- cookieOptions: { path: "/", sameSite: "strict" },
74
- };
75
- var transPath = translationPath || "/locales/{{lng}}/{{ns}}.json";
76
- var mergedConfig = __assign({ fallbackLng: "en-US",
77
- // set to false for production
78
- debug: true,
79
- // used to traverse nesting in tree-like translation structures
80
- keySeparator: ".", backend: {
81
- /*
82
- * this is the path to your translation files
83
- * this can also take an absolute path as well as the current relative path
84
- * relative path currently points to public/locales
85
- */
86
- loadPath: transPath,
87
- }, interpolation: {
88
- // React takes care of interpolation for us
89
- escapeValue: false,
90
- }, detection: detectionObject }, i18nConfig);
91
- return i18n
92
- // used for loading external translation files
93
- .use(Backend)
94
- // used to detect langage via cookie, local storage, or query param
95
- .use(languageDetector)
96
- // implement React-specefic libs to handle i18next chores
97
- .use(initReactI18next)
98
- .init(mergedConfig);
99
- }
100
- //# sourceMappingURL=localize.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"localize.js","sourceRoot":"","sources":["../../src/localize.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,OAAO,MAAM,sBAAsB,CAAC;AAC3C,OAAO,gBAAgB,MAAM,kCAAkC,CAAC;AAuBhE,MAAM,UAAU,QAAQ,CAAC,EAKN;IAJjB,IAAA,cAAc,oBAAA,EACd,eAAe,qBAAA,EACf,eAAe,qBAAA,EACZ,UAAU,cAJU,wDAKxB,CADc;IAEb,IAAM,gBAAgB,GAAG,IAAI,gBAAgB,EAAE,CAAC;IAEhD,iEAAiE;IACjE,IAAM,6BAA6B,GAAG;QACpC,IAAI,EAAE,+BAA+B;QACrC,MAAM,EAAE,UAAC,OAAyB;YAChC,IAAI;gBACF,IAAM,iBAAiB,GAAG,CAAC,OAAO,IAAI,OAAO,CAAC,iBAAiB,CAAC,IAAI,MAAM,CAAC;gBAC3E,IAAM,KAAK,GAAG,IAAI,MAAM,CAAC,cAAO,iBAAiB,sBAAmB,CAAC,CAAC;gBACtE,IAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;gBACjD,IAAI,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE;oBACzB,IAAM,IAAI,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;oBAChE,IAAI,IAAI,EAAE;wBACR,OAAO,IAAI,CAAC;qBACb;iBACF;aACF;YAAC,OAAO,G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,GAAG,CAAC,gBAAgB,CAAC;QACtB,yDAAyD;SACxD,GAAG,CAAC,gBAAgB,CAAC;SACrB,IAAI,CAAC,YAAY,CAAC,CAAC;AACxB,CAAC"}
@@ -1,6 +0,0 @@
1
- import { useTranslation } from "react-i18next";
2
- export function useSpsLanguage(ns, options) {
3
- if (ns === void 0) { ns = "translation"; }
4
- return useTranslation([ns, "design-system"], options);
5
- }
6
- //# sourceMappingURL=useSpsLanguage.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useSpsLanguage.js","sourceRoot":"","sources":["../../src/useSpsLanguage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,MAAM,UAAU,cAAc,CAAC,EAAkB,EAAE,OAAa;IAAjC,mBAAA,EAAA,kBAAkB;IAC/C,OAAO,cAAc,CAAC,CAAC,EAAE,EAAE,eAAe,CAAC,EAAE,OAAO,CAAC,CAAC;AACxD,CAAC"}