I am localizing my app and have a few questions regarding best practices for handling locales, especially for translations and date formatting:
-
What is the best way to determine the initial locale for a user? The easiest approach seems to be checking
navigator.language
and decide by the browser settings. However, for users from smaller countries (like myself), it’s common to use English for the browser but still prefer their native language on websites. Deciding based on user location seems unreliable as latitude and longitude are not tied to language preferences. Anything else besides those two approaches feels like over engineering the problem. -
Is it common to use different locales for translations and dates?
User might prefer the en-US locale for translations but keep his country date format to avoid confusion with formats likeMM/DD/YYYY
vsDD.MM.YYYY
(which is used in bigger part of Europe).
So far it looks like the best approach is to keep the locales unified for dates and translations at the expense of causing confusion to some users and just stick to navigator.language
as default and set the locale on manual language selection by the user.
Maybe someone with better overview about the topic can provide better solution.