Skip to content

Commit

Permalink
Merge branch 'master' into v1
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrestoffe committed Dec 8, 2018
2 parents b531a52 + b9a3bb6 commit 087db13
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .craftplugin
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"pluginName":"Locale Redirector","pluginDescription":"Automatically redirect visitors to their preferred language","pluginVersion":"1.1.1","pluginAuthorName":"Pierre Stoffe","pluginVendorName":"pierrestoffe","pluginAuthorUrl":"https://pierrestoffe.be","pluginAuthorGithub":"pierrestoffe","codeComments":"yes","pluginComponents":["services"],"consolecommandName":"","controllerName":"","cpsectionName":"","elementName":"","fieldName":"","modelName":"","purchasableName":"","recordName":"","serviceName":"","taskName":"","utilityName":"","widgetName":"","apiVersion":"api_version_3_0"}
{"pluginName":"Locale Redirector","pluginDescription":"Automatically redirect visitors to their preferred language","pluginVersion":"1.1.2","pluginAuthorName":"Pierre Stoffe","pluginVendorName":"pierrestoffe","pluginAuthorUrl":"https://pierrestoffe.be","pluginAuthorGithub":"pierrestoffe","codeComments":"yes","pluginComponents":["services"],"consolecommandName":"","controllerName":"","cpsectionName":"","elementName":"","fieldName":"","modelName":"","purchasableName":"","recordName":"","serviceName":"","taskName":"","utilityName":"","widgetName":"","apiVersion":"api_version_3_0"}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

## [Unreleased]

## [1.1.2] - 2018-12-09

### Changed
- Disable redirection for URLs that contain the ignore-lang parameter

## [1.1.1] - 2018-12-08

### Added
Expand Down
21 changes: 1 addition & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,6 @@ Language Redirector mixes all these parameters and provides you with an easy-to-

If you feel like it, you can also rename the URL query parameter name and the session key. By default, they are both set to 'lang'.

## Using Language Redirector

Adding a language switcher to your website becomes way easier with this plugin.
As the `craft.languageSwitcher.getUrls()` function returns the URLs of the currently-visited element in all the languages defined in the config file, your language switcher could look like this:

```
{% set allLanguages = craft.languageSwitcher.getUrls() %}

<ul>
{% for item in allLanguages %}
<li>
<a href="{{ item.url }}" hreflang="{{ item.id }}" lang="{{ item.id }}" title="{{ 'Switch to {language}'|translate({
language: item.name
}) }}">
{{ item.nativeName|capitalize }}
</a>
</li>
{% endfor %}
</ul>
```
Read [the wiki](https://github.com/pierrestoffe/craft-language-redirector/wiki) for more information.

Brought to you by [Pierre Stoffe](https://pierrestoffe.be)
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "pierrestoffe/craft-language-redirector",
"description": "Automatically redirect visitors to their preferred language",
"type": "craft-plugin",
"version": "1.1.1",
"version": "1.1.2",
"keywords": [
"craft",
"cms",
Expand Down
4 changes: 4 additions & 0 deletions src/LanguageRedirector.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ function (Event $event) {
$canRedirect = false;
}

if($request->getQueryParam('ignore-lang') !== null) {
$canRedirect = false;
}

if(Craft::$app->user->checkPermission('accessCp') && LanguageRedirector::getInstance()->getSettings()->redirectUsersWithCpAccess == false) {
$canRedirect = false;
}
Expand Down

0 comments on commit 087db13

Please sign in to comment.