Skip to content

armgit / Piik

Public Imported from GitHub
0

Free, open-source screen sharing for private live streams with friends. Watch together in a browser or self-host Piik. 免费开源的私密屏幕共享,支持游戏直播、一起看电影与自部署。

696 B
Raw Blame
//go:build !windows

package app

import (
	"os"
	"strings"
)

func defaultConsoleLanguage() string {
	var locale string
	for _, name := range []string{"LC_ALL", "LC_MESSAGES", "LANG"} {
		if locale = os.Getenv(name); locale != "" {
			break
		}
	}
	// GNU's message-language preference applies only outside the C/POSIX locale.
	if locale == "" || locale == "C" || locale == "POSIX" || strings.HasPrefix(locale, "C.") {
		return "en"
	}
	if preferred, _, _ := strings.Cut(os.Getenv("LANGUAGE"), ":"); preferred != "" {
		locale = preferred
	}
	if end := strings.IndexAny(locale, "_-.@"); end >= 0 {
		locale = locale[:end]
	}
	if strings.EqualFold(locale, "zh") {
		return "zh"
	}
	return "en"
}