0

My users need to select a country as part of the signup, so I have added a list of countries to my translation file. e.g. countries: { AF: 'Afghanistan', AL: 'Albania', AM: 'Armenia', AN: 'Netherlands Antilles', AW: 'Aruba', MF: 'Saint Martin (French part)', AO: 'Angola', AQ: 'Antarctica', AR: 'Argentina', AU: 'Australia', CC: 'Cocos (Keeling) Islands', CX: 'Christmas Island', KI: 'Kiribati', NF: 'Norfolk Island', ... }

However, when I try to retrieve the list of countries (so that I can enumerate them) I get the error [vue-i18n] Value of key 'countries' is not a string!. I'm assuming that I'm not the first to try to do this.

Is there a way that you've found to do this, or am I coming at this from the wrong direction by trying to use vue-i18n to do this? Thanks...

Zagreus
  • 207
  • 2
  • 8

1 Answers1

0

You should separate between the country the user is coming from and the language your website should be translated to. There are so many country's out there so you can hardly provide a translation for every one of them. Usually you have 2-3 languages/translations for your website. I suggest to separate user data from translation. Let your users choose the language of the website in a dropdown (and preselect it via browser language detection).

And yes, the locale should be a string and it would be best to choose language locale codes which corresponds with what you get from navigator.language. The most common use case is to use the two lower case characters like 'en'

Hexodus
  • 12,361
  • 6
  • 53
  • 72