imba-localization 0.2.4 → 0.2.5
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 +8 -8
- package/localization.imba +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -54,10 +54,10 @@ Add this to your HTML head to load the localization file simultaneously with you
|
|
|
54
54
|
|
|
55
55
|
```imba
|
|
56
56
|
# app.imba
|
|
57
|
-
import {
|
|
57
|
+
import { LocalizationState } from 'imba-localization'
|
|
58
58
|
|
|
59
59
|
# Create an instance with the JSON URL and optional default language
|
|
60
|
-
const loc = new
|
|
60
|
+
const loc = new LocalizationState("path/to/lang.json", "en")
|
|
61
61
|
|
|
62
62
|
# Set up event handlers
|
|
63
63
|
loc.onready = do
|
|
@@ -69,7 +69,7 @@ loc.onready = do
|
|
|
69
69
|
console.log loc['user']['profile'] # Accessing nested properties
|
|
70
70
|
|
|
71
71
|
loc.onerror = do(error, details)
|
|
72
|
-
# The
|
|
72
|
+
# The LocalizationState object can return following types of errors:
|
|
73
73
|
# 'no_localization_file' - if there were a problem when downloading JSON file
|
|
74
74
|
# 'no_default_localization' - if there is no localization in the file for the default language
|
|
75
75
|
# 'no_localization_key' - if there is no requiered (from the interface) key in the file
|
|
@@ -123,7 +123,7 @@ Your localization file should follow this format:
|
|
|
123
123
|
### Constructor
|
|
124
124
|
|
|
125
125
|
```imba
|
|
126
|
-
new
|
|
126
|
+
new LocalizationState(url, default = 'en')
|
|
127
127
|
```
|
|
128
128
|
|
|
129
129
|
- `url`: Path to your JSON localization file
|
|
@@ -148,8 +148,8 @@ new Localization(url, default = 'en')
|
|
|
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 {
|
|
152
|
-
const loc = new
|
|
151
|
+
import { LocalizationState, LanguageSelector } from 'imba-localization'
|
|
152
|
+
const loc = new LocalizationState("path/to/lang.json", "en")
|
|
153
153
|
|
|
154
154
|
# In your UI component
|
|
155
155
|
tag AppHeader
|
|
@@ -209,8 +209,8 @@ 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 {
|
|
213
|
-
const loc = new
|
|
212
|
+
import { LocalizationState, LanguageSelector } from 'imba-localization'
|
|
213
|
+
const loc = new LocalizationState("path/to/lang.json", "en")
|
|
214
214
|
|
|
215
215
|
# Create an inheritent class
|
|
216
216
|
tag Languages < LanguageSelector
|
package/localization.imba
CHANGED