@symbiote-native/localization 0.0.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/LICENSE +21 -0
- package/README.md +153 -0
- package/build/angular/index.d.ts +3 -0
- package/build/angular/index.js +7 -0
- package/build/angular/services/calendars.service/index.d.ts +6 -0
- package/build/angular/services/calendars.service/index.js +68 -0
- package/build/angular/services/locales.service/index.d.ts +6 -0
- package/build/angular/services/locales.service/index.js +69 -0
- package/build/core/index.d.ts +4 -0
- package/build/core/index.js +3 -0
- package/build/core/localization.d.ts +39 -0
- package/build/core/localization.js +42 -0
- package/build/core/native-module.d.ts +12 -0
- package/build/core/native-module.js +21 -0
- package/build/core/types.d.ts +174 -0
- package/build/core/types.js +59 -0
- package/build/react/hooks/use-calendars/index.d.ts +2 -0
- package/build/react/hooks/use-calendars/index.js +13 -0
- package/build/react/hooks/use-locales/index.d.ts +2 -0
- package/build/react/hooks/use-locales/index.js +15 -0
- package/build/react/index.d.ts +3 -0
- package/build/react/index.js +7 -0
- package/build/vue/composables/use-calendars/index.d.ts +3 -0
- package/build/vue/composables/use-calendars/index.js +16 -0
- package/build/vue/composables/use-locales/index.d.ts +3 -0
- package/build/vue/composables/use-locales/index.js +20 -0
- package/build/vue/index.d.ts +3 -0
- package/build/vue/index.js +7 -0
- package/build-ngc/angular/index.d.ts +3 -0
- package/build-ngc/angular/index.js +8 -0
- package/build-ngc/angular/index.js.map +1 -0
- package/build-ngc/angular/services/calendars.service/index.d.ts +9 -0
- package/build-ngc/angular/services/calendars.service/index.js +27 -0
- package/build-ngc/angular/services/calendars.service/index.js.map +1 -0
- package/build-ngc/angular/services/locales.service/index.d.ts +9 -0
- package/build-ngc/angular/services/locales.service/index.js +28 -0
- package/build-ngc/angular/services/locales.service/index.js.map +1 -0
- package/build-ngc/core/index.d.ts +4 -0
- package/build-ngc/core/index.js +4 -0
- package/build-ngc/core/index.js.map +1 -0
- package/build-ngc/core/localization.d.ts +39 -0
- package/build-ngc/core/localization.js +43 -0
- package/build-ngc/core/localization.js.map +1 -0
- package/build-ngc/core/native-module.d.ts +12 -0
- package/build-ngc/core/native-module.js +22 -0
- package/build-ngc/core/native-module.js.map +1 -0
- package/build-ngc/core/types.d.ts +174 -0
- package/build-ngc/core/types.js +60 -0
- package/build-ngc/core/types.js.map +1 -0
- package/native-link.json +12 -0
- package/package.json +107 -0
- package/src/angular/index.ts +17 -0
- package/src/angular/services/calendars.service/calendars.service.test.ts +102 -0
- package/src/angular/services/calendars.service/index.ts +26 -0
- package/src/angular/services/locales.service/index.ts +27 -0
- package/src/angular/services/locales.service/locales.service.test.ts +122 -0
- package/src/core/index.ts +4 -0
- package/src/core/localization.test.ts +64 -0
- package/src/core/localization.ts +45 -0
- package/src/core/native-module.ts +43 -0
- package/src/core/types.ts +181 -0
- package/src/react/hooks/use-calendars/index.ts +16 -0
- package/src/react/hooks/use-calendars/use-calendars.test.tsx +87 -0
- package/src/react/hooks/use-locales/index.ts +18 -0
- package/src/react/hooks/use-locales/use-locales.test.tsx +107 -0
- package/src/react/index.ts +18 -0
- package/src/vue/composables/use-calendars/index.ts +25 -0
- package/src/vue/composables/use-calendars/use-calendars.test.ts +96 -0
- package/src/vue/composables/use-locales/index.ts +24 -0
- package/src/vue/composables/use-locales/use-locales.test.ts +116 -0
- package/src/vue/index.ts +18 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Hand-ported verbatim from .vendors/expo/packages/expo-localization/src/Localization.types.ts
|
|
2
|
+
// (sdk-57) — plain data shapes, no expo-modules-core dependency at all. Every JSDoc comment is
|
|
3
|
+
// kept as-is: they document real, per-platform behavior differences, not restated obviousness.
|
|
4
|
+
/**
|
|
5
|
+
* An enum mapping days of the week in Gregorian calendar to their index as returned by the `firstWeekday` property.
|
|
6
|
+
*/
|
|
7
|
+
export var Weekday;
|
|
8
|
+
(function (Weekday) {
|
|
9
|
+
Weekday[Weekday["SUNDAY"] = 1] = "SUNDAY";
|
|
10
|
+
Weekday[Weekday["MONDAY"] = 2] = "MONDAY";
|
|
11
|
+
Weekday[Weekday["TUESDAY"] = 3] = "TUESDAY";
|
|
12
|
+
Weekday[Weekday["WEDNESDAY"] = 4] = "WEDNESDAY";
|
|
13
|
+
Weekday[Weekday["THURSDAY"] = 5] = "THURSDAY";
|
|
14
|
+
Weekday[Weekday["FRIDAY"] = 6] = "FRIDAY";
|
|
15
|
+
Weekday[Weekday["SATURDAY"] = 7] = "SATURDAY";
|
|
16
|
+
})(Weekday || (Weekday = {}));
|
|
17
|
+
/**
|
|
18
|
+
* The calendar identifier, one of [Unicode calendar types](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/calendar).
|
|
19
|
+
*/
|
|
20
|
+
export var CalendarIdentifier;
|
|
21
|
+
(function (CalendarIdentifier) {
|
|
22
|
+
/** Thai Buddhist calendar */
|
|
23
|
+
CalendarIdentifier["BUDDHIST"] = "buddhist";
|
|
24
|
+
/** Traditional Chinese calendar */
|
|
25
|
+
CalendarIdentifier["CHINESE"] = "chinese";
|
|
26
|
+
/** Coptic calendar */
|
|
27
|
+
CalendarIdentifier["COPTIC"] = "coptic";
|
|
28
|
+
/** Traditional Korean calendar */
|
|
29
|
+
CalendarIdentifier["DANGI"] = "dangi";
|
|
30
|
+
/** Ethiopic calendar, Amete Alem (epoch approx. 5493 B.C.E) */
|
|
31
|
+
CalendarIdentifier["ETHIOAA"] = "ethioaa";
|
|
32
|
+
/** Ethiopic calendar, Amete Mihret (epoch approx, 8 C.E.) */
|
|
33
|
+
CalendarIdentifier["ETHIOPIC"] = "ethiopic";
|
|
34
|
+
/** Gregorian calendar (also referred to upstream as "gregorian" — dropped as a separate
|
|
35
|
+
* member here since this repo's lint bans duplicate enum values). */
|
|
36
|
+
CalendarIdentifier["GREGORY"] = "gregory";
|
|
37
|
+
/** Traditional Hebrew calendar */
|
|
38
|
+
CalendarIdentifier["HEBREW"] = "hebrew";
|
|
39
|
+
/** Indian calendar */
|
|
40
|
+
CalendarIdentifier["INDIAN"] = "indian";
|
|
41
|
+
/** Islamic calendar */
|
|
42
|
+
CalendarIdentifier["ISLAMIC"] = "islamic";
|
|
43
|
+
/** Islamic calendar, tabular (intercalary years [2,5,7,10,13,16,18,21,24,26,29] - civil epoch) */
|
|
44
|
+
CalendarIdentifier["ISLAMIC_CIVIL"] = "islamic-civil";
|
|
45
|
+
/** Islamic calendar, Saudi Arabia sighting */
|
|
46
|
+
CalendarIdentifier["ISLAMIC_RGSA"] = "islamic-rgsa";
|
|
47
|
+
/**Islamic calendar, tabular (intercalary years [2,5,7,10,13,16,18,21,24,26,29] - astronomical epoch) */
|
|
48
|
+
CalendarIdentifier["ISLAMIC_TBLA"] = "islamic-tbla";
|
|
49
|
+
/** Islamic calendar, Umm al-Qura */
|
|
50
|
+
CalendarIdentifier["ISLAMIC_UMALQURA"] = "islamic-umalqura";
|
|
51
|
+
/** ISO calendar (Gregorian calendar using the ISO 8601 calendar week rules) */
|
|
52
|
+
CalendarIdentifier["ISO8601"] = "iso8601";
|
|
53
|
+
/** Japanese imperial calendar */
|
|
54
|
+
CalendarIdentifier["JAPANESE"] = "japanese";
|
|
55
|
+
/** Persian calendar */
|
|
56
|
+
CalendarIdentifier["PERSIAN"] = "persian";
|
|
57
|
+
/** Civil (algorithmic) Arabic calendar */
|
|
58
|
+
CalendarIdentifier["ROC"] = "roc";
|
|
59
|
+
})(CalendarIdentifier || (CalendarIdentifier = {}));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// React lifecycle wiring over the framework-agnostic core — mirrors use-locales' shape exactly.
|
|
2
|
+
// Ported from expo-localization's own useCalendars hook (sdk-57).
|
|
3
|
+
import { useEffect, useMemo, useReducer } from 'react';
|
|
4
|
+
import { addCalendarListener, getCalendars } from '../../../core';
|
|
5
|
+
export function useCalendars() {
|
|
6
|
+
const [invalidationKey, invalidate] = useReducer((key) => key + 1, 0);
|
|
7
|
+
const calendars = useMemo(() => getCalendars(), [invalidationKey]);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const subscription = addCalendarListener(invalidate);
|
|
10
|
+
return () => subscription.remove();
|
|
11
|
+
}, []);
|
|
12
|
+
return calendars;
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// React lifecycle wiring over the framework-agnostic core (core/localization.ts /
|
|
2
|
+
// core/native-module.ts). Ported from expo-localization's own useLocales hook (sdk-57): a
|
|
3
|
+
// useReducer-driven invalidation counter that useMemo recomputes getLocales() from, whenever the
|
|
4
|
+
// native module fires onLocaleSettingsChanged.
|
|
5
|
+
import { useEffect, useMemo, useReducer } from 'react';
|
|
6
|
+
import { addLocaleListener, getLocales } from '../../../core';
|
|
7
|
+
export function useLocales() {
|
|
8
|
+
const [invalidationKey, invalidate] = useReducer((key) => key + 1, 0);
|
|
9
|
+
const locales = useMemo(() => getLocales(), [invalidationKey]);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const subscription = addLocaleListener(invalidate);
|
|
12
|
+
return () => subscription.remove();
|
|
13
|
+
}, []);
|
|
14
|
+
return locales;
|
|
15
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { useLocales } from './hooks/use-locales';
|
|
2
|
+
export { useCalendars } from './hooks/use-calendars';
|
|
3
|
+
export { getLocales, getCalendars, addLocaleListener, addCalendarListener, Weekday, CalendarIdentifier, type Locale, type Calendar, type EventSubscription, } from '../core';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// @symbiote-native/localization/react: the React entry over the framework-agnostic core. Locales
|
|
2
|
+
// and calendars each get their own lifecycle hook, matching upstream's own useLocales/
|
|
3
|
+
// useCalendars being two separate hooks, not one combined hook — mirrors the lifecycle-bucket
|
|
4
|
+
// naming convention of adapters/react/src/hooks (never `composables`, that's Vue's term).
|
|
5
|
+
export { useLocales } from './hooks/use-locales';
|
|
6
|
+
export { useCalendars } from './hooks/use-calendars';
|
|
7
|
+
export { getLocales, getCalendars, addLocaleListener, addCalendarListener, Weekday, CalendarIdentifier, } from '../core';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Vue lifecycle wiring over the framework-agnostic core — mirrors use-locales' shape exactly.
|
|
2
|
+
import { onMounted, onUnmounted, ref } from '@vue/runtime-core';
|
|
3
|
+
import { addCalendarListener, getCalendars, } from '../../../core';
|
|
4
|
+
export function useCalendars() {
|
|
5
|
+
const calendars = ref(getCalendars());
|
|
6
|
+
let subscription;
|
|
7
|
+
onMounted(() => {
|
|
8
|
+
subscription = addCalendarListener(() => {
|
|
9
|
+
calendars.value = getCalendars();
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
onUnmounted(() => {
|
|
13
|
+
subscription?.remove();
|
|
14
|
+
});
|
|
15
|
+
return calendars;
|
|
16
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Vue lifecycle wiring over the framework-agnostic core (core/localization.ts). Unlike
|
|
2
|
+
// packages/network's use-network-state (which seeds a placeholder and fetches asynchronously in
|
|
3
|
+
// onMounted), getLocales() is a synchronous native call, so the ref is computed once, directly at
|
|
4
|
+
// setup — onMounted only wires the change listener, mirroring use-network-state's
|
|
5
|
+
// onMounted/onUnmounted subscription shape otherwise.
|
|
6
|
+
import { onMounted, onUnmounted, ref } from '@vue/runtime-core';
|
|
7
|
+
import { addLocaleListener, getLocales } from '../../../core';
|
|
8
|
+
export function useLocales() {
|
|
9
|
+
const locales = ref(getLocales());
|
|
10
|
+
let subscription;
|
|
11
|
+
onMounted(() => {
|
|
12
|
+
subscription = addLocaleListener(() => {
|
|
13
|
+
locales.value = getLocales();
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
onUnmounted(() => {
|
|
17
|
+
subscription?.remove();
|
|
18
|
+
});
|
|
19
|
+
return locales;
|
|
20
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { useLocales } from './composables/use-locales';
|
|
2
|
+
export { useCalendars } from './composables/use-calendars';
|
|
3
|
+
export { getLocales, getCalendars, addLocaleListener, addCalendarListener, Weekday, CalendarIdentifier, type Locale, type Calendar, type EventSubscription, } from '../core';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// @symbiote-native/localization/vue: the Vue entry over the framework-agnostic core. Locales and
|
|
2
|
+
// calendars each get their own lifecycle composable, matching upstream's own useLocales/
|
|
3
|
+
// useCalendars being two separate hooks, not one combined hook — mirrors the lifecycle-bucket
|
|
4
|
+
// naming convention of adapters/vue/src/composables (never `hooks`, that's React's term).
|
|
5
|
+
export { useLocales } from './composables/use-locales';
|
|
6
|
+
export { useCalendars } from './composables/use-calendars';
|
|
7
|
+
export { getLocales, getCalendars, addLocaleListener, addCalendarListener, Weekday, CalendarIdentifier, } from '../core';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { LocalesService } from './services/locales.service';
|
|
2
|
+
export { CalendarsService } from './services/calendars.service';
|
|
3
|
+
export { getLocales, getCalendars, addLocaleListener, addCalendarListener, Weekday, CalendarIdentifier, type Locale, type Calendar, type EventSubscription, } from '../core';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// LocalesService/CalendarsService are the Angular-only lifecycle half; the free functions and
|
|
2
|
+
// event subscription plumbing all live in core, shared with React/Vue. Two separate services
|
|
3
|
+
// (not one combined service), matching upstream's own useLocales/useCalendars being two separate
|
|
4
|
+
// hooks.
|
|
5
|
+
export { LocalesService } from './services/locales.service';
|
|
6
|
+
export { CalendarsService } from './services/calendars.service';
|
|
7
|
+
export { getLocales, getCalendars, addLocaleListener, addCalendarListener, Weekday, CalendarIdentifier, } from '../core';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/angular/index.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,6FAA6F;AAC7F,iGAAiG;AACjG,SAAS;AACT,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EACL,UAAU,EACV,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,OAAO,EACP,kBAAkB,GAInB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Signal } from '@angular/core';
|
|
2
|
+
import { type Calendar } from '../../../core';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export declare class CalendarsService {
|
|
5
|
+
private readonly injector;
|
|
6
|
+
connect(): Signal<Calendar[]>;
|
|
7
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CalendarsService, never>;
|
|
8
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<CalendarsService>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { effect, inject, Injectable, Injector, signal } from '@angular/core';
|
|
2
|
+
import { addCalendarListener, getCalendars } from '../../../core';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
// Angular twin of React's `useCalendars` hook and Vue's `useCalendars` composable — mirrors
|
|
5
|
+
// LocalesService's shape exactly.
|
|
6
|
+
//
|
|
7
|
+
// readonly calendars = inject(CalendarsService).connect();
|
|
8
|
+
// // template: {{ calendars() }}
|
|
9
|
+
export class CalendarsService {
|
|
10
|
+
injector = inject(Injector);
|
|
11
|
+
connect() {
|
|
12
|
+
const calendars = signal(getCalendars(), /* @ts-ignore */
|
|
13
|
+
...(ngDevMode ? [{ debugName: "calendars" }] : /* istanbul ignore next */ []));
|
|
14
|
+
effect(onCleanup => {
|
|
15
|
+
const subscription = addCalendarListener(() => calendars.set(getCalendars()));
|
|
16
|
+
onCleanup(() => subscription.remove());
|
|
17
|
+
}, { injector: this.injector });
|
|
18
|
+
return calendars.asReadonly();
|
|
19
|
+
}
|
|
20
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CalendarsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
21
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CalendarsService, providedIn: 'root' });
|
|
22
|
+
}
|
|
23
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CalendarsService, decorators: [{
|
|
24
|
+
type: Injectable,
|
|
25
|
+
args: [{ providedIn: 'root' }]
|
|
26
|
+
}] });
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/angular/services/calendars.service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAiB,MAAM,eAAe,CAAC;;AAEjF,4FAA4F;AAC5F,kCAAkC;AAClC,EAAE;AACF,6DAA6D;AAC7D,mCAAmC;AAEnC,MAAM,OAAO,gBAAgB;IACV,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAE7C,OAAO;QACL,MAAM,SAAS,GAAG,MAAM,CAAa,YAAY,EAAE;sFAAC,CAAC;QAErD,MAAM,CACJ,SAAS,CAAC,EAAE;YACV,MAAM,YAAY,GAAG,mBAAmB,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;YAC9E,SAAS,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;QACzC,CAAC,EACD,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAC5B,CAAC;QAEF,OAAO,SAAS,CAAC,UAAU,EAAE,CAAC;IAChC,CAAC;uGAfU,gBAAgB;2GAAhB,gBAAgB,cADH,MAAM;;2FACnB,gBAAgB;kBAD5B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Signal } from '@angular/core';
|
|
2
|
+
import { type Locale } from '../../../core';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export declare class LocalesService {
|
|
5
|
+
private readonly injector;
|
|
6
|
+
connect(): Signal<Locale[]>;
|
|
7
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<LocalesService, never>;
|
|
8
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<LocalesService>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { effect, inject, Injectable, Injector, signal } from '@angular/core';
|
|
2
|
+
import { addLocaleListener, getLocales } from '../../../core';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
// Angular twin of React's `useLocales` hook and Vue's `useLocales` composable. See
|
|
5
|
+
// packages/battery's BatteryStateService for the `connect()` pattern rationale. getLocales() is
|
|
6
|
+
// synchronous, so the signal seeds from it directly rather than an async `.then()` fetch.
|
|
7
|
+
//
|
|
8
|
+
// readonly locales = inject(LocalesService).connect();
|
|
9
|
+
// // template: {{ locales() }}
|
|
10
|
+
export class LocalesService {
|
|
11
|
+
injector = inject(Injector);
|
|
12
|
+
connect() {
|
|
13
|
+
const locales = signal(getLocales(), /* @ts-ignore */
|
|
14
|
+
...(ngDevMode ? [{ debugName: "locales" }] : /* istanbul ignore next */ []));
|
|
15
|
+
effect(onCleanup => {
|
|
16
|
+
const subscription = addLocaleListener(() => locales.set(getLocales()));
|
|
17
|
+
onCleanup(() => subscription.remove());
|
|
18
|
+
}, { injector: this.injector });
|
|
19
|
+
return locales.asReadonly();
|
|
20
|
+
}
|
|
21
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: LocalesService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
22
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: LocalesService, providedIn: 'root' });
|
|
23
|
+
}
|
|
24
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: LocalesService, decorators: [{
|
|
25
|
+
type: Injectable,
|
|
26
|
+
args: [{ providedIn: 'root' }]
|
|
27
|
+
}] });
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/angular/services/locales.service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAe,MAAM,eAAe,CAAC;;AAE3E,mFAAmF;AACnF,gGAAgG;AAChG,0FAA0F;AAC1F,EAAE;AACF,yDAAyD;AACzD,iCAAiC;AAEjC,MAAM,OAAO,cAAc;IACR,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAE7C,OAAO;QACL,MAAM,OAAO,GAAG,MAAM,CAAW,UAAU,EAAE;oFAAC,CAAC;QAE/C,MAAM,CACJ,SAAS,CAAC,EAAE;YACV,MAAM,YAAY,GAAG,iBAAiB,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;YACxE,SAAS,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;QACzC,CAAC,EACD,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAC5B,CAAC;QAEF,OAAO,OAAO,CAAC,UAAU,EAAE,CAAC;IAC9B,CAAC;uGAfU,cAAc;2GAAd,cAAc,cADD,MAAM;;2FACnB,cAAc;kBAD1B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { getLocales, getCalendars } from './localization';
|
|
2
|
+
export { addLocaleListener, addCalendarListener } from './native-module';
|
|
3
|
+
export { Weekday, CalendarIdentifier, type Locale, type Calendar } from './types';
|
|
4
|
+
export type { EventSubscription } from 'expo-modules-core';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAA8B,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Calendar, Locale } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* List of user's locales, returned as an array of objects of type `Locale`.
|
|
4
|
+
* Guaranteed to contain at least 1 element.
|
|
5
|
+
* These are returned in the order the user defines in their device settings.
|
|
6
|
+
* On the web currency and measurements systems are not provided, instead returned as null.
|
|
7
|
+
* If needed, you can infer them from the current region using a lookup table.
|
|
8
|
+
* @example
|
|
9
|
+
* ```js
|
|
10
|
+
* [{
|
|
11
|
+
* "languageTag": "pl-PL",
|
|
12
|
+
* "languageCode": "pl",
|
|
13
|
+
* "textDirection": "ltr",
|
|
14
|
+
* "digitGroupingSeparator": " ",
|
|
15
|
+
* "decimalSeparator": ",",
|
|
16
|
+
* "measurementSystem": "metric",
|
|
17
|
+
* "currencyCode": "PLN",
|
|
18
|
+
* "currencySymbol": "zł",
|
|
19
|
+
* "regionCode": "PL",
|
|
20
|
+
* "temperatureUnit": "celsius"
|
|
21
|
+
* }]
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare const getLocales: () => Locale[];
|
|
25
|
+
/**
|
|
26
|
+
* List of user's preferred calendars, returned as an array of objects of type `Calendar`.
|
|
27
|
+
* Guaranteed to contain at least 1 element.
|
|
28
|
+
* For now always returns a single element, but it's likely to return a user preference list on some platforms in the future.
|
|
29
|
+
* @example
|
|
30
|
+
* ```js
|
|
31
|
+
* [{
|
|
32
|
+
* "calendar": "gregory",
|
|
33
|
+
* "timeZone": "Europe/Warsaw",
|
|
34
|
+
* "uses24hourClock": true,
|
|
35
|
+
* "firstWeekday": 1
|
|
36
|
+
* }]
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare const getCalendars: () => Calendar[];
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Hand-ported from .vendors/expo/packages/expo-localization/src/Localization.ts (sdk-57) —
|
|
2
|
+
// both functions delegate straight to the native module, no extra wrapping needed beyond typing
|
|
3
|
+
// them as synchronous getters.
|
|
4
|
+
import ExpoLocalizationModule from './native-module';
|
|
5
|
+
/**
|
|
6
|
+
* List of user's locales, returned as an array of objects of type `Locale`.
|
|
7
|
+
* Guaranteed to contain at least 1 element.
|
|
8
|
+
* These are returned in the order the user defines in their device settings.
|
|
9
|
+
* On the web currency and measurements systems are not provided, instead returned as null.
|
|
10
|
+
* If needed, you can infer them from the current region using a lookup table.
|
|
11
|
+
* @example
|
|
12
|
+
* ```js
|
|
13
|
+
* [{
|
|
14
|
+
* "languageTag": "pl-PL",
|
|
15
|
+
* "languageCode": "pl",
|
|
16
|
+
* "textDirection": "ltr",
|
|
17
|
+
* "digitGroupingSeparator": " ",
|
|
18
|
+
* "decimalSeparator": ",",
|
|
19
|
+
* "measurementSystem": "metric",
|
|
20
|
+
* "currencyCode": "PLN",
|
|
21
|
+
* "currencySymbol": "zł",
|
|
22
|
+
* "regionCode": "PL",
|
|
23
|
+
* "temperatureUnit": "celsius"
|
|
24
|
+
* }]
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export const getLocales = ExpoLocalizationModule.getLocales;
|
|
28
|
+
/**
|
|
29
|
+
* List of user's preferred calendars, returned as an array of objects of type `Calendar`.
|
|
30
|
+
* Guaranteed to contain at least 1 element.
|
|
31
|
+
* For now always returns a single element, but it's likely to return a user preference list on some platforms in the future.
|
|
32
|
+
* @example
|
|
33
|
+
* ```js
|
|
34
|
+
* [{
|
|
35
|
+
* "calendar": "gregory",
|
|
36
|
+
* "timeZone": "Europe/Warsaw",
|
|
37
|
+
* "uses24hourClock": true,
|
|
38
|
+
* "firstWeekday": 1
|
|
39
|
+
* }]
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export const getCalendars = ExpoLocalizationModule.getCalendars;
|
|
43
|
+
//# sourceMappingURL=localization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localization.js","sourceRoot":"","sources":["../../src/core/localization.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,gGAAgG;AAChG,+BAA+B;AAC/B,OAAO,sBAAsB,MAAM,iBAAiB,CAAC;AAGrD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,UAAU,GAAmB,sBAAsB,CAAC,UAAU,CAAC;AAE5E;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,YAAY,GAAqB,sBAAsB,CAAC,YAAY,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type EventSubscription } from 'expo-modules-core';
|
|
2
|
+
import type { Calendar, Locale } from './types';
|
|
3
|
+
export type INativeLocalizationModule = {
|
|
4
|
+
getLocales(): Locale[];
|
|
5
|
+
getCalendars(): Calendar[];
|
|
6
|
+
addListener(eventName: 'onLocaleSettingsChanged', listener: (event?: unknown) => void): EventSubscription;
|
|
7
|
+
addListener(eventName: 'onCalendarSettingsChanged', listener: (event?: unknown) => void): EventSubscription;
|
|
8
|
+
};
|
|
9
|
+
declare const ExpoLocalizationModule: INativeLocalizationModule;
|
|
10
|
+
export declare function addLocaleListener(listener: (event?: unknown) => void): EventSubscription;
|
|
11
|
+
export declare function addCalendarListener(listener: (event?: unknown) => void): EventSubscription;
|
|
12
|
+
export default ExpoLocalizationModule;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Hand-ported from .vendors/expo/packages/expo-localization/src/ExpoLocalization.native.ts
|
|
2
|
+
// (sdk-57). getLocales()/getCalendars() are synchronous, JSI-bridged native calls (no await) —
|
|
3
|
+
// the native module itself implements them as sync-bridged functions, the same constants-style
|
|
4
|
+
// read pattern this repo already uses for expo-device's eagerly-resolved fields
|
|
5
|
+
// (packages/device/src/core/native-module.ts). One native module fans out two independent event
|
|
6
|
+
// streams (locale settings vs calendar settings) through the same addListener, keyed by event
|
|
7
|
+
// name — mirrors the three-event-names-on-one-addListener overload trick in
|
|
8
|
+
// packages/battery/src/core/native-module.ts.
|
|
9
|
+
import { requireNativeModule } from 'expo-modules-core';
|
|
10
|
+
const EXPO_LOCALIZATION_MODULE_NAME = 'ExpoLocalization';
|
|
11
|
+
const ExpoLocalizationModule = requireNativeModule(EXPO_LOCALIZATION_MODULE_NAME);
|
|
12
|
+
export function addLocaleListener(
|
|
13
|
+
// NOTE: upstream never uses the event's data — the listener is invoked purely as an
|
|
14
|
+
// invalidate signal for useLocales/the Vue composable/the Angular service below.
|
|
15
|
+
listener) {
|
|
16
|
+
return ExpoLocalizationModule.addListener('onLocaleSettingsChanged', listener);
|
|
17
|
+
}
|
|
18
|
+
export function addCalendarListener(listener) {
|
|
19
|
+
return ExpoLocalizationModule.addListener('onCalendarSettingsChanged', listener);
|
|
20
|
+
}
|
|
21
|
+
export default ExpoLocalizationModule;
|
|
22
|
+
//# sourceMappingURL=native-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-module.js","sourceRoot":"","sources":["../../src/core/native-module.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,+FAA+F;AAC/F,+FAA+F;AAC/F,gFAAgF;AAChF,gGAAgG;AAChG,8FAA8F;AAC9F,4EAA4E;AAC5E,8CAA8C;AAC9C,OAAO,EAA0B,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAGhF,MAAM,6BAA6B,GAAG,kBAAkB,CAAC;AAezD,MAAM,sBAAsB,GAAG,mBAAmB,CAChD,6BAA6B,CAC9B,CAAC;AAEF,MAAM,UAAU,iBAAiB;AAC/B,oFAAoF;AACpF,iFAAiF;AACjF,QAAmC;IAEnC,OAAO,sBAAsB,CAAC,WAAW,CAAC,yBAAyB,EAAE,QAAQ,CAAC,CAAC;AACjF,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,QAAmC;IACrE,OAAO,sBAAsB,CAAC,WAAW,CAAC,2BAA2B,EAAE,QAAQ,CAAC,CAAC;AACnF,CAAC;AAED,eAAe,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
export type Locale = {
|
|
2
|
+
/**
|
|
3
|
+
* An [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) with a region code.
|
|
4
|
+
* @example
|
|
5
|
+
* `'en-US'`, `'es-419'`, `'pl-PL'`.
|
|
6
|
+
*/
|
|
7
|
+
languageTag: string;
|
|
8
|
+
/**
|
|
9
|
+
* An [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) without the region code.
|
|
10
|
+
* @example
|
|
11
|
+
* `'en'`, `'es'`, `'pl'`.
|
|
12
|
+
*/
|
|
13
|
+
languageCode: string | null;
|
|
14
|
+
/**
|
|
15
|
+
* An [ISO 15924](https://en.wikipedia.org/wiki/ISO_15924) 4-letter script code. On Android and Web, it may be `null` if none is defined.
|
|
16
|
+
* @example
|
|
17
|
+
* `'Latn'`, `'Hans'`, `'Hebr'`.
|
|
18
|
+
*/
|
|
19
|
+
languageScriptCode: string | null;
|
|
20
|
+
/**
|
|
21
|
+
* The region code for your device that comes from the Region setting under Language & Region on iOS, Region settings on Android and is parsed from locale on Web (can be `null` on Web).
|
|
22
|
+
* @example
|
|
23
|
+
* `'US'`.
|
|
24
|
+
*/
|
|
25
|
+
regionCode: string | null;
|
|
26
|
+
/**
|
|
27
|
+
* The region code for the preferred language. When the language is not region-specific, it returns the same value as `regionCode`. When the language is region-specific, it returns the region code for the language (`en-CA` -> `CA`).
|
|
28
|
+
* Prefer using `regionCode` for any internalization purposes.
|
|
29
|
+
* @example
|
|
30
|
+
* `'US'`.
|
|
31
|
+
*/
|
|
32
|
+
languageRegionCode: string | null;
|
|
33
|
+
/**
|
|
34
|
+
* Currency code for the locale.
|
|
35
|
+
* On iOS, it's the currency code from the `Region` setting under Language & Region, not for the current locale.
|
|
36
|
+
* On Android, it's the currency specifc to the locale in the list, as there are no separate settings for selecting a region.
|
|
37
|
+
* Is `null` on Web, use a table lookup based on region instead.
|
|
38
|
+
* @example
|
|
39
|
+
* `'USD'`, `'EUR'`, `'PLN'`.
|
|
40
|
+
*/
|
|
41
|
+
currencyCode: string | null;
|
|
42
|
+
/**
|
|
43
|
+
* Currency symbol for the currency specified by `currencyCode`.
|
|
44
|
+
* @example
|
|
45
|
+
* `'$'`, `'€'`, `'zł'`.
|
|
46
|
+
*/
|
|
47
|
+
currencySymbol: string | null;
|
|
48
|
+
/**
|
|
49
|
+
* Currency code for the locale.
|
|
50
|
+
* On iOS, it's the currency code for the current locale in the list, not the device region.
|
|
51
|
+
* On Android, it's equal to `currencyCode`.
|
|
52
|
+
* Is `null` on Web.
|
|
53
|
+
* Prefer using `currencyCode` for any internalization purposes.
|
|
54
|
+
* @example
|
|
55
|
+
* `'USD'`, `'EUR'`, `'PLN'`.
|
|
56
|
+
*/
|
|
57
|
+
languageCurrencyCode: string | null;
|
|
58
|
+
/**
|
|
59
|
+
* Currency symbol for the currency specified by `languageCurrencyCode`.
|
|
60
|
+
* Prefer using `currencySymbol` for any internalization purposes.
|
|
61
|
+
* @example
|
|
62
|
+
* `'$'`, `'€'`, `'zł'`.
|
|
63
|
+
*/
|
|
64
|
+
languageCurrencySymbol: string | null;
|
|
65
|
+
/**
|
|
66
|
+
* Decimal separator used for formatting numbers with fractional parts.
|
|
67
|
+
* @example
|
|
68
|
+
* `'.'`, `','`.
|
|
69
|
+
*/
|
|
70
|
+
decimalSeparator: string | null;
|
|
71
|
+
/**
|
|
72
|
+
* Digit grouping separator used for formatting large numbers.
|
|
73
|
+
* @example
|
|
74
|
+
* `'.'`, `','`.
|
|
75
|
+
*/
|
|
76
|
+
digitGroupingSeparator: string | null;
|
|
77
|
+
/**
|
|
78
|
+
* Text direction for the locale. One of: `'ltr'`, `'rtl'`.
|
|
79
|
+
*/
|
|
80
|
+
textDirection: 'ltr' | 'rtl';
|
|
81
|
+
/**
|
|
82
|
+
* The measurement system used in the locale.
|
|
83
|
+
* Is `null` on Web, as user chosen measurement system is not exposed on the web and using locale to determine measurement systems is unreliable.
|
|
84
|
+
* Ask for user preferences if possible.
|
|
85
|
+
*/
|
|
86
|
+
measurementSystem: `metric` | `us` | `uk` | null;
|
|
87
|
+
/**
|
|
88
|
+
* The temperature unit used in the locale.
|
|
89
|
+
* Returns `null` if the region code is unknown.
|
|
90
|
+
*/
|
|
91
|
+
temperatureUnit: 'celsius' | 'fahrenheit' | null;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* An enum mapping days of the week in Gregorian calendar to their index as returned by the `firstWeekday` property.
|
|
95
|
+
*/
|
|
96
|
+
export declare enum Weekday {
|
|
97
|
+
SUNDAY = 1,
|
|
98
|
+
MONDAY = 2,
|
|
99
|
+
TUESDAY = 3,
|
|
100
|
+
WEDNESDAY = 4,
|
|
101
|
+
THURSDAY = 5,
|
|
102
|
+
FRIDAY = 6,
|
|
103
|
+
SATURDAY = 7
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The calendar identifier, one of [Unicode calendar types](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/calendar).
|
|
107
|
+
*/
|
|
108
|
+
export declare enum CalendarIdentifier {
|
|
109
|
+
/** Thai Buddhist calendar */
|
|
110
|
+
BUDDHIST = "buddhist",
|
|
111
|
+
/** Traditional Chinese calendar */
|
|
112
|
+
CHINESE = "chinese",
|
|
113
|
+
/** Coptic calendar */
|
|
114
|
+
COPTIC = "coptic",
|
|
115
|
+
/** Traditional Korean calendar */
|
|
116
|
+
DANGI = "dangi",
|
|
117
|
+
/** Ethiopic calendar, Amete Alem (epoch approx. 5493 B.C.E) */
|
|
118
|
+
ETHIOAA = "ethioaa",
|
|
119
|
+
/** Ethiopic calendar, Amete Mihret (epoch approx, 8 C.E.) */
|
|
120
|
+
ETHIOPIC = "ethiopic",
|
|
121
|
+
/** Gregorian calendar (also referred to upstream as "gregorian" — dropped as a separate
|
|
122
|
+
* member here since this repo's lint bans duplicate enum values). */
|
|
123
|
+
GREGORY = "gregory",
|
|
124
|
+
/** Traditional Hebrew calendar */
|
|
125
|
+
HEBREW = "hebrew",
|
|
126
|
+
/** Indian calendar */
|
|
127
|
+
INDIAN = "indian",
|
|
128
|
+
/** Islamic calendar */
|
|
129
|
+
ISLAMIC = "islamic",
|
|
130
|
+
/** Islamic calendar, tabular (intercalary years [2,5,7,10,13,16,18,21,24,26,29] - civil epoch) */
|
|
131
|
+
ISLAMIC_CIVIL = "islamic-civil",
|
|
132
|
+
/** Islamic calendar, Saudi Arabia sighting */
|
|
133
|
+
ISLAMIC_RGSA = "islamic-rgsa",
|
|
134
|
+
/**Islamic calendar, tabular (intercalary years [2,5,7,10,13,16,18,21,24,26,29] - astronomical epoch) */
|
|
135
|
+
ISLAMIC_TBLA = "islamic-tbla",
|
|
136
|
+
/** Islamic calendar, Umm al-Qura */
|
|
137
|
+
ISLAMIC_UMALQURA = "islamic-umalqura",
|
|
138
|
+
/** ISO calendar (Gregorian calendar using the ISO 8601 calendar week rules) */
|
|
139
|
+
ISO8601 = "iso8601",
|
|
140
|
+
/** Japanese imperial calendar */
|
|
141
|
+
JAPANESE = "japanese",
|
|
142
|
+
/** Persian calendar */
|
|
143
|
+
PERSIAN = "persian",
|
|
144
|
+
/** Civil (algorithmic) Arabic calendar */
|
|
145
|
+
ROC = "roc"
|
|
146
|
+
}
|
|
147
|
+
export type Calendar = {
|
|
148
|
+
/**
|
|
149
|
+
* The calendar identifier, one of [Unicode calendar types](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/calendar).
|
|
150
|
+
*
|
|
151
|
+
* On Android is limited to one of device's [available calendar types](https://developer.android.com/reference/java/util/Calendar#getAvailableCalendarTypes()).
|
|
152
|
+
*
|
|
153
|
+
* On iOS uses [calendar identifiers](https://developer.apple.com/documentation/foundation/calendar/identifier), but maps them to the corresponding Unicode types, will also never contain `'dangi'` or `'islamic-rgsa'` due to it not being implemented on iOS.
|
|
154
|
+
*/
|
|
155
|
+
calendar: CalendarIdentifier | null;
|
|
156
|
+
/**
|
|
157
|
+
* True when current device settings use 24-hour time format.
|
|
158
|
+
* Can be null on some browsers that don't support the [hourCycle](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/hourCycle) property in [Intl](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl) API.
|
|
159
|
+
*/
|
|
160
|
+
uses24hourClock: boolean | null;
|
|
161
|
+
/**
|
|
162
|
+
* The first day of the week. For most calendars Sunday is numbered `1`, with Saturday being number `7`.
|
|
163
|
+
* Can be null on some browsers that don't support the [weekInfo](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/weekInfo) property in [Intl](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl) API.
|
|
164
|
+
* @example
|
|
165
|
+
* `1`, `7`.
|
|
166
|
+
*/
|
|
167
|
+
firstWeekday: Weekday | null;
|
|
168
|
+
/**
|
|
169
|
+
* Time zone for the calendar. Can be `null` on Web.
|
|
170
|
+
* @example
|
|
171
|
+
* `'America/Los_Angeles'`, `'Europe/Warsaw'`, `'GMT+1'`.
|
|
172
|
+
*/
|
|
173
|
+
timeZone: string | null;
|
|
174
|
+
};
|