imba-localization 0.3.7 → 0.3.8
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/localization.imba +11 -1
- package/package.json +1 -1
package/localization.imba
CHANGED
|
@@ -5,6 +5,8 @@ export class Localization
|
|
|
5
5
|
languages = {}
|
|
6
6
|
preferred = (window..navigator..language || 'en-US').slice(0, 2)
|
|
7
7
|
default
|
|
8
|
+
ready = false
|
|
9
|
+
errors = {}
|
|
8
10
|
|
|
9
11
|
def constructor url, dft = 'en'
|
|
10
12
|
default = dft
|
|
@@ -15,10 +17,16 @@ export class Localization
|
|
|
15
17
|
|
|
16
18
|
return new Proxy self, {
|
|
17
19
|
get: do(target, p, receiver)
|
|
20
|
+
if !ready
|
|
21
|
+
console.log("Request before localization is ready", p)
|
|
22
|
+
return
|
|
23
|
+
return if errors[p]
|
|
18
24
|
return Reflect.get(target, p, receiver) if self[p]
|
|
19
25
|
return target.languages[p] if target.languages[p]
|
|
20
26
|
return target.languages[active][p] if target.languages[active] and target.languages[active][p]
|
|
21
|
-
|
|
27
|
+
if !errors[p]
|
|
28
|
+
onerror('no_localization_key', p) if onerror isa Function
|
|
29
|
+
errors[p] = true
|
|
22
30
|
return ''
|
|
23
31
|
}
|
|
24
32
|
|
|
@@ -36,6 +44,7 @@ export class Localization
|
|
|
36
44
|
else
|
|
37
45
|
console.log('There is no Localization for the default language', default)
|
|
38
46
|
return
|
|
47
|
+
ready = true
|
|
39
48
|
onready! if onready isa Function
|
|
40
49
|
onchange(active) if onchange isa Function
|
|
41
50
|
|
|
@@ -50,6 +59,7 @@ export class Localization
|
|
|
50
59
|
if window.localStorage.getItem('imba-localization') != name
|
|
51
60
|
window.localStorage.setItem('imba-localization', name)
|
|
52
61
|
onchange(name) if onchange isa Function
|
|
62
|
+
errors = {}
|
|
53
63
|
|
|
54
64
|
export const path-arrow-down = <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">
|
|
55
65
|
|