Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When determining language from HTTP_ACCEPT_LANGUAGE, also try base language only #1402

Merged
merged 1 commit into from
Apr 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

1. [](#bugfix)
* Fixed a bad method signature causing warning when running tests on `GPMTest` object
* When determining language from `HTTP_ACCEPT_LANGUAGE`, also try base language only

# v1.2.0
## 03/31/2017
Expand Down
9 changes: 9 additions & 0 deletions system/src/Grav/Common/Language/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,15 @@ public function setActiveFromUri($uri)
}
}

// repeat if not found, try base language only - fixes Safari sending the language code always
// with a locale (e.g. it-it or fr-fr)
foreach ($preferred as $lang) {
$lang = substr($lang, 0, 2);
if ($this->validate($lang)) {
$this->active = $lang;
break;
}
}
}
}
}
Expand Down