@solidnative-dev/localization 0.0.0-stage → 0.1.0-beta.0

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Solid Native contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,60 @@
1
- # Temporary Holding Version
1
+ # `@solidnative-dev/localization`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Validated startup locale and effective native layout direction for Solid Native
4
+ applications. The React Native adapter calls the pinned 0.87 `I18nManager`
5
+ TurboModule directly without evaluating `I18nManager.js` or its generated
6
+ JavaScript spec.
7
+
8
+ ```ts
9
+ import { getReactNativeLocalizationSnapshot } from "@solidnative-dev/localization/react-native";
10
+
11
+ const localization = getReactNativeLocalizationSnapshot();
12
+ // { localeTag: "de-CH", layoutDirection: "ltr", ... }
13
+ ```
14
+
15
+ Android's underscore-separated locale identifier is normalized to a hyphenated
16
+ tag. React Native's iOS module omits the identifier, so that platform uses the
17
+ Hermes `Intl.DateTimeFormat` locale while retaining native `isRTL` and style
18
+ swap policy. Every field is validated and the result is frozen.
19
+
20
+ This is deliberately a startup snapshot rather than a reactive accessor:
21
+ Android and iOS apply locale and RTL configuration during native application
22
+ startup, and changing those settings requires a restart. The package does not
23
+ expose `forceRTL`, `allowRTL`, or style-swapping mutation as if they updated the
24
+ running Fabric surface.
25
+
26
+ Shipping iOS applications must declare every supported localization, including
27
+ at least one RTL localization before natural RTL can activate. Xcode normally
28
+ derives `CFBundleLocalizations` from the project's localized resources; projects
29
+ that manage the plist directly must provide the equivalent declaration.
30
+
31
+ React Native 0.87's Android `I18nUtil` consults an arbitrary available locale
32
+ when deriving natural RTL. The package-owned Android `SolidNativeSurface`
33
+ therefore synchronizes React Native's package-scoped Fabric preferences from the
34
+ Activity's effective application locale immediately before surface creation.
35
+ This keeps the native Activity, the read-only snapshot, and Yoga direction
36
+ aligned without exposing the JavaScript mutation facade.
37
+
38
+ Run the physical Android Release gate on one attached, unlocked device with:
39
+
40
+ ```sh
41
+ pnpm --filter @solidnative-dev/native-e2e android:localization:test
42
+ ```
43
+
44
+ The gate uses package-scoped `en-US` and `ar-SA` cold starts without modifying
45
+ the device locale or global RTL setting. It independently verifies Activity
46
+ configuration, TurboModule snapshot, decor direction, mirrored Fabric child
47
+ geometry, style swapping, teardown, and process/package cleanup.
48
+
49
+ Run the signed physical iPhone Release gate with:
50
+
51
+ ```sh
52
+ SOLID_NATIVE_IOS_DESTINATION=<CoreDevice-identifier> \
53
+ SOLID_NATIVE_IOS_TEAM=<development-team> \
54
+ pnpm --filter @solidnative-dev/native-e2e ios:localization:test
55
+ ```
56
+
57
+ XCTest gives only the disposable app process `en-US` and `ar-SA` startup
58
+ preferences. It requires Hermes Intl, the direct native `I18nManager` snapshot,
59
+ and the physical LTR/RTL Fabric geometry to agree, disposes both cold-started
60
+ surfaces without terminating the host process, and removes the signed app.
@@ -0,0 +1,13 @@
1
+ export declare const LOCALIZATION_MAX_LOCALE_TAG_LENGTH = 128;
2
+ export type NativeLayoutDirection = "ltr" | "rtl";
3
+ export interface LocalizationSnapshot {
4
+ readonly localeTag: string;
5
+ readonly layoutDirection: NativeLayoutDirection;
6
+ readonly swapsLeftAndRightInRTL: boolean;
7
+ }
8
+ export interface LocalizationAdapter {
9
+ readSnapshot(): unknown;
10
+ }
11
+ /** Reads and freezes the native startup locale and effective layout policy. */
12
+ export declare function readLocalizationSnapshot(adapter: LocalizationAdapter): LocalizationSnapshot;
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kCAAkC,MAAM,CAAC;AAEtD,MAAM,MAAM,qBAAqB,GAAG,KAAK,GAAG,KAAK,CAAC;AAElD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,eAAe,EAAE,qBAAqB,CAAC;IAChD,QAAQ,CAAC,sBAAsB,EAAE,OAAO,CAAC;CAC1C;AAED,MAAM,WAAW,mBAAmB;IAClC,YAAY,IAAI,OAAO,CAAC;CACzB;AAiCD,+EAA+E;AAC/E,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,mBAAmB,GAC3B,oBAAoB,CAetB"}
package/dist/index.js ADDED
@@ -0,0 +1,37 @@
1
+ export const LOCALIZATION_MAX_LOCALE_TAG_LENGTH = 128;
2
+ function record(value, path) {
3
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
4
+ throw new TypeError(`${path} must be an object.`);
5
+ }
6
+ return value;
7
+ }
8
+ function boolean(value, path) {
9
+ if (typeof value !== "boolean") {
10
+ throw new TypeError(`${path} must be a boolean.`);
11
+ }
12
+ return value;
13
+ }
14
+ function localeTag(value) {
15
+ if (typeof value !== "string" ||
16
+ value.length === 0 ||
17
+ value.length > LOCALIZATION_MAX_LOCALE_TAG_LENGTH ||
18
+ !/^[A-Za-z0-9]+(?:[-_][A-Za-z0-9]+)*$/u.test(value)) {
19
+ throw new TypeError(`Localization localeTag must be a language tag containing 1-${LOCALIZATION_MAX_LOCALE_TAG_LENGTH} ASCII letters, digits, hyphens, or underscores.`);
20
+ }
21
+ return value.replaceAll("_", "-");
22
+ }
23
+ /** Reads and freezes the native startup locale and effective layout policy. */
24
+ export function readLocalizationSnapshot(adapter) {
25
+ const candidate = record(adapter, "Localization adapter");
26
+ if (typeof candidate.readSnapshot !== "function") {
27
+ throw new TypeError("Localization adapter must provide readSnapshot().");
28
+ }
29
+ const snapshot = record(adapter.readSnapshot(), "Localization snapshot");
30
+ const isRTL = boolean(snapshot.isRTL, "Localization snapshot.isRTL");
31
+ return Object.freeze({
32
+ localeTag: localeTag(snapshot.localeTag),
33
+ layoutDirection: isRTL ? "rtl" : "ltr",
34
+ swapsLeftAndRightInRTL: boolean(snapshot.swapsLeftAndRightInRTL, "Localization snapshot.swapsLeftAndRightInRTL"),
35
+ });
36
+ }
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kCAAkC,GAAG,GAAG,CAAC;AActD,SAAS,MAAM,CACb,KAAc,EACd,IAAY;IAEZ,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACxE,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,qBAAqB,CAAC,CAAC;IACpD,CAAC;IACD,OAAO,KAA0C,CAAC;AACpD,CAAC;AAED,SAAS,OAAO,CAAC,KAAc,EAAE,IAAY;IAC3C,IAAI,OAAO,KAAK,KAAK,S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interface ReactNativeI18nManagerModule {
3
+ getConstants(): unknown;
4
+ }
5
+ export type DefaultLocaleReader = () => unknown;
6
+ /** @internal Translation seam kept separate from native module lookup. */
7
+ export declare function readReactNativeLocalizationSnapshot(value: ReactNativeI18nManagerModule, readDefaultLocale?: DefaultLocaleReader): LocalizationSnapshot;
8
+ //# sourceMappingURL=react-native-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-native-adapter.d.ts","sourceRoot":"","sources":["../src/react-native-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,4BAA4B;IAC3C,YAAY,IAAI,OAAO,CAAC;CACzB;AAED,MAAM,MAAM,mBAAmB,GAAG,MAAM,OAAO,CAAC;AAgBhD,0EAA0E;AAC1E,wBAAgB,mCAAmC,CACjD,KAAK,EAAE,4BAA4B,EACnC,iBAAiB,GAAE,mBAAmC,GACrD,oBAAoB,CA2BtB"}
@@ -0,0 +1,34 @@
1
+ import { readLocalizationSnapshot, } from "./index.js";
2
+ function record(value, path) {
3
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
4
+ throw new TypeError(`${path} must be an object.`);
5
+ }
6
+ return value;
7
+ }
8
+ function defaultLocale() {
9
+ return Intl.DateTimeFormat().resolvedOptions().locale;
10
+ }
11
+ /** @internal Translation seam kept separate from native module lookup. */
12
+ export function readReactNativeLocalizationSnapshot(value, readDefaultLocale = defaultLocale) {
13
+ const module = record(value, "React Native I18nManager module");
14
+ if (typeof module.getConstants !== "function") {
15
+ throw new TypeError("React Native I18nManager module must provide getConstants().");
16
+ }
17
+ if (typeof readDefaultLocale !== "function") {
18
+ throw new TypeError("Default locale reader must be a function.");
19
+ }
20
+ return readLocalizationSnapshot({
21
+ readSnapshot() {
22
+ const constants = record(value.getConstants(), "React Native I18nManager constants");
23
+ const nativeLocale = constants.localeIdentifier;
24
+ return {
25
+ isRTL: constants.isRTL,
26
+ localeTag: typeof nativeLocale === "string" && nativeLocale.length > 0
27
+ ? nativeLocale
28
+ : readDefaultLocale(),
29
+ swapsLeftAndRightInRTL: constants.doLeftAndRightSwapInRTL,
30
+ };
31
+ },
32
+ });
33
+ }
34
+ //# sourceMappingURL=react-native-adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-native-adapter.js","sourceRoot":"","sources":["../src/react-native-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,GAEzB,MAAM,YAAY,CAAC;AAQpB,SAAS,MAAM,CACb,KAAc,EACd,IAAY;IAEZ,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACxE,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,qBAAqB,CAAC,CAAC;IACpD,CAAC;IACD,OAAO,KAA0C,CAAC;AACpD,CAAC;AAED,SAAS,aAAa;IACpB,OAAO,IAAI,CAAC,cAAc,EAAE,CAAC,eAAe,EAAE,CAAC,MAAM,CAAC;AACxD,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,mCAAmC,CACjD,KAAmC,EACnC,oBAAyC,aAAa;IAEtD,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,iCAAiC,CAAC,CAAC;IAChE,IAAI,OAAO,MAAM,CAAC,YAAY,KAAK,UAAU,EAAE,CAAC;QAC9C,MAAM,IAAI,SAAS,CACjB,8DAA8D,CAC/D,CAAC;IACJ,CAAC;IACD,IAAI,OAAO,iBAAiB,KAAK,UAAU,EAAE,CAAC;QAC5C,MAAM,IAAI,SAAS,CAAC,2CAA2C,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,wBAAwB,CAAC;QAC9B,YAAY;YACV,MAAM,SAAS,GAAG,MAAM,CACtB,KAAK,CAAC,YAAY,EAAE,EACpB,oCAAoC,CACrC,CAAC;YACF,MAAM,YAAY,GAAG,SAAS,CAAC,gBAAgB,CAAC;YAChD,OAAO;gBACL,KAAK,EAAE,SAAS,CAAC,KAAK;gBACtB,SAAS,EACP,OAAO,YAAY,KAAK,QAAQ,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC;oBACzD,CAAC,CAAC,YAAY;oBACd,CAAC,CAAC,iBAAiB,EAAE;gBACzB,sBAAsB,EAAE,SAAS,CAAC,uBAAuB;aAC1D,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { LocalizationSnapshot } from "./index.js";
2
+ /** Reads the pinned startup locale without evaluating I18nManager.js. */
3
+ export declare function getReactNativeLocalizationSnapshot(): LocalizationSnapshot;
4
+ export type { LocalizationSnapshot, NativeLayoutDirection } from "./index.js";
5
+ //# sourceMappingURL=react-native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-native.d.ts","sourceRoot":"","sources":["../src/react-native.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAmBvD,yEAAyE;AACzE,wBAAgB,kCAAkC,IAAI,oBAAoB,CASzE;AAED,YAAY,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { get, getEnforcing, } from "react-native/Libraries/TurboModule/TurboModuleRegistry";
2
+ import { assertVerifiedReactNativePlatform } from "@solidnative-dev/react-native-compat";
3
+ import { readReactNativeLocalizationSnapshot, } from "./react-native-adapter.js";
4
+ let snapshot;
5
+ function assertPlatform() {
6
+ assertVerifiedReactNativePlatform(getEnforcing("PlatformConstants").getConstants(), "Localization");
7
+ }
8
+ /** Reads the pinned startup locale without evaluating I18nManager.js. */
9
+ export function getReactNativeLocalizationSnapshot() {
10
+ if (snapshot !== undefined)
11
+ return snapshot;
12
+ assertPlatform();
13
+ const module = get("I18nManager");
14
+ if (module === null) {
15
+ throw new Error("The React Native I18nManager TurboModule is unavailable.");
16
+ }
17
+ snapshot = readReactNativeLocalizationSnapshot(module);
18
+ return snapshot;
19
+ }
20
+ //# sourceMappingURL=react-native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-native.js","sourceRoot":"","sources":["../src/react-native.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,YAAY,GACb,MAAM,wDAAwD,CAAC;AAChE,OAAO,EAAE,iCAAiC,EAAE,MAAM,sCAAsC,CAAC;AAGzF,OAAO,EACL,mCAAmC,GAEpC,MAAM,2BAA2B,CAAC;AAMnC,IAAI,QAA0C,CAAC;AAE/C,SAAS,cAAc;IACrB,iCAAiC,CAC/B,YAAY,CAA0B,mBAAmB,CAAC,CAAC,YAAY,EAAE,EACzE,cAAc,CACf,CAAC;AACJ,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,kCAAkC;IAChD,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC;IAC5C,cAAc,EAAE,CAAC;IACjB,MAAM,MAAM,GAAG,GAAG,CAA+B,aAAa,CAAC,CAAC;IAChE,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC9E,CAAC;IACD,QAAQ,GAAG,mCAAmC,CAAC,MAAM,CAAC,CAAC;IACvD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,51 @@
1
1
  {
2
2
  "name": "@solidnative-dev/localization",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0-beta.0",
4
+ "type": "module",
5
+ "description": "Validated startup locale and native layout-direction state.",
6
+ "license": "MIT",
7
+ "homepage": "https://solidnative.dev",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/solid-native/solid-native.git",
11
+ "directory": "packages/localization"
12
+ },
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "engines": {
17
+ "node": "^22.13.0 || ^24.3.0 || >=26.0.0"
18
+ },
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "default": "./dist/index.js"
23
+ },
24
+ "./react-native": {
25
+ "types": "./dist/react-native.d.ts",
26
+ "default": "./dist/react-native.js"
27
+ }
28
+ },
29
+ "files": [
30
+ "dist/index.d.ts",
31
+ "dist/index.d.ts.map",
32
+ "dist/index.js",
33
+ "dist/index.js.map",
34
+ "dist/react-native.d.ts",
35
+ "dist/react-native.d.ts.map",
36
+ "dist/react-native.js",
37
+ "dist/react-native.js.map",
38
+ "dist/react-native-adapter.d.ts",
39
+ "dist/react-native-adapter.d.ts.map",
40
+ "dist/react-native-adapter.js",
41
+ "dist/react-native-adapter.js.map"
42
+ ],
43
+ "dependencies": {
44
+ "@solidnative-dev/react-native-compat": "0.1.0-beta.0"
45
+ },
46
+ "scripts": {
47
+ "build": "tsc -p tsconfig.json",
48
+ "check": "tsc -p tsconfig.json --noEmit",
49
+ "test": "pnpm build && node --test test/*.test.mjs"
50
+ }
6
51
  }