gt-react 10.18.0 → 10.18.1
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/CHANGELOG.md +9 -0
- package/dist/browser.cjs.min.cjs +5 -5
- package/dist/browser.cjs.min.cjs.map +1 -1
- package/dist/browser.esm.min.mjs +5 -5
- package/dist/browser.esm.min.mjs.map +1 -1
- package/dist/i18n-context/browser-i18n-manager/BrowserI18nManager.d.ts +18 -1
- package/dist/i18n-context/browser-i18n-manager/BrowserI18nManager.d.ts.map +1 -1
- package/dist/i18n-context/browser-i18n-manager/utils/constants.d.ts +3 -0
- package/dist/i18n-context/browser-i18n-manager/utils/constants.d.ts.map +1 -0
- package/dist/i18n-context/browser-i18n-manager/utils/types.d.ts +9 -0
- package/dist/i18n-context/browser-i18n-manager/utils/types.d.ts.map +1 -1
- package/dist/i18n-context/functions/html-tag-operations.d.ts +19 -0
- package/dist/i18n-context/functions/html-tag-operations.d.ts.map +1 -0
- package/dist/i18n-context/functions/index.d.ts +1 -0
- package/dist/i18n-context/functions/index.d.ts.map +1 -1
- package/dist/i18n-context/setup/bootstrap.d.ts +3 -3
- package/dist/i18n-context/setup/bootstrap.d.ts.map +1 -1
- package/dist/i18n-context/setup/types.d.ts +5 -2
- package/dist/i18n-context/setup/types.d.ts.map +1 -1
- package/dist/internal.cjs.min.cjs.map +1 -1
- package/dist/internal.esm.min.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
import { I18nManager } from 'gt-i18n/internal';
|
|
2
2
|
import type { I18nManagerConstructorParams } from 'gt-i18n/internal/types';
|
|
3
3
|
import type { BrowserStorageAdapter } from './BrowserStorageAdapter';
|
|
4
|
+
import type { HtmlTagOptions } from './utils/types';
|
|
4
5
|
import { Translation } from 'gt-i18n/types';
|
|
6
|
+
/**
|
|
7
|
+
* The configuration for the BrowserI18nManager
|
|
8
|
+
*/
|
|
9
|
+
type BrowserI18nManagerConstructorParams = I18nManagerConstructorParams<BrowserStorageAdapter> & {
|
|
10
|
+
htmlTagOptions?: HtmlTagOptions;
|
|
11
|
+
};
|
|
5
12
|
/**
|
|
6
13
|
* I18nManager implementation for Browser.
|
|
7
14
|
*/
|
|
8
15
|
export declare class BrowserI18nManager extends I18nManager<BrowserStorageAdapter, Translation> {
|
|
9
|
-
|
|
16
|
+
/** Customize browser-related behavior */
|
|
17
|
+
private htmlTagOptions?;
|
|
18
|
+
constructor(config: BrowserI18nManagerConstructorParams);
|
|
10
19
|
/**
|
|
11
20
|
* Load translations for a given locale
|
|
12
21
|
* @param {string} locale - The locale to load translations for
|
|
@@ -26,5 +35,13 @@ export declare class BrowserI18nManager extends I18nManager<BrowserStorageAdapte
|
|
|
26
35
|
* @note This function causes a page reload
|
|
27
36
|
*/
|
|
28
37
|
setLocale(locale: string): void;
|
|
38
|
+
/**
|
|
39
|
+
* Update the html tag (lang, dir)
|
|
40
|
+
*/
|
|
41
|
+
updateHtmlTag(htmlTagOptions?: {
|
|
42
|
+
lang?: string;
|
|
43
|
+
dir?: 'ltr' | 'rtl';
|
|
44
|
+
} & HtmlTagOptions): void;
|
|
29
45
|
}
|
|
46
|
+
export {};
|
|
30
47
|
//# sourceMappingURL=BrowserI18nManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BrowserI18nManager.d.ts","sourceRoot":"","sources":["../../../src/i18n-context/browser-i18n-manager/BrowserI18nManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"BrowserI18nManager.d.ts","sourceRoot":"","sources":["../../../src/i18n-context/browser-i18n-manager/BrowserI18nManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C;;GAEG;AACH,KAAK,mCAAmC,GACtC,4BAA4B,CAAC,qBAAqB,CAAC,GAAG;IACpD,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC,CAAC;AAEJ;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,WAAW,CACjD,qBAAqB,EACrB,WAAW,CACZ;IACC,yCAAyC;IACzC,OAAO,CAAC,cAAc,CAAC,CAAiB;gBAE5B,MAAM,EAAE,mCAAmC;IAcvD;;;;OAIG;IACG,gBAAgB,CAAC,MAAM,GAAE,MAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxE;;;OAGG;IACH,SAAS,IAAI,MAAM;IAInB;;;;;;OAMG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAS/B;;OAEG;IACH,aAAa,CACX,cAAc,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAA;KAAE,GAAG,cAAc,GACvE,IAAI;CA4BR"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/i18n-context/browser-i18n-manager/utils/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,eAAO,MAAM,wBAAwB,EAAE,cAGtC,CAAC"}
|
|
@@ -2,4 +2,13 @@
|
|
|
2
2
|
* Type for custom getLocale function
|
|
3
3
|
*/
|
|
4
4
|
export type GetLocale = () => string;
|
|
5
|
+
/**
|
|
6
|
+
* Html tag options
|
|
7
|
+
* @param {boolean} updateHtmlLangTag - Whether to update the html lang tag on locale change
|
|
8
|
+
* @param {boolean} updateHtmlDirTag - Whether to update the html dir tag on locale change
|
|
9
|
+
*/
|
|
10
|
+
export type HtmlTagOptions = {
|
|
11
|
+
updateHtmlLangTag?: boolean;
|
|
12
|
+
updateHtmlDirTag?: boolean;
|
|
13
|
+
};
|
|
5
14
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/i18n-context/browser-i18n-manager/utils/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/i18n-context/browser-i18n-manager/utils/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC;AAErC;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Update the html tag lang property
|
|
3
|
+
* @param {string} locale - The locale to update the html tag lang property to
|
|
4
|
+
* @returns {void}
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* updateHtmlTagLang('en');
|
|
8
|
+
*/
|
|
9
|
+
export declare function updateHtmlTagLang(locale: string): void;
|
|
10
|
+
/**
|
|
11
|
+
* Update the html tag dir property
|
|
12
|
+
* @param {string} dir - The direction to update the html tag dir property to
|
|
13
|
+
* @returns {void}
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* updateHtmlTagDir('ltr');
|
|
17
|
+
*/
|
|
18
|
+
export declare function updateHtmlTagDir(dir: 'ltr' | 'rtl'): void;
|
|
19
|
+
//# sourceMappingURL=html-tag-operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html-tag-operations.d.ts","sourceRoot":"","sources":["../../../src/i18n-context/functions/html-tag-operations.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAOtD;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,KAAK,GAAG,KAAK,GAAG,IAAI,CAOzD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/i18n-context/functions/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/i18n-context/functions/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC"}
|
|
@@ -7,13 +7,13 @@ import { InitializeGTParams } from './types';
|
|
|
7
7
|
* @example
|
|
8
8
|
* import gtConfig from '../gt.config.json';
|
|
9
9
|
*
|
|
10
|
-
* function
|
|
11
|
-
* return import(`./_gt/${locale}.json`);
|
|
10
|
+
* async function loadTranslations(locale: string) {
|
|
11
|
+
* return (await import(`./_gt/${locale}.json`)).default;
|
|
12
12
|
* }
|
|
13
13
|
*
|
|
14
14
|
* await bootstrap({
|
|
15
15
|
* ...gtConfig,
|
|
16
|
-
*
|
|
16
|
+
* loadTranslations,
|
|
17
17
|
* });
|
|
18
18
|
*
|
|
19
19
|
* await import('./main.tsx')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../../src/i18n-context/setup/bootstrap.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,SAAS,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../../src/i18n-context/setup/bootstrap.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,SAAS,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CASzE"}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import type { GTConfig, TranslationsLoader } from 'gt-i18n/internal/types';
|
|
2
|
-
import { GetLocale } from '../browser-i18n-manager/utils/types';
|
|
2
|
+
import { GetLocale, HtmlTagOptions } from '../browser-i18n-manager/utils/types';
|
|
3
3
|
/**
|
|
4
4
|
* Parameters for the initializing GT
|
|
5
5
|
* @param {string} params.defaultLocale - The default locale to use
|
|
6
6
|
* @param {string[]} params.locales - The locales to support
|
|
7
|
-
* @param {GetLocale} params.getLocale - The function to get the locale
|
|
8
7
|
* @param {TranslationsLoader} params.loadTranslations - The custom translation loader to use
|
|
8
|
+
* @param {GetLocale} [params.getLocale] - The function to get the locale
|
|
9
|
+
* @param {HtmlTagOptions} [params.htmlTagOptions.updateHtmlLangTag] - (true) Whether to update the html lang tag on locale change
|
|
10
|
+
* @param {HtmlTagOptions} [params.htmlTagOptions.updateHtmlDirTag] - (true) Whether to update the html dir tag on locale change
|
|
9
11
|
*/
|
|
10
12
|
export type InitializeGTParams = GTConfig & {
|
|
11
13
|
loadTranslations?: TranslationsLoader;
|
|
12
14
|
getLocale?: GetLocale;
|
|
15
|
+
htmlTagOptions?: HtmlTagOptions;
|
|
13
16
|
};
|
|
14
17
|
export type { GTConfig, TranslationsLoader } from 'gt-i18n/internal/types';
|
|
15
18
|
export type { GetLocale } from '../browser-i18n-manager/utils/types';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/i18n-context/setup/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/i18n-context/setup/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAEhF;;;;;;;;GAQG;AACH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG;IAC1C,gBAAgB,CAAC,EAAE,kBAAkB,CAAC;IACtC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC,CAAC;AAGF,YAAY,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC3E,YAAY,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC"}
|