feat: add Device localization support#23
Conversation
|
Linked PR: NativePHP/mobile-device#1 |
Return device locale, language, region, timezone, currency, and preferred language via the Device.GetLocale bridge function as an immutable Localization data object.
77e8a2b to
f29767d
Compare
When two or more locales are configured via `nativephp.locales`, the build now injects CFBundleLocalizations into Info.plist (iOS) and generates locales_config.xml with a manifest reference (Android). This fixes iOS reporting incorrect Locale.current and enables the per-app language picker on Android 13+.
|
This adds build-time locale support to go alongside the What it does: On iOS, if your app doesn't declare On Android, How to use it: Add the locales your app supports to 'locales' => ['en', 'fr', 'es', 'de'],If the array has fewer than two entries (or is empty), nothing happens — it's fully opt-in and a single locale is a no-op on both platforms. What changed:
|
|
Wouldn't |
|
@simonhamp Tested this — without The build-time config tells iOS "this app supports these languages" which unblocks correct locale reporting for everything inside the app. Without it, the App Store listing also only shows the development region language, and the app won't appear in the iOS 16+ per-app language settings. On Android,
|
|
Also worth noting — as we lean more into native UI elements (Edge components, native navigation, etc.), the app needs to be locale-aware at the native layer, not just in PHP. Having the device report the correct locale is foundational for that. |
|
I'm not sure that's a fair test yet. We don't have I do agree that having it at the native layer does also make sense |

Summary
localization()method toDevicereturning an immutableLocalizationvalue objectDevice.GetLocalebridge functionLocalizationdata object underNative\Mobile\DatanamespaceDevicefacade docblock