Documentation ¶
Overview ¶
//////////////////////////////////////////////////////////////////// request.go ////////////////////////////////////////////////////////////////////
Index ¶
- func GetLangCode(r *http.Request, supportedLangCodes []string, ...) string
- func GetLangCodeFromAcceptLanguage(r *http.Request) string
- func GetLangCodeFromCookie(r *http.Request, supportedLangCodes []string, cookieName string) string
- func GetLangCodeFromUrlQuery(r *http.Request, supportedLangCodes []string, urlQueryKey string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetLangCode ¶
func GetLangCode(r *http.Request, supportedLangCodes []string, defaultLangCode, urlQueryKey, cookieName string) string
//////////////////////////////////////////////////////////////////// Get the lang code with 2 digits. Resolve a language code in the following priority order:
- URL parameter (such as "lang=en")
- Cookie (such as "lang")
- HTTP Header ("Accept-Language")
When it could not resolve a language code, will be returned defaultLangCode such as "en". ////////////////////////////////////////////////////////////////////
func GetLangCodeFromAcceptLanguage ¶
//////////////////////////////////////////////////////////////////// Get the lang code with 2 digits from HTTP Header ("Accept-Language"). ////////////////////////////////////////////////////////////////////
func GetLangCodeFromCookie ¶
//////////////////////////////////////////////////////////////////// Get the lang code with 2 digits from cookie. ////////////////////////////////////////////////////////////////////
func GetLangCodeFromUrlQuery ¶
func GetLangCodeFromUrlQuery(r *http.Request, supportedLangCodes []string, urlQueryKey string) string
//////////////////////////////////////////////////////////////////// Get the lang code with 2 digits from URL query. ////////////////////////////////////////////////////////////////////
Types ¶
This section is empty.