imba-localization 0.2.5 → 0.2.6
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 +9 -9
- package/localization.imba +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ A lightweight Imba module for loading and handling JSON-based localization files
|
|
|
11
11
|
- 🧠 **Intuitive access** - Proxy-based access to translation strings
|
|
12
12
|
- 📡 **Event handling** - Support for `onready`, `onchange`, and `onerror` events
|
|
13
13
|
- 🚀 **Simple integration** - Easy to use in any Imba-based web application
|
|
14
|
-
- 🧩 **`<
|
|
14
|
+
- 🧩 **`<LocalizationSelector>`** - Plug and play component for switching languages
|
|
15
15
|
|
|
16
16
|
## 📘 Notes
|
|
17
17
|
|
|
@@ -143,18 +143,18 @@ new LocalizationState(url, default = 'en')
|
|
|
143
143
|
|
|
144
144
|
## 🧩 Components
|
|
145
145
|
|
|
146
|
-
###
|
|
146
|
+
### LocalizationSelector
|
|
147
147
|
|
|
148
148
|
A customizable dropdown component that allows users to select from available in the JSON localization file languages.
|
|
149
149
|
|
|
150
150
|
```imba
|
|
151
|
-
import { LocalizationState,
|
|
151
|
+
import { LocalizationState, LocalizationSelector } from 'imba-localization'
|
|
152
152
|
const loc = new LocalizationState("path/to/lang.json", "en")
|
|
153
153
|
|
|
154
154
|
# In your UI component
|
|
155
155
|
tag AppHeader
|
|
156
156
|
<self>
|
|
157
|
-
<
|
|
157
|
+
<LocalizationSelector state=loc> # state attribute is mandatory
|
|
158
158
|
```
|
|
159
159
|
|
|
160
160
|
To make this component work as intended, your JSON file will need some adjustments. For each supported language you will need to define the display name for the language and also the country code for the flag to show (for example `en` language is used in `gb` and `us` countries):
|
|
@@ -209,11 +209,11 @@ css
|
|
|
209
209
|
LanguageSelector can be easily customized through CSS and Imba tag (class) inheritance. Here how the above classes can be adjusted via the inheritance:
|
|
210
210
|
|
|
211
211
|
```imba
|
|
212
|
-
import { LocalizationState,
|
|
212
|
+
import { LocalizationState, LocalizationSelector } from 'imba-localization'
|
|
213
213
|
const loc = new LocalizationState("path/to/lang.json", "en")
|
|
214
214
|
|
|
215
215
|
# Create an inheritent class
|
|
216
|
-
tag Languages <
|
|
216
|
+
tag Languages < LocalizationSelector
|
|
217
217
|
css
|
|
218
218
|
$ease: 1s
|
|
219
219
|
.menu-item rd:2px
|
|
@@ -230,7 +230,7 @@ tag MyApp
|
|
|
230
230
|
You can redefine the collection of flag icons through the `icons` attribute:
|
|
231
231
|
|
|
232
232
|
```imba
|
|
233
|
-
<
|
|
233
|
+
<LocalizationSelector icons='https://flagicons.lipis.dev/flags/4x3/##.svg'>
|
|
234
234
|
```
|
|
235
235
|
There are many flag collections out there:
|
|
236
236
|
- https://kapowaz.github.io/square-flags/flags/##.svg (default one)
|
|
@@ -253,12 +253,12 @@ tag SomeIcon
|
|
|
253
253
|
<path d="...">
|
|
254
254
|
|
|
255
255
|
|
|
256
|
-
<
|
|
256
|
+
<LocalizationSelector arrow=SomeIcon>
|
|
257
257
|
```
|
|
258
258
|
|
|
259
259
|
### ArrowIcon
|
|
260
260
|
|
|
261
|
-
The default arrow icon used in the
|
|
261
|
+
The default arrow icon used in the LocalizationSelector component is available as a separate icon (in case for some reason you don't want to use [imba-phosphor-icons](https://www.npmjs.com/package/imba-phosphor-icons) package by Sindre).
|
|
262
262
|
|
|
263
263
|
```imba
|
|
264
264
|
import {ArrowIcon} from 'imba-localization'
|
package/localization.imba
CHANGED
|
@@ -56,7 +56,7 @@ export tag ArrowIcon
|
|
|
56
56
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
|
|
57
57
|
<path d="M213.66,165.66a8,8,0,0,1-11.32,0L128,91.31,53.66,165.66a8,8,0,0,1-11.32-11.32l80-80a8,8,0,0,1,11.32,0l80,80A8,8,0,0,1,213.66,165.66Z">
|
|
58
58
|
|
|
59
|
-
export tag
|
|
59
|
+
export tag LocalizationSelector
|
|
60
60
|
state
|
|
61
61
|
icons = "https://kapowaz.github.io/square-flags/flags/##.svg"
|
|
62
62
|
#dropdown = false
|