Skip to content

Instantly share code, notes, and snippets.

@marekkaczkowski
Created May 24, 2018 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marekkaczkowski/6e4ed432439c4005367b71279d2c7edf to your computer and use it in GitHub Desktop.
Save marekkaczkowski/6e4ed432439c4005367b71279d2c7edf to your computer and use it in GitHub Desktop.
Data normalization and internationalization with vue-18n
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