sgerp-frontend-lib 0.2.4 → 0.2.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/locales/locale.d.ts
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
export type Language = "en" | "ja" | "ms" | "tl" | "fil";
|
|
2
|
+
type LocalePlugin = Record<Language, Record<string, string>>;
|
|
3
|
+
/**
|
|
4
|
+
* Register a locale plugin to extend translations
|
|
5
|
+
* @param plugin - Object with translations for each language
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* registerLocalePlugin({
|
|
9
|
+
* en: { 'myapp.title': 'My App' },
|
|
10
|
+
* ja: { 'myapp.title': 'マイアプリ' },
|
|
11
|
+
* ms: { 'myapp.title': 'Aplikasi Saya' },
|
|
12
|
+
* tl: { 'myapp.title': 'Aking App' },
|
|
13
|
+
* fil: { 'myapp.title': 'Aking App' },
|
|
14
|
+
* });
|
|
15
|
+
*/
|
|
16
|
+
export declare const registerLocalePlugin: (plugin: LocalePlugin) => void;
|
|
2
17
|
type LocaleChangeListener = (locale: Language) => void;
|
|
3
18
|
export declare const subscribeToLocaleChanges: (listener: LocaleChangeListener) => () => void;
|
|
4
19
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locale.d.ts","sourceRoot":"","sources":["../../sgerplib/locales/locale.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"locale.d.ts","sourceRoot":"","sources":["../../sgerplib/locales/locale.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC;AAYzD,KAAK,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAG7D;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,oBAAoB,GAAI,QAAQ,YAAY,KAAG,IAE3D,CAAC;AAQF,KAAK,oBAAoB,GAAG,CAAC,MAAM,EAAE,QAAQ,KAAK,IAAI,CAAC;AAGvD,eAAO,MAAM,wBAAwB,GAAI,UAAU,oBAAoB,eAKtE,CAAC;AA6BF;;;GAGG;AACH,eAAO,MAAM,SAAS,QAAO,QAe5B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,SAAS,GAAI,QAAQ,QAAQ,KAAG,IAU5C,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,GACnB,KAAK,MAAM,EACX,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EACpC,SAAQ,QAAsB,KAC7B,MA+CF,CAAC"}
|
package/dist/locales/locale.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
"use client";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.localize = exports.setLocale = exports.getLocale = exports.subscribeToLocaleChanges = void 0;
|
|
4
|
+
exports.localize = exports.setLocale = exports.getLocale = exports.subscribeToLocaleChanges = exports.registerLocalePlugin = void 0;
|
|
5
5
|
const locale_en_1 = require("./locale_en");
|
|
6
6
|
const locale_ja_1 = require("./locale_ja");
|
|
7
7
|
const locale_ms_1 = require("./locale_ms");
|
|
@@ -14,6 +14,24 @@ const locales = {
|
|
|
14
14
|
fil: locale_tl_1.translations, // Filipino uses same translations as Tagalog
|
|
15
15
|
// id: translations_id,
|
|
16
16
|
};
|
|
17
|
+
const localePlugins = [];
|
|
18
|
+
/**
|
|
19
|
+
* Register a locale plugin to extend translations
|
|
20
|
+
* @param plugin - Object with translations for each language
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* registerLocalePlugin({
|
|
24
|
+
* en: { 'myapp.title': 'My App' },
|
|
25
|
+
* ja: { 'myapp.title': 'マイアプリ' },
|
|
26
|
+
* ms: { 'myapp.title': 'Aplikasi Saya' },
|
|
27
|
+
* tl: { 'myapp.title': 'Aking App' },
|
|
28
|
+
* fil: { 'myapp.title': 'Aking App' },
|
|
29
|
+
* });
|
|
30
|
+
*/
|
|
31
|
+
const registerLocalePlugin = (plugin) => {
|
|
32
|
+
localePlugins.push(plugin);
|
|
33
|
+
};
|
|
34
|
+
exports.registerLocalePlugin = registerLocalePlugin;
|
|
17
35
|
const DEFAULT_LOCALE = "en";
|
|
18
36
|
const STORAGE_KEY = "sgerp-language";
|
|
19
37
|
let currentLocale = DEFAULT_LOCALE;
|
|
@@ -99,9 +117,21 @@ exports.setLocale = setLocale;
|
|
|
99
117
|
* @returns The localized string
|
|
100
118
|
*/
|
|
101
119
|
const localize = (key, params = {}, locale = (0, exports.getLocale)()) => {
|
|
120
|
+
var _a;
|
|
102
121
|
const translation = locale in locales ? locales[locale] : locales[DEFAULT_LOCALE];
|
|
103
|
-
//
|
|
104
|
-
let value
|
|
122
|
+
// Check plugins first (in reverse order so last registered wins)
|
|
123
|
+
let value;
|
|
124
|
+
for (let i = localePlugins.length - 1; i >= 0; i--) {
|
|
125
|
+
const plugin = localePlugins[i];
|
|
126
|
+
if ((_a = plugin[locale]) === null || _a === void 0 ? void 0 : _a[key]) {
|
|
127
|
+
value = plugin[locale][key];
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
// Try to find the key in the selected locale if not found in plugins
|
|
132
|
+
if (value === undefined) {
|
|
133
|
+
value = translation[key];
|
|
134
|
+
}
|
|
105
135
|
// If not found, try removing '_id' from the key and search again
|
|
106
136
|
if (value === undefined) {
|
|
107
137
|
const keyWithoutId = key.replace(/_id/g, "");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../sgerplib/vrptoolbox/collection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAA0B,MAAM,aAAa,CAAC;AAE3E,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAqBjD;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,UAAU,CAAC,eAAe,CAAC;IACxE,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAC,CAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,CAAS;gBAEd,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../sgerplib/vrptoolbox/collection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAA0B,MAAM,aAAa,CAAC;AAE3E,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAqBjD;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,UAAU,CAAC,eAAe,CAAC;IACxE,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAC,CAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,CAAS;gBAEd,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;IAwCjE;;OAEG;IACH,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;CAIzD"}
|
|
@@ -26,6 +26,8 @@ class OptimizationJobCollection extends collection_1.Collection {
|
|
|
26
26
|
// Create fetch function that adapts VRP Toolbox API to SGERP format
|
|
27
27
|
const fetchFn = async (params) => {
|
|
28
28
|
const searchParams = new URLSearchParams();
|
|
29
|
+
// Exclude error field from list API to improve performance (error can be large)
|
|
30
|
+
searchParams.append('only_fields', 'id,status,label,created_at,creator_username,auth_backend,nodes_count,vehicles_count,project_id,solver_parameters_time_limit_ms,modified_at');
|
|
29
31
|
if (params && typeof params === 'object') {
|
|
30
32
|
Object.entries(params).forEach(([key, value]) => {
|
|
31
33
|
if (value !== undefined && value !== null) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sgerp-frontend-lib",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "TypeScript/React library for interacting with the SGERP API, providing client SDK, Backbone.js-style Collections, and pre-built React components",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|