@shoelace-style/localize 2.1.2 → 2.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.1.3
4
+
5
+ - Renamed `updateLocalizedTerms()` to `update()` (forgive me SemVer, but nobody was using this I promise)
3
6
 
4
7
  ## 2.1.2
5
8
 
package/dist/index.d.ts CHANGED
@@ -11,7 +11,7 @@ export declare function term<K extends keyof Translation>(lang: string, key: K,
11
11
  export declare function date(lang: string, dateToFormat: Date | string, options?: Intl.DateTimeFormatOptions): string;
12
12
  export declare function number(lang: string, numberToFormat: number | string, options?: Intl.NumberFormatOptions): string;
13
13
  export declare function relativeTime(lang: string, value: number, unit: Intl.RelativeTimeFormatUnit, options?: Intl.RelativeTimeFormatOptions): string;
14
- export declare function updateLocalizedTerms(): void;
14
+ export declare function update(): void;
15
15
  export declare class LocalizeController implements ReactiveController {
16
16
  host: ReactiveControllerHost & HTMLElement;
17
17
  constructor(host: ReactiveControllerHost & HTMLElement);
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const connectedElements = new Set();
2
- const documentElementObserver = new MutationObserver(updateLocalizedTerms);
2
+ const documentElementObserver = new MutationObserver(update);
3
3
  const translations = new Map();
4
4
  let documentLanguage = document.documentElement.lang || navigator.language;
5
5
  let fallback;
@@ -15,7 +15,7 @@ export function registerTranslation(...translation) {
15
15
  fallback = t;
16
16
  }
17
17
  });
18
- updateLocalizedTerms();
18
+ update();
19
19
  }
20
20
  export function term(lang, key, ...args) {
21
21
  const code = lang.toLowerCase().slice(0, 2);
@@ -52,7 +52,7 @@ export function number(lang, numberToFormat, options) {
52
52
  export function relativeTime(lang, value, unit, options) {
53
53
  return new Intl.RelativeTimeFormat(lang, options).format(value, unit);
54
54
  }
55
- export function updateLocalizedTerms() {
55
+ export function update() {
56
56
  documentLanguage = document.documentElement.lang || navigator.language;
57
57
  [...connectedElements.keys()].map((el) => {
58
58
  if (typeof el.requestUpdate === 'function') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shoelace-style/localize",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "description": "A micro library for localizing custom elements using Lit's Reactive Controller model.",
5
5
  "main": "/dist/index.js",
6
6
  "module": "/dist/index.js",
package/src/index.ts CHANGED
@@ -10,7 +10,7 @@ export interface Translation {
10
10
  }
11
11
 
12
12
  const connectedElements = new Set<HTMLElement>();
13
- const documentElementObserver = new MutationObserver(updateLocalizedTerms);
13
+ const documentElementObserver = new MutationObserver(update);
14
14
  const translations: Map<string, Translation> = new Map();
15
15
  let documentLanguage = document.documentElement.lang || navigator.language;
16
16
  let fallback: Translation;
@@ -35,7 +35,7 @@ export function registerTranslation(...translation: Translation[]) {
35
35
  }
36
36
  });
37
37
 
38
- updateLocalizedTerms();
38
+ update();
39
39
  }
40
40
 
41
41
  //
@@ -97,9 +97,9 @@ export function relativeTime(
97
97
  }
98
98
 
99
99
  //
100
- // Updates the locale for all localized elements that are currently connected
100
+ // Updates all localized elements that are currently connected
101
101
  //
102
- export function updateLocalizedTerms() {
102
+ export function update() {
103
103
  documentLanguage = document.documentElement.lang || navigator.language;
104
104
 
105
105
  [...connectedElements.keys()].map((el: LitElement) => {