@wix/site-service-locale 1.0.2

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.
Files changed (48) hide show
  1. package/README.md +47 -0
  2. package/cjs/build/definition/index.d.ts +17 -0
  3. package/cjs/build/definition/index.js +6 -0
  4. package/cjs/build/definition/index.js.map +1 -0
  5. package/cjs/build/implementations/index.d.ts +1 -0
  6. package/cjs/build/implementations/index.js +6 -0
  7. package/cjs/build/implementations/index.js.map +1 -0
  8. package/cjs/build/implementations/localeService.d.ts +6 -0
  9. package/cjs/build/implementations/localeService.js +28 -0
  10. package/cjs/build/implementations/localeService.js.map +1 -0
  11. package/cjs/build/index.d.ts +2 -0
  12. package/cjs/build/index.js +19 -0
  13. package/cjs/build/index.js.map +1 -0
  14. package/cjs/build/service.d.ts +7 -0
  15. package/cjs/build/service.js +8 -0
  16. package/cjs/build/service.js.map +1 -0
  17. package/cjs/build/types/index.d.ts +3 -0
  18. package/cjs/build/types/index.js +3 -0
  19. package/cjs/build/types/index.js.map +1 -0
  20. package/cjs/package.json +3 -0
  21. package/definition/package.json +3 -0
  22. package/dist/definition/index.d.ts +17 -0
  23. package/dist/definition/index.js +3 -0
  24. package/dist/definition/index.js.map +1 -0
  25. package/dist/implementations/index.d.ts +1 -0
  26. package/dist/implementations/index.js +2 -0
  27. package/dist/implementations/index.js.map +1 -0
  28. package/dist/implementations/localeService.d.ts +6 -0
  29. package/dist/implementations/localeService.js +25 -0
  30. package/dist/implementations/localeService.js.map +1 -0
  31. package/dist/index.d.ts +2 -0
  32. package/dist/index.js +3 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/service.d.ts +7 -0
  35. package/dist/service.js +5 -0
  36. package/dist/service.js.map +1 -0
  37. package/dist/types/index.d.ts +3 -0
  38. package/dist/types/index.js +2 -0
  39. package/dist/types/index.js.map +1 -0
  40. package/implementations/package.json +3 -0
  41. package/package.json +81 -0
  42. package/src/definition/index.ts +18 -0
  43. package/src/implementations/index.ts +1 -0
  44. package/src/implementations/localeService.ts +31 -0
  45. package/src/index.ts +2 -0
  46. package/src/service.ts +5 -0
  47. package/src/types/index.ts +187 -0
  48. package/types/package.json +3 -0
package/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # @wix/site-service-locale
2
+
3
+ A thin signal-backed service that exposes the current site language and text direction.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ yarn add @wix/site-service-locale
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { LocaleDefinition } from '@wix/site-service-locale/definition'
15
+ import { LocaleService } from '@wix/site-service-locale/implementations'
16
+
17
+ createServicesMap().addService(LocaleDefinition, LocaleService, config)
18
+
19
+ const service = servicesManager.getService(LocaleDefinition)
20
+
21
+ // getters:
22
+ service.language
23
+ service.direction
24
+ ```
25
+
26
+ ## API
27
+
28
+ | Member | Type | Throws when | Description |
29
+ |---|---|---|---|
30
+ | `language` | `Language` | never | Site primary language code (for example `en`, `fr`). |
31
+ | `direction` | `LanguageDirection` | never | Site text direction (`ltr` or `rtl`). |
32
+ | `_updateConfig` | `(Partial<ILocaleServiceConfig>) => void` | never | Private replace-on-write updater for provided fields. |
33
+
34
+ ## Configuration
35
+
36
+ `ILocaleServiceConfig`:
37
+
38
+ ```ts
39
+ type ILocaleServiceConfig = {
40
+ language?: Language
41
+ direction?: LanguageDirection
42
+ }
43
+ ```
44
+
45
+ ## Reactivity
46
+
47
+ This service is a thin signal wrapper over `@wix/services-definitions/core-services/signals`. Every property is signal-backed under the hood; wrap reads in `effect` / `computed` to react to changes. Signals are not exposed directly.
@@ -0,0 +1,17 @@
1
+ import type { ServiceDefinition } from '@wix/services-definitions';
2
+ import type { Language, LanguageDirection } from '../types';
3
+ export type ILocaleServiceConfig = {
4
+ language: Language;
5
+ direction: LanguageDirection;
6
+ };
7
+ export interface ILocaleService {
8
+ readonly language: Language;
9
+ readonly direction: LanguageDirection;
10
+ _updateConfig: (config: Partial<ILocaleServiceConfig>) => void;
11
+ }
12
+ export type ILocaleDefinition = ServiceDefinition<ILocaleService, ILocaleServiceConfig>;
13
+ export declare const LocaleDefinition: string & {
14
+ __api: ILocaleService;
15
+ __config: ILocaleServiceConfig;
16
+ isServiceDefinition?: boolean;
17
+ } & ILocaleService;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LocaleDefinition = void 0;
4
+ const services_definitions_1 = require("@wix/services-definitions");
5
+ exports.LocaleDefinition = (0, services_definitions_1.defineService)('@wix/site-service-locale');
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/definition/index.ts"],"names":[],"mappings":";;;AAAA,oEAAyD;AAiB5C,QAAA,gBAAgB,GAAG,IAAA,oCAAa,EAAuC,0BAA0B,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ export { LocaleService } from './localeService';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LocaleService = void 0;
4
+ var localeService_1 = require("./localeService");
5
+ Object.defineProperty(exports, "LocaleService", { enumerable: true, get: function () { return localeService_1.LocaleService; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/implementations/index.ts"],"names":[],"mappings":";;;AAAA,iDAA+C;AAAtC,8GAAA,aAAa,OAAA"}
@@ -0,0 +1,6 @@
1
+ import type { ILocaleService, ILocaleServiceConfig } from '../definition';
2
+ export declare const LocaleService: import("@wix/services-definitions").ServiceFactory<string & {
3
+ __api: ILocaleService;
4
+ __config: ILocaleServiceConfig;
5
+ isServiceDefinition?: boolean;
6
+ } & ILocaleService, ILocaleServiceConfig>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LocaleService = void 0;
4
+ const services_definitions_1 = require("@wix/services-definitions");
5
+ const signals_1 = require("@wix/services-definitions/core-services/signals");
6
+ const definition_1 = require("../definition");
7
+ exports.LocaleService = (0, services_definitions_1.implementService)(definition_1.LocaleDefinition, ({ config, getService }) => {
8
+ const { signal } = getService(signals_1.SignalsServiceDefinition);
9
+ const _language = signal(config.language);
10
+ const _direction = signal(config.direction);
11
+ return {
12
+ get language() {
13
+ return _language.get();
14
+ },
15
+ get direction() {
16
+ return _direction.get();
17
+ },
18
+ _updateConfig({ language, direction }) {
19
+ if (language) {
20
+ _language.set(language);
21
+ }
22
+ if (direction) {
23
+ _direction.set(direction);
24
+ }
25
+ },
26
+ };
27
+ });
28
+ //# sourceMappingURL=localeService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localeService.js","sourceRoot":"","sources":["../../../src/implementations/localeService.ts"],"names":[],"mappings":";;;AAAA,oEAA4D;AAE5D,6EAA0F;AAE1F,8CAAgD;AAEnC,QAAA,aAAa,GAAG,IAAA,uCAAgB,EACzC,6BAAgB,EAChB,CAAC,EAAE,MAAM,EAAE,UAAU,EAA4C,EAAkB,EAAE;IACjF,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,kCAAwB,CAAC,CAAA;IACvD,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IACzC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;IAE3C,OAAO;QACH,IAAI,QAAQ;YACR,OAAO,SAAS,CAAC,GAAG,EAAE,CAAA;QAC1B,CAAC;QACD,IAAI,SAAS;YACT,OAAO,UAAU,CAAC,GAAG,EAAE,CAAA;QAC3B,CAAC;QACD,aAAa,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAiC;YAChE,IAAI,QAAQ,EAAE,CAAC;gBACX,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;YAC3B,CAAC;YACD,IAAI,SAAS,EAAE,CAAC;gBACZ,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;YAC7B,CAAC;QACL,CAAC;KACJ,CAAA;AACL,CAAC,CACJ,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './definition';
2
+ export * from './implementations';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./definition"), exports);
18
+ __exportStar(require("./implementations"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B;AAC5B,oDAAiC"}
@@ -0,0 +1,7 @@
1
+ import { LocaleService } from './implementations/localeService';
2
+ export declare const definition: string & {
3
+ __api: import("./definition").ILocaleService;
4
+ __config: import("./definition").ILocaleServiceConfig;
5
+ isServiceDefinition?: boolean;
6
+ } & import("./definition").ILocaleService;
7
+ export default LocaleService;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.definition = void 0;
4
+ const definition_1 = require("./definition");
5
+ const localeService_1 = require("./implementations/localeService");
6
+ exports.definition = definition_1.LocaleDefinition;
7
+ exports.default = localeService_1.LocaleService;
8
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/service.ts"],"names":[],"mappings":";;;AAAA,6CAA+C;AAC/C,mEAA+D;AAElD,QAAA,UAAU,GAAG,6BAAgB,CAAA;AAC1C,kBAAe,6BAAa,CAAA"}
@@ -0,0 +1,3 @@
1
+ export type LanguageDirection = 'ltr' | 'rtl';
2
+ export type Language = 'fa' | 'fo' | 'ps' | 'sq' | 'hy' | 'bn' | 'be' | 'yo' | 'bs' | 'pt' | 'bg' | 'km' | 'zh' | 'hr' | 'da' | 'et' | 'fj' | 'fi' | 'fr' | 'de' | 'el' | 'ht' | 'hu' | 'is' | 'gu' | 'hi' | 'kl' | 'kn' | 'ml' | 'sd' | 'ta' | 'te' | 'id' | 'su' | 'ku' | 'ga' | 'gl' | 'he' | 'yi' | 'co' | 'it' | 'la' | 'lb' | 'ja' | 'jp' | 'kk' | 'sw' | 'ln' | 'lo' | 'lv' | 'lt' | 'mi' | 'mk' | 'mg' | 'mr' | 'ms' | 'mt' | 'my' | 'mn' | 'ne' | 'ha' | 'ig' | 'no' | 'tl' | 'pl' | 'ro' | 'ru' | 'se' | 'sm' | 'sr' | 'sk' | 'si' | 'sl' | 'so' | 'af' | 'xh' | 'zu' | 'ko' | 'eu' | 'ca' | 'es' | 'sv' | 'tg' | 'th' | 'tr' | 'ug' | 'uk' | 'cy' | 'en' | 'uz' | 'vi' | 'ny' | 'sn' | 'az' | 'cs' | 'am' | 'ka' | 'ky' | 'nl' | 'ur' | 'ar' | 'qu' | 'tk' | 'aa' | 'ab' | 'ae' | 'ak' | 'an' | 'as' | 'av' | 'ay' | 'ba' | 'bh' | 'bi' | 'bm' | 'bo' | 'br' | 'ce' | 'ch' | 'cr' | 'cu' | 'cv' | 'dv' | 'dz' | 'ee' | 'eo' | 'ff' | 'fy' | 'gd' | 'gn' | 'gv' | 'ho' | 'hz' | 'ia' | 'ie' | 'ii' | 'ik' | 'io' | 'iu' | 'jv' | 'ki' | 'kr' | 'ks' | 'kw' | 'lg' | 'li' | 'lu' | 'mh' | 'na' | 'nb' | 'nd' | 'ng' | 'nn' | 'nr' | 'nv' | 'oc' | 'oj' | 'om' | 'or' | 'os' | 'pa' | 'pi' | 'rm' | 'rn' | 'rw' | 'sa' | 'sc' | 'sg' | 'ss' | 'st' | 'ti' | 'tn' | 'to' | 'ts' | 'tt' | 'tw' | 'ty' | 've' | 'vo' | 'wa' | 'wo' | 'za';
3
+ export type { ILocaleService, ILocaleServiceConfig, ILocaleDefinition } from '../definition';
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "main": "../cjs/build/definition/index.js"
3
+ }
@@ -0,0 +1,17 @@
1
+ import type { ServiceDefinition } from '@wix/services-definitions';
2
+ import type { Language, LanguageDirection } from '../types';
3
+ export type ILocaleServiceConfig = {
4
+ language: Language;
5
+ direction: LanguageDirection;
6
+ };
7
+ export interface ILocaleService {
8
+ readonly language: Language;
9
+ readonly direction: LanguageDirection;
10
+ _updateConfig: (config: Partial<ILocaleServiceConfig>) => void;
11
+ }
12
+ export type ILocaleDefinition = ServiceDefinition<ILocaleService, ILocaleServiceConfig>;
13
+ export declare const LocaleDefinition: string & {
14
+ __api: ILocaleService;
15
+ __config: ILocaleServiceConfig;
16
+ isServiceDefinition?: boolean;
17
+ } & ILocaleService;
@@ -0,0 +1,3 @@
1
+ import { defineService } from '@wix/services-definitions';
2
+ export const LocaleDefinition = defineService('@wix/site-service-locale');
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/definition/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAiBzD,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAuC,0BAA0B,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ export { LocaleService } from './localeService';
@@ -0,0 +1,2 @@
1
+ export { LocaleService } from './localeService';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/implementations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import type { ILocaleService, ILocaleServiceConfig } from '../definition';
2
+ export declare const LocaleService: import("@wix/services-definitions").ServiceFactory<string & {
3
+ __api: ILocaleService;
4
+ __config: ILocaleServiceConfig;
5
+ isServiceDefinition?: boolean;
6
+ } & ILocaleService, ILocaleServiceConfig>;
@@ -0,0 +1,25 @@
1
+ import { implementService } from '@wix/services-definitions';
2
+ import { SignalsServiceDefinition } from '@wix/services-definitions/core-services/signals';
3
+ import { LocaleDefinition } from '../definition';
4
+ export const LocaleService = implementService(LocaleDefinition, ({ config, getService }) => {
5
+ const { signal } = getService(SignalsServiceDefinition);
6
+ const _language = signal(config.language);
7
+ const _direction = signal(config.direction);
8
+ return {
9
+ get language() {
10
+ return _language.get();
11
+ },
12
+ get direction() {
13
+ return _direction.get();
14
+ },
15
+ _updateConfig({ language, direction }) {
16
+ if (language) {
17
+ _language.set(language);
18
+ }
19
+ if (direction) {
20
+ _direction.set(direction);
21
+ }
22
+ },
23
+ };
24
+ });
25
+ //# sourceMappingURL=localeService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localeService.js","sourceRoot":"","sources":["../../src/implementations/localeService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAE5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAA;AAE1F,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAEhD,MAAM,CAAC,MAAM,aAAa,GAAG,gBAAgB,CACzC,gBAAgB,EAChB,CAAC,EAAE,MAAM,EAAE,UAAU,EAA4C,EAAkB,EAAE;IACjF,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,wBAAwB,CAAC,CAAA;IACvD,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IACzC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;IAE3C,OAAO;QACH,IAAI,QAAQ;YACR,OAAO,SAAS,CAAC,GAAG,EAAE,CAAA;QAC1B,CAAC;QACD,IAAI,SAAS;YACT,OAAO,UAAU,CAAC,GAAG,EAAE,CAAA;QAC3B,CAAC;QACD,aAAa,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAiC;YAChE,IAAI,QAAQ,EAAE,CAAC;gBACX,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;YAC3B,CAAC;YACD,IAAI,SAAS,EAAE,CAAC;gBACZ,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;YAC7B,CAAC;QACL,CAAC;KACJ,CAAA;AACL,CAAC,CACJ,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './definition';
2
+ export * from './implementations';
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from './definition';
2
+ export * from './implementations';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,mBAAmB,CAAA"}
@@ -0,0 +1,7 @@
1
+ import { LocaleService } from './implementations/localeService';
2
+ export declare const definition: string & {
3
+ __api: import("./definition").ILocaleService;
4
+ __config: import("./definition").ILocaleServiceConfig;
5
+ isServiceDefinition?: boolean;
6
+ } & import("./definition").ILocaleService;
7
+ export default LocaleService;
@@ -0,0 +1,5 @@
1
+ import { LocaleDefinition } from './definition';
2
+ import { LocaleService } from './implementations/localeService';
3
+ export const definition = LocaleDefinition;
4
+ export default LocaleService;
5
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAA;AAE/D,MAAM,CAAC,MAAM,UAAU,GAAG,gBAAgB,CAAA;AAC1C,eAAe,aAAa,CAAA"}
@@ -0,0 +1,3 @@
1
+ export type LanguageDirection = 'ltr' | 'rtl';
2
+ export type Language = 'fa' | 'fo' | 'ps' | 'sq' | 'hy' | 'bn' | 'be' | 'yo' | 'bs' | 'pt' | 'bg' | 'km' | 'zh' | 'hr' | 'da' | 'et' | 'fj' | 'fi' | 'fr' | 'de' | 'el' | 'ht' | 'hu' | 'is' | 'gu' | 'hi' | 'kl' | 'kn' | 'ml' | 'sd' | 'ta' | 'te' | 'id' | 'su' | 'ku' | 'ga' | 'gl' | 'he' | 'yi' | 'co' | 'it' | 'la' | 'lb' | 'ja' | 'jp' | 'kk' | 'sw' | 'ln' | 'lo' | 'lv' | 'lt' | 'mi' | 'mk' | 'mg' | 'mr' | 'ms' | 'mt' | 'my' | 'mn' | 'ne' | 'ha' | 'ig' | 'no' | 'tl' | 'pl' | 'ro' | 'ru' | 'se' | 'sm' | 'sr' | 'sk' | 'si' | 'sl' | 'so' | 'af' | 'xh' | 'zu' | 'ko' | 'eu' | 'ca' | 'es' | 'sv' | 'tg' | 'th' | 'tr' | 'ug' | 'uk' | 'cy' | 'en' | 'uz' | 'vi' | 'ny' | 'sn' | 'az' | 'cs' | 'am' | 'ka' | 'ky' | 'nl' | 'ur' | 'ar' | 'qu' | 'tk' | 'aa' | 'ab' | 'ae' | 'ak' | 'an' | 'as' | 'av' | 'ay' | 'ba' | 'bh' | 'bi' | 'bm' | 'bo' | 'br' | 'ce' | 'ch' | 'cr' | 'cu' | 'cv' | 'dv' | 'dz' | 'ee' | 'eo' | 'ff' | 'fy' | 'gd' | 'gn' | 'gv' | 'ho' | 'hz' | 'ia' | 'ie' | 'ii' | 'ik' | 'io' | 'iu' | 'jv' | 'ki' | 'kr' | 'ks' | 'kw' | 'lg' | 'li' | 'lu' | 'mh' | 'na' | 'nb' | 'nd' | 'ng' | 'nn' | 'nr' | 'nv' | 'oc' | 'oj' | 'om' | 'or' | 'os' | 'pa' | 'pi' | 'rm' | 'rn' | 'rw' | 'sa' | 'sc' | 'sg' | 'ss' | 'st' | 'ti' | 'tn' | 'to' | 'ts' | 'tt' | 'tw' | 'ty' | 've' | 'vo' | 'wa' | 'wo' | 'za';
3
+ export type { ILocaleService, ILocaleServiceConfig, ILocaleDefinition } from '../definition';
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ {
2
+ "main": "../cjs/build/implementations/index.js"
3
+ }
package/package.json ADDED
@@ -0,0 +1,81 @@
1
+ {
2
+ "name": "@wix/site-service-locale",
3
+ "version": "1.0.2",
4
+ "main": "cjs/build/index.js",
5
+ "module": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "license": "MIT",
8
+ "files": [
9
+ "dist",
10
+ "src",
11
+ "cjs",
12
+ "definition",
13
+ "implementations",
14
+ "types",
15
+ "!**/*.tsbuildinfo"
16
+ ],
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "import": "./dist/index.js",
21
+ "require": "./cjs/build/index.js"
22
+ },
23
+ "./definition": {
24
+ "types": "./dist/definition/index.d.ts",
25
+ "import": "./dist/definition/index.js",
26
+ "require": "./cjs/build/definition/index.js"
27
+ },
28
+ "./implementations": {
29
+ "types": "./dist/implementations/index.d.ts",
30
+ "import": "./dist/implementations/index.js",
31
+ "require": "./cjs/build/implementations/index.js"
32
+ },
33
+ "./types": {
34
+ "types": "./dist/types/index.d.ts",
35
+ "import": "./dist/types/index.js",
36
+ "require": "./cjs/build/types/index.js"
37
+ },
38
+ "./service": {
39
+ "types": "./dist/service.d.ts",
40
+ "import": "./dist/service.js",
41
+ "require": "./cjs/build/service.js"
42
+ }
43
+ },
44
+ "dependencies": {
45
+ "@wix/services-definitions": "^0.1.4",
46
+ "@wix/services-manager": "^0.2.20"
47
+ },
48
+ "devDependencies": {
49
+ "typescript": "^5.3.3",
50
+ "vitest": "4.1.0"
51
+ },
52
+ "scripts": {
53
+ "build": "tsc -b . --force && tsc --project tsconfig.cjs.json",
54
+ "lint": "yarn run -T lint:package $npm_package_name",
55
+ "test": "vitest --run && yarn test-type-check",
56
+ "test-type-check": "echo 'validating typescript in test files' && tsc --project tsconfig.test.json && echo 'Finished validating typescript in test files successfully'"
57
+ },
58
+ "publishUnscoped": false,
59
+ "publishConfig": {
60
+ "registry": "https://registry.npmjs.org/",
61
+ "access": "public"
62
+ },
63
+ "sideEffects": false,
64
+ "wix": {
65
+ "artifact": {
66
+ "groupId": "com.wixpress.npm",
67
+ "artifactId": "site-service-locale",
68
+ "targets": {
69
+ "static": false,
70
+ "docker": false
71
+ }
72
+ },
73
+ "validations": {
74
+ "postBuild": [
75
+ "test",
76
+ "lint"
77
+ ]
78
+ }
79
+ },
80
+ "falconPackageHash": "28be00dbd06aa823b5bb0de9da80943f8223fab006708943c55e9a82"
81
+ }
@@ -0,0 +1,18 @@
1
+ import { defineService } from '@wix/services-definitions'
2
+ import type { ServiceDefinition } from '@wix/services-definitions'
3
+ import type { Language, LanguageDirection } from '../types'
4
+
5
+ export type ILocaleServiceConfig = {
6
+ language: Language
7
+ direction: LanguageDirection
8
+ }
9
+
10
+ export interface ILocaleService {
11
+ readonly language: Language
12
+ readonly direction: LanguageDirection
13
+ _updateConfig: (config: Partial<ILocaleServiceConfig>) => void
14
+ }
15
+
16
+ export type ILocaleDefinition = ServiceDefinition<ILocaleService, ILocaleServiceConfig>
17
+
18
+ export const LocaleDefinition = defineService<ILocaleService, ILocaleServiceConfig>('@wix/site-service-locale')
@@ -0,0 +1 @@
1
+ export { LocaleService } from './localeService'
@@ -0,0 +1,31 @@
1
+ import { implementService } from '@wix/services-definitions'
2
+ import type { ServiceFactoryOpts } from '@wix/services-definitions'
3
+ import { SignalsServiceDefinition } from '@wix/services-definitions/core-services/signals'
4
+ import type { ILocaleService, ILocaleServiceConfig } from '../definition'
5
+ import { LocaleDefinition } from '../definition'
6
+
7
+ export const LocaleService = implementService(
8
+ LocaleDefinition,
9
+ ({ config, getService }: ServiceFactoryOpts<ILocaleServiceConfig>): ILocaleService => {
10
+ const { signal } = getService(SignalsServiceDefinition)
11
+ const _language = signal(config.language)
12
+ const _direction = signal(config.direction)
13
+
14
+ return {
15
+ get language() {
16
+ return _language.get()
17
+ },
18
+ get direction() {
19
+ return _direction.get()
20
+ },
21
+ _updateConfig({ language, direction }: Partial<ILocaleServiceConfig>) {
22
+ if (language) {
23
+ _language.set(language)
24
+ }
25
+ if (direction) {
26
+ _direction.set(direction)
27
+ }
28
+ },
29
+ }
30
+ }
31
+ )
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './definition'
2
+ export * from './implementations'
package/src/service.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { LocaleDefinition } from './definition'
2
+ import { LocaleService } from './implementations/localeService'
3
+
4
+ export const definition = LocaleDefinition
5
+ export default LocaleService
@@ -0,0 +1,187 @@
1
+ export type LanguageDirection = 'ltr' | 'rtl'
2
+
3
+ export type Language =
4
+ | 'fa'
5
+ | 'fo'
6
+ | 'ps'
7
+ | 'sq'
8
+ | 'hy'
9
+ | 'bn'
10
+ | 'be'
11
+ | 'yo'
12
+ | 'bs'
13
+ | 'pt'
14
+ | 'bg'
15
+ | 'km'
16
+ | 'zh'
17
+ | 'hr'
18
+ | 'da'
19
+ | 'et'
20
+ | 'fj'
21
+ | 'fi'
22
+ | 'fr'
23
+ | 'de'
24
+ | 'el'
25
+ | 'ht'
26
+ | 'hu'
27
+ | 'is'
28
+ | 'gu'
29
+ | 'hi'
30
+ | 'kl'
31
+ | 'kn'
32
+ | 'ml'
33
+ | 'sd'
34
+ | 'ta'
35
+ | 'te'
36
+ | 'id'
37
+ | 'su'
38
+ | 'ku'
39
+ | 'ga'
40
+ | 'gl'
41
+ | 'he'
42
+ | 'yi'
43
+ | 'co'
44
+ | 'it'
45
+ | 'la'
46
+ | 'lb'
47
+ | 'ja'
48
+ | 'jp'
49
+ | 'kk'
50
+ | 'sw'
51
+ | 'ln'
52
+ | 'lo'
53
+ | 'lv'
54
+ | 'lt'
55
+ | 'mi'
56
+ | 'mk'
57
+ | 'mg'
58
+ | 'mr'
59
+ | 'ms'
60
+ | 'mt'
61
+ | 'my'
62
+ | 'mn'
63
+ | 'ne'
64
+ | 'ha'
65
+ | 'ig'
66
+ | 'no'
67
+ | 'tl'
68
+ | 'pl'
69
+ | 'ro'
70
+ | 'ru'
71
+ | 'se'
72
+ | 'sm'
73
+ | 'sr'
74
+ | 'sk'
75
+ | 'si'
76
+ | 'sl'
77
+ | 'so'
78
+ | 'af'
79
+ | 'xh'
80
+ | 'zu'
81
+ | 'ko'
82
+ | 'eu'
83
+ | 'ca'
84
+ | 'es'
85
+ | 'sv'
86
+ | 'tg'
87
+ | 'th'
88
+ | 'tr'
89
+ | 'ug'
90
+ | 'uk'
91
+ | 'cy'
92
+ | 'en'
93
+ | 'uz'
94
+ | 'vi'
95
+ | 'ny'
96
+ | 'sn'
97
+ | 'az'
98
+ | 'cs'
99
+ | 'am'
100
+ | 'ka'
101
+ | 'ky'
102
+ | 'nl'
103
+ | 'ur'
104
+ | 'ar'
105
+ | 'qu'
106
+ | 'tk'
107
+ | 'aa'
108
+ | 'ab'
109
+ | 'ae'
110
+ | 'ak'
111
+ | 'an'
112
+ | 'as'
113
+ | 'av'
114
+ | 'ay'
115
+ | 'ba'
116
+ | 'bh'
117
+ | 'bi'
118
+ | 'bm'
119
+ | 'bo'
120
+ | 'br'
121
+ | 'ce'
122
+ | 'ch'
123
+ | 'cr'
124
+ | 'cu'
125
+ | 'cv'
126
+ | 'dv'
127
+ | 'dz'
128
+ | 'ee'
129
+ | 'eo'
130
+ | 'ff'
131
+ | 'fy'
132
+ | 'gd'
133
+ | 'gn'
134
+ | 'gv'
135
+ | 'ho'
136
+ | 'hz'
137
+ | 'ia'
138
+ | 'ie'
139
+ | 'ii'
140
+ | 'ik'
141
+ | 'io'
142
+ | 'iu'
143
+ | 'jv'
144
+ | 'ki'
145
+ | 'kr'
146
+ | 'ks'
147
+ | 'kw'
148
+ | 'lg'
149
+ | 'li'
150
+ | 'lu'
151
+ | 'mh'
152
+ | 'na'
153
+ | 'nb'
154
+ | 'nd'
155
+ | 'ng'
156
+ | 'nn'
157
+ | 'nr'
158
+ | 'nv'
159
+ | 'oc'
160
+ | 'oj'
161
+ | 'om'
162
+ | 'or'
163
+ | 'os'
164
+ | 'pa'
165
+ | 'pi'
166
+ | 'rm'
167
+ | 'rn'
168
+ | 'rw'
169
+ | 'sa'
170
+ | 'sc'
171
+ | 'sg'
172
+ | 'ss'
173
+ | 'st'
174
+ | 'ti'
175
+ | 'tn'
176
+ | 'to'
177
+ | 'ts'
178
+ | 'tt'
179
+ | 'tw'
180
+ | 'ty'
181
+ | 've'
182
+ | 'vo'
183
+ | 'wa'
184
+ | 'wo'
185
+ | 'za'
186
+
187
+ export type { ILocaleService, ILocaleServiceConfig, ILocaleDefinition } from '../definition'
@@ -0,0 +1,3 @@
1
+ {
2
+ "main": "../cjs/build/types/index.js"
3
+ }