@wix/site-service-locale 1.0.2 → 1.0.3

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @wix/site-service-locale
2
2
 
3
- A thin signal-backed service that exposes the current site language and text direction.
3
+ A thin signal-backed service that exposes the current site language, text direction, and regional locale.
4
4
 
5
5
  ## Install
6
6
 
@@ -21,6 +21,7 @@ const service = servicesManager.getService(LocaleDefinition)
21
21
  // getters:
22
22
  service.language
23
23
  service.direction
24
+ service.locale
24
25
  ```
25
26
 
26
27
  ## API
@@ -29,6 +30,7 @@ service.direction
29
30
  |---|---|---|---|
30
31
  | `language` | `Language` | never | Site primary language code (for example `en`, `fr`). |
31
32
  | `direction` | `LanguageDirection` | never | Site text direction (`ltr` or `rtl`). |
33
+ | `locale` | `string` | never | BCP-47 locale used for regional formatting (for example `en-US`, `de-CH`). |
32
34
  | `_updateConfig` | `(Partial<ILocaleServiceConfig>) => void` | never | Private replace-on-write updater for provided fields. |
33
35
 
34
36
  ## Configuration
@@ -37,8 +39,9 @@ service.direction
37
39
 
38
40
  ```ts
39
41
  type ILocaleServiceConfig = {
40
- language?: Language
41
- direction?: LanguageDirection
42
+ language: Language
43
+ direction: LanguageDirection
44
+ locale: string
42
45
  }
43
46
  ```
44
47
 
@@ -3,10 +3,12 @@ import type { Language, LanguageDirection } from '../types';
3
3
  export type ILocaleServiceConfig = {
4
4
  language: Language;
5
5
  direction: LanguageDirection;
6
+ locale: string;
6
7
  };
7
8
  export interface ILocaleService {
8
9
  readonly language: Language;
9
10
  readonly direction: LanguageDirection;
11
+ readonly locale: string;
10
12
  _updateConfig: (config: Partial<ILocaleServiceConfig>) => void;
11
13
  }
12
14
  export type ILocaleDefinition = ServiceDefinition<ILocaleService, ILocaleServiceConfig>;
@@ -1 +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"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/definition/index.ts"],"names":[],"mappings":";;;AAAA,oEAAyD;AAmB5C,QAAA,gBAAgB,GAAG,IAAA,oCAAa,EAAuC,0BAA0B,CAAC,CAAA"}
@@ -8,6 +8,7 @@ exports.LocaleService = (0, services_definitions_1.implementService)(definition_
8
8
  const { signal } = getService(signals_1.SignalsServiceDefinition);
9
9
  const _language = signal(config.language);
10
10
  const _direction = signal(config.direction);
11
+ const _locale = signal(config.locale);
11
12
  return {
12
13
  get language() {
13
14
  return _language.get();
@@ -15,13 +16,19 @@ exports.LocaleService = (0, services_definitions_1.implementService)(definition_
15
16
  get direction() {
16
17
  return _direction.get();
17
18
  },
18
- _updateConfig({ language, direction }) {
19
+ get locale() {
20
+ return _locale.get();
21
+ },
22
+ _updateConfig({ language, direction, locale }) {
19
23
  if (language) {
20
24
  _language.set(language);
21
25
  }
22
26
  if (direction) {
23
27
  _direction.set(direction);
24
28
  }
29
+ if (locale) {
30
+ _locale.set(locale);
31
+ }
25
32
  },
26
33
  };
27
34
  });
@@ -1 +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;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,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;YAC3B,CAAC;YACD,IAAI,SAAS,EAAE,CAAC;gBACZ,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;YAC7B,CAAC;YACD,IAAI,MAAM,EAAE,CAAC;gBACT,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;YACvB,CAAC;QACL,CAAC;KACJ,CAAA;AACL,CAAC,CACJ,CAAA"}
@@ -3,10 +3,12 @@ import type { Language, LanguageDirection } from '../types';
3
3
  export type ILocaleServiceConfig = {
4
4
  language: Language;
5
5
  direction: LanguageDirection;
6
+ locale: string;
6
7
  };
7
8
  export interface ILocaleService {
8
9
  readonly language: Language;
9
10
  readonly direction: LanguageDirection;
11
+ readonly locale: string;
10
12
  _updateConfig: (config: Partial<ILocaleServiceConfig>) => void;
11
13
  }
12
14
  export type ILocaleDefinition = ServiceDefinition<ILocaleService, ILocaleServiceConfig>;
@@ -1 +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"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/definition/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAmBzD,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAuC,0BAA0B,CAAC,CAAA"}
@@ -5,6 +5,7 @@ export const LocaleService = implementService(LocaleDefinition, ({ config, getSe
5
5
  const { signal } = getService(SignalsServiceDefinition);
6
6
  const _language = signal(config.language);
7
7
  const _direction = signal(config.direction);
8
+ const _locale = signal(config.locale);
8
9
  return {
9
10
  get language() {
10
11
  return _language.get();
@@ -12,13 +13,19 @@ export const LocaleService = implementService(LocaleDefinition, ({ config, getSe
12
13
  get direction() {
13
14
  return _direction.get();
14
15
  },
15
- _updateConfig({ language, direction }) {
16
+ get locale() {
17
+ return _locale.get();
18
+ },
19
+ _updateConfig({ language, direction, locale }) {
16
20
  if (language) {
17
21
  _language.set(language);
18
22
  }
19
23
  if (direction) {
20
24
  _direction.set(direction);
21
25
  }
26
+ if (locale) {
27
+ _locale.set(locale);
28
+ }
22
29
  },
23
30
  };
24
31
  });
@@ -1 +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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,CAAA;AACL,CAAC,CACJ,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/site-service-locale",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "main": "cjs/build/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -77,5 +77,5 @@
77
77
  ]
78
78
  }
79
79
  },
80
- "falconPackageHash": "28be00dbd06aa823b5bb0de9da80943f8223fab006708943c55e9a82"
80
+ "falconPackageHash": "bbfdbace36fedb3156231ee0832d6181bd77227ae43ed017301e84c6"
81
81
  }
@@ -5,11 +5,13 @@ import type { Language, LanguageDirection } from '../types'
5
5
  export type ILocaleServiceConfig = {
6
6
  language: Language
7
7
  direction: LanguageDirection
8
+ locale: string
8
9
  }
9
10
 
10
11
  export interface ILocaleService {
11
12
  readonly language: Language
12
13
  readonly direction: LanguageDirection
14
+ readonly locale: string
13
15
  _updateConfig: (config: Partial<ILocaleServiceConfig>) => void
14
16
  }
15
17
 
@@ -10,6 +10,7 @@ export const LocaleService = implementService(
10
10
  const { signal } = getService(SignalsServiceDefinition)
11
11
  const _language = signal(config.language)
12
12
  const _direction = signal(config.direction)
13
+ const _locale = signal(config.locale)
13
14
 
14
15
  return {
15
16
  get language() {
@@ -18,13 +19,19 @@ export const LocaleService = implementService(
18
19
  get direction() {
19
20
  return _direction.get()
20
21
  },
21
- _updateConfig({ language, direction }: Partial<ILocaleServiceConfig>) {
22
+ get locale() {
23
+ return _locale.get()
24
+ },
25
+ _updateConfig({ language, direction, locale }: Partial<ILocaleServiceConfig>) {
22
26
  if (language) {
23
27
  _language.set(language)
24
28
  }
25
29
  if (direction) {
26
30
  _direction.set(direction)
27
31
  }
32
+ if (locale) {
33
+ _locale.set(locale)
34
+ }
28
35
  },
29
36
  }
30
37
  }