Skip to content

Commit

Permalink
Merge branch 'release/1.4.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Jun 26, 2021
2 parents d2ea312 + 46e5cdb commit a392422
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# v1.4.3
## 06/25/2021

1. [](#new)
* Made langswitcher data available in Grav object
1. [](#bugfix)
* Fix multilang alternatives [#58](https://github.com/getgrav/grav-plugin-langswitcher/pull/58)
# v1.4.2
## 03/17/2021

Expand Down
2 changes: 1 addition & 1 deletion blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: LangSwitcher
version: 1.4.2
version: 1.4.3
description: LangSwitcher is a [Grav](http://github.com/getgrav/grav) plugin that provides native language text links to switch between [multiple languages](http://learn.getgrav.org/content/multi-language) in Grav **v0.9.30** or greater.
icon: globe
author:
Expand Down
3 changes: 2 additions & 1 deletion langswitcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

class LangSwitcherPlugin extends Plugin
{

/**
* @return array
*/
Expand Down Expand Up @@ -99,7 +100,7 @@ public function onTwigSiteVariables()

$data->current = $this->grav['language']->getLanguage();

$this->grav['twig']->twig_vars['langswitcher'] = $data;
$this->grav['twig']->twig_vars['langswitcher'] = $this->grav['langswitcher'] = $data;

if ($this->config->get('plugins.langswitcher.built_in_css')) {
$this->grav['assets']->add('plugin://langswitcher/css/langswitcher.css');
Expand Down
6 changes: 3 additions & 3 deletions templates/partials/langswitcher.hreflang.html.twig
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{% set langobj = grav['language'] %}
{% for key in langswitcher.languages %}
{% if key == langswitcher.current %}
{% set lang_url = page.url %}
{% set lang_url = page.url is same as('/') ? '' : page.url %}
{% else %}
{% set lang_url = base_url_simple ~ langobj.getLanguageURLPrefix(key) ~ langswitcher.page_route ~ page.urlExtension ?: '/' %}
{% set lang_url = (langobj.getLanguageURLPrefix(key) ~ langswitcher.page_route ~ page.urlExtension ?: '')|rtrim('/') %}
{% endif %}
<link rel="alternate" hreflang="{{ key }}" href="{{ base_url_absolute ~ lang_url ~ uri.params }}" />
<link rel="alternate" hreflang="{{ key }}" href="{{ uri.base ~ lang_url ~ uri.params }}" />
{% endfor %}

0 comments on commit a392422

Please sign in to comment.