I have been working on an application where i need to redirect user to the selected pages that are translated in the respective locale. I have been getting a list of languages from the backend. I need to convert the languages in the language code. For example:
var languageName = ['English', 'Japnese', 'Chinese']; Need to convert them to
['en-us','ja-jp','zh-cn']; How can i convert the language name to language locale or country code..
.map()or just aforloop maybe?en-usoren-uk? Which dialect of Chinese is "Chinese" exactly? If you're expecting some magic library or API that does this conversion for you, you'd probably fail in some way or another when it comes to these questions. You'll kinda need to define this mapping yourself.