From 45e193a7d719c1c76cddd985ad6a7dee80bc92f6 Mon Sep 17 00:00:00 2001 From: 1v9 Date: Mon, 4 Mar 2019 21:25:06 +0800 Subject: [PATCH] Feat: Add force language to Gitalk * inspired by #651 --- _config.yml | 6 +++++- layout/_third-party/comments/gitalk.swig | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/_config.yml b/_config.yml index f60cabbd09..fe54d5343e 100644 --- a/_config.yml +++ b/_config.yml @@ -617,11 +617,15 @@ gitment: gitalk: enable: false github_id: # Github repo owner - repo: # Repository name to store issues. + repo: # Repository name to store issues client_id: # Github Application Client ID client_secret: # Github Application Client Secret admin_user: # GitHub repo owner and collaborators, only these guys can initialize github issues distraction_free_mode: true # Facebook-like distraction free mode + # Gitalk's display language depends on user's browser or system environment + # If you want everyone visiting your site to see a uniform language, you can set a force language value + # Available value: en, es-ES, fr, ru, zh-CN, zh-TW + language: # Baidu Share # Available values: button | slide diff --git a/layout/_third-party/comments/gitalk.swig b/layout/_third-party/comments/gitalk.swig index 86172ad92d..749ec59e9c 100644 --- a/layout/_third-party/comments/gitalk.swig +++ b/layout/_third-party/comments/gitalk.swig @@ -24,6 +24,11 @@ owner: '{{ theme.gitalk.github_id }}', admin: ['{{ theme.gitalk.admin_user }}'], id: md5(location.pathname), + {% if theme.gitalk.language == '' %} + language: window.navigator.language || window.navigator.userLanguage, + {% else %} + language: '{{ theme.gitalk.language }}', + {% endif %} distractionFreeMode: '{{ theme.gitalk.distraction_free_mode }}' }); gitalk.render('gitalk-container');