Commit 2b03c2e6 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #47948 from allencloud/remove-unused-code-in-loadSystemLanguage

Automatic merge from submit-queue fix system language judging bug in loadSystemLanguage Signed-off-by: 's avatarallencloud <allen.sun@daocloud.io> **What this PR does / why we need it**: This PR removes some unused code in loadSystemLanguage. Since in code `pieces := strings.Split(langStr, ".")`, even `langStr` is an empty string, `piece` is a slice with one element of empty string, so there is no chance that len(pieces) == 0. According to these, I think it is OK to remove the unused code in loadSystemLanguage. According to the discuss we had, finally we decided to use a more accurate way to change the code, using `if len(pieces) != 1` to make the decision. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes # NONE **Special notes for your reviewer**: NONE **Release note**: ```release-note NONE ```
parents b8f1bb41 2e79f6c6
......@@ -49,12 +49,12 @@ var knownTranslations = map[string][]string{
func loadSystemLanguage() string {
langStr := os.Getenv("LANG")
if langStr == "" {
glog.V(3).Infof("Couldn't find the LANG environment variable, defaulting to en-US")
glog.V(3).Infof("Couldn't find the LANG environment variable, defaulting to en_US")
return "default"
}
pieces := strings.Split(langStr, ".")
if len(pieces) == 0 {
glog.V(3).Infof("Unexpected system language (%s), defaulting to en-US", langStr)
if len(pieces) != 2 {
glog.V(3).Infof("Unexpected system language (%s), defaulting to en_US", langStr)
return "default"
}
return pieces[0]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment