suhaibkhan / messageResource.js

Javascript library for loading and using message resource property files.
MIT License
22 stars 22 forks source link

Locale (e.g. es_ES) should fall back to parent locale (e.g. es) when child locale not found #9

Open ip2k opened 9 years ago

ip2k commented 9 years ago

[ more context: http://stackoverflow.com/questions/5047298/detecting-browser-locales-languages-and-generating-output ]

Summary of the problem: a user's browser presents a locale which site translations are not available for, and a more appropriate locale than the default is available without their specific e.g. dialect. In other words, if a user comes with locale set to es_ES and we only have es_MX and es, es should be served instead of the default locale.

I was wondering what the best way to implement this would be. I was thinking that it could be if the ajax fails, put some logic in to try the file name with the underscore and everything after removed, but I was also thinking about how to then name that locale appropriately within the messageResource.js API.