fix: inaccurate google translation behavior (#55)

This commit is contained in:
jeffreytse 2021-08-12 12:02:44 +08:00
parent f06b7b0e62
commit 9ecb45bd4e
2 changed files with 8 additions and 1 deletions

View file

@ -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>
@ -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');

View file

@ -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>