mirror of https://github.com/k3s-io/k3s
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: allencloud <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 ```pull/6/head
commit
2b03c2e6df
|
@ -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]
|
||||
|
|
Loading…
Reference in New Issue