Skip to content

Localize Middleware language-detection bug #1140

@lianguan

Description

@lianguan

MiddleWare/Localize line 60:

foreach ($supportedLanguages as $language) {
            $language = substr($language, 0, 2);

            if (isset($this->langs[$language])) {
                $userLanguage = $language;
                break;
            }
        }

the code above have two bugs:

  1. It dosn't distinguish zh-CN and zh-TW.
  2. both language package of zh-CN and zh-TW contain '-', but the spliter of browser's accept-language is '_'.

so, I think the right code is:

$language = str_replace('_', '-', $language);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions