Created
May 24, 2018 12:52
-
-
Save marekkaczkowski/6e4ed432439c4005367b71279d2c7edf to your computer and use it in GitHub Desktop.
Data normalization and internationalization with vue-18n
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const raw = [ | |
{u000011: { "name": "Foo" }}, | |
{u000012: { "name": "Boo" }} | |
]; | |
const n11n = raw.map(item => { | |
let id = String(Object.keys(item)[0]) | |
let key = String(Object.keys(item[id])) | |
return { | |
id: id, | |
label: `$t(${key.toUpperCase()})`, | |
value: item[id][key] | |
} | |
}); | |
console.log('RAW', raw); | |
console.log('N11N', n11n); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment