1
// Copyright 2013 ChaiShushan <chaishushan{AT}gmail.com>. All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
12
func getDefaultLocale() string {
13
if v := os.Getenv("LC_MESSAGES"); v != "" {
14
return simplifiedLocale(v)
16
if v := os.Getenv("LANG"); v != "" {
17
return simplifiedLocale(v)
22
func simplifiedLocale(lang string) string {
23
// en_US/en_US.UTF-8/zh_CN/zh_TW/el_GR@euro/...
24
if idx := strings.Index(lang, ":"); idx != -1 {
27
if idx := strings.Index(lang, "@"); idx != -1 {
30
if idx := strings.Index(lang, "."); idx != -1 {
33
return strings.TrimSpace(lang)