feat(quick-261016-0fm): admin language follows the stored preference
- principalFrom sets PreferredLocale from metadata admin_locale; personal API token principals clear it, so token clients keep the request locale - the guarded admin group runs locale.from-principal after the backend guard, overriding the LocaleResolver or Accept-Language locale - GET /lang honours a supported ?locale= and reports meta.locales (cabana.LangEnvelope, cabana.LangMeta) - Docker test for the override, refusals and /lang; docs and OpenAPI
This commit is contained in:
@@ -186,13 +186,28 @@ func AdminRefresh() {}
|
||||
// forms (D-20).
|
||||
type LangBundle map[string]MessageForms
|
||||
|
||||
// LangMeta is the meta object of GET /lang.
|
||||
type LangMeta struct {
|
||||
// Locale is the locale the bundle resolved to.
|
||||
Locale string `json:"locale"`
|
||||
// Locales are the supported admin locales, sorted.
|
||||
Locales []string `json:"locales"`
|
||||
}
|
||||
|
||||
// LangEnvelope is the GET /lang answer.
|
||||
type LangEnvelope struct {
|
||||
Data LangBundle `json:"data"`
|
||||
Meta LangMeta `json:"meta"`
|
||||
}
|
||||
|
||||
// AdminLang documents GET /lang.
|
||||
//
|
||||
// @Summary Admin UI strings
|
||||
// @Description Every backend::lang key as CLDR plural forms for the Accept-Language locale, over the fallback locale's keys. Public: the login screen loads it before signing in. meta.locale is the locale the bundle resolved to.
|
||||
// @Description Every backend::lang key as CLDR plural forms for the request locale, over the fallback locale's keys. The locale query parameter selects one of the supported admin locales instead (the SPA sends the admin's chosen language); a value that is not one of them is ignored. Public: the login screen loads it before signing in. meta.locale is the locale the bundle resolved to and meta.locales lists the supported admin locales.
|
||||
// @Tags admin
|
||||
// @Produce json
|
||||
// @Success 200 {object} Envelope[LangBundle]
|
||||
// @Param locale query string false "A supported admin locale (one of meta.locales); other values are ignored"
|
||||
// @Success 200 {object} LangEnvelope
|
||||
// @Router /lang [get]
|
||||
func AdminLang() {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user