Skip to content

Commit

Permalink
fix: inaccurate google translation behavior (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreytse committed Aug 12, 2021
1 parent f06b7b0 commit 9ecb45b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion _includes/extensions/google-translate.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
{% assign translate_langs = include.translate_langs %}
{% endif %}

{% if include.lang %}
{% assign lang = include.lang %}
{% endif %}

<div id="google_translate_element" style="display: none;">
</div>

Expand All @@ -24,7 +28,7 @@
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: '',
pageLanguage: '{{ lang }}',
autoDisplay: false,
layout: google.translate.TranslateElement.InlineLayout.VERTICAL
}, 'google_translate_element');
Expand Down
3 changes: 3 additions & 0 deletions _includes/views/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
{%- include functions.html func='get_value' -%}
{%- assign translate_langs = return -%}
{%- if translate_langs.size > 0 -%}
{%- assign name = 'lang' -%}
{%- include functions.html func='get_value' default='en' -%}
{%- assign lang = return -%}
<span class="page-link">
{%- include extensions/google-translate.html -%}
</span>
Expand Down

0 comments on commit 9ecb45b

Please sign in to comment.