This is my app.js
app.js
$translateProvider.registerAvailableLanguageKeys(['en_US','es_ES', 'pt_PT','fr_FR','de_DE','ja_JP','it_IT'], {
'en-*':'en_US',
'es-*':'es_ES',
'pt-*':'pt_PT',
'fr-*':'fr_FR',
'de-*':'de_DE',
'ja-*':'ja_JP',
'it-*':'it_IT',
'*':'en_US'
})
}
]
keys (['en_US','es_ES', 'pt_PT','fr_FR','de_DE','ja_JP','it_IT']
and
'en-*':'en_US',
'es-*':'es_ES',
'pt-*':'pt_PT',
'fr-*':'fr_FR',
'de-*':'de_DE',
'ja-*':'ja_JP',
'it-*':'it_IT',
'*':'en_US'
How can i get these keys from a global object from outside javascript file since im repeating these keys in other places.
My javascript file has these two arrays.
keys.js
var keys=['en_US','es_ES', 'pt_PT','fr_FR','de_DE','ja_JP','it_IT']
var commonKeys=['en-*','es-*', 'pt-*','fr-*','de-*','ja-*','it-*', '*']
How can i use this javascript file to get iterate key value pair in app.js and other places instead of repeating it everywhere.
If your goal is to create an object with key-value pairs from the two arrays you could do the following:
Or, if you are ok with using a third-party library, you could include underscore.js and use the _.object function like this:
In both cases the output of the js console would be