@ordernow/capacitor-language 1.0.0 → 1.0.2
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 +26 -2
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -28,8 +28,32 @@ npx cap sync
|
|
|
28
28
|
|
|
29
29
|
### iOS
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
Declare your app's languages in `ios/App/App/Info.plist` with these keys:
|
|
32
|
+
|
|
33
|
+
| Key | Type | Value |
|
|
34
|
+
| --- | --- | --- |
|
|
35
|
+
| `CFBundleLocalizations` | Array of strings | **Required.** Every language your app supports, as iOS language identifiers (`en`, `vi`, `zh-Hans`, `pt-BR`…), main language first. iOS only shows Settings → App → Language when it lists more than one language, and only applies a listed language. Without it, `set` has no visible effect. |
|
|
36
|
+
| `CFBundleDevelopmentRegion` | String | The language iOS falls back to when none of the user's languages is listed, usually your main language. Capacitor's template already has it (`en`); change it if your main language differs. |
|
|
37
|
+
|
|
38
|
+
The codes you pass to `set` must match the `CFBundleLocalizations` entries exactly: Simplified Chinese is `zh-Hans`, not `zh`. Map your web locale codes when they differ.
|
|
39
|
+
|
|
40
|
+
For example, an app in English, Vietnamese, Simplified Chinese and Korean:
|
|
41
|
+
|
|
42
|
+
```xml
|
|
43
|
+
<key>CFBundleDevelopmentRegion</key>
|
|
44
|
+
<string>en</string>
|
|
45
|
+
<key>CFBundleLocalizations</key>
|
|
46
|
+
<array>
|
|
47
|
+
<string>en</string>
|
|
48
|
+
<string>vi</string>
|
|
49
|
+
<string>zh-Hans</string>
|
|
50
|
+
<string>ko</string>
|
|
51
|
+
</array>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
- **Nothing else to add.** No `.lproj` folders, no `AppDelegate` or view controller changes: `npx cap sync ios` installs the pod and registers the plugin.
|
|
55
|
+
- **Reading the language back:** [`@capacitor/device`](https://capacitorjs.com/docs/apis/device) `getLanguageCode()` / `getLanguageTag()` return the language set here, and the one picked in Settings.
|
|
56
|
+
- iOS reads the language at launch: system UI follows `set` from the next launch. When the user changes it in Settings, iOS relaunches the app.
|
|
33
57
|
|
|
34
58
|
## Usage
|
|
35
59
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ordernow/capacitor-language",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Set the iOS per-app language (Settings → App → Language) from Capacitor apps",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -46,7 +46,8 @@
|
|
|
46
46
|
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
|
|
47
47
|
"clean": "rimraf ./dist",
|
|
48
48
|
"watch": "tsc --watch",
|
|
49
|
-
"prepare": "npm run build"
|
|
49
|
+
"prepare": "npm run build",
|
|
50
|
+
"test": "vitest run test"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
53
|
"@capacitor/core": "^7.4.4",
|
|
@@ -60,7 +61,8 @@
|
|
|
60
61
|
"rimraf": "^6.1.0",
|
|
61
62
|
"rollup": "^4.53.2",
|
|
62
63
|
"swiftlint": "^2.0.0",
|
|
63
|
-
"typescript": "^5.9.3"
|
|
64
|
+
"typescript": "^5.9.3",
|
|
65
|
+
"vitest": "^5.0.5"
|
|
64
66
|
},
|
|
65
67
|
"peerDependencies": {
|
|
66
68
|
"@capacitor/core": ">=6.0.0 <9.0.0"
|