forked from any-code/riot-i18n
-
Notifications
You must be signed in to change notification settings - Fork 0
/
i1-8n.tag
40 lines (30 loc) · 797 Bytes
/
i1-8n.tag
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<i1-8n>
<style scoped>
:scope {
display: inline-block;
}
.original {
display: none;
}
</style>
<span ref="localised" name="localised"></span>
<span ref="original" name="original" class="original"><yield /></span>
<script>
this.mixin('i18n')
this.i18n.on('update', function() {
this.update()
}.bind(this))
this.on('mount', function() {
// Did riot use V3 refs?
this.hasRefs = this.refs != undefined
this.localise()
})
this.on('update', function() {
this.localise()
})
this.localise = function() {
var refs = this.hasRefs ? this.refs : this;
refs.localised.innerHTML = this.i18n.localise(refs.original.innerHTML);
}
</script>
</i1-8n>