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
Kubernetes Submit Queue 2017-07-12 03:42:10 -07:00 committed by GitHub
commit 2b03c2e6df
1 changed files with 3 additions and 3 deletions

View File

@ -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]