Skip to content

Commit

Permalink
feat(Message): translate message values
Browse files Browse the repository at this point in the history
  • Loading branch information
ayZagen committed May 4, 2020
1 parent 364b977 commit 18aa3e6
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions src/ui/components/PMessage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { h, defineComponent } from 'vue';
import { h, defineComponent, withDirectives } from 'vue';

import { i18n } from '../directives/i18n';
import { Colorable } from '../mixins';

function generateMessageDiv(messages: any){
Expand All @@ -9,23 +10,33 @@ function generateMessageDiv(messages: any){
if(Array.isArray(messages)){

const messageNodes = messages.map( (message, key) => {
return h('div', {
class: 'pa__messages__message',
}, message)
return withDirectives(
h('div', {
class: 'pa__messages__message',
}),
[[i18n, message]]
)
})
return messageNodes
}else if( messages instanceof Set) {
const nodes = []
for (const value of messages.values()) {
nodes.push(h('div', {
class: 'pa__messages__message',
}, value))
nodes.push(
withDirectives(
h('div', {
class: 'pa__messages__message',
}),
[[i18n, value]]
)
)
}
return nodes
}else{
return h('div', {
return withDirectives(h('div', {
class: 'pa__messages__message',
}, messages)
}),
[[i18n, messages]]
)
}

}
Expand Down

0 comments on commit 18aa3e6

Please sign in to comment.