Refactoring api to use translations (chunk 1)

- Add spanish translations
- Files in order by name from admin to export
- Does not include api templates and tests
- Fix web_test to load translations
- Fix i18n to fallback to DEFAULT_LOCALE if no system locale found
Этот коммит содержится в:
Elias Nahum
2016-01-21 10:07:29 -03:00
родитель 9f526555df
Коммит 507fbeb068
11 изменённых файлов: 945 добавлений и 140 удалений

Просмотреть файл

@@ -36,7 +36,10 @@ func InitTranslations() {
func GetTranslationsBySystemLocale() i18n.TranslateFunc {
locale := model.DEFAULT_LOCALE
if userLanguage, err := jibber_jabber.DetectLanguage(); err == nil {
locale = userLanguage
// only set the system locale if is supported, fallback to DEFAULT_LOCALE
if contains(userLanguage) {
locale = userLanguage
}
}
if locales[locale] == "" {
@@ -138,3 +141,12 @@ func getTranslationsAndLocale(w http.ResponseWriter, r *http.Request) (i18n.Tran
SetLocaleCookie(w, model.DEFAULT_LOCALE, 10)
return translations, model.DEFAULT_LOCALE
}
func contains(l string) bool {
for _, a := range locales {
if a == l {
return true
}
}
return false
}