如何更改Google登录按钮语言

Gui*_*les 12 javascript internationalization google-plus google-signin

所以这是我的问题:我的页面中有一个默认的Google登录按钮,需要更改它的语言.

我渲染它:

gapi.signin2.render('google-button', {
    'scope': 'profile email',
    'width': 122,
    'height': 39, 
    ...
});
Run Code Online (Sandbox Code Playgroud)

我在整个网络上尝试了几种解决方案.那些是:

  1. 在API的脚本标记中插入lang对象:

    <script src="https://apis.google.com/js/platform.js" async defer > 
        {lang:'pt'}
    </script>
    
    Run Code Online (Sandbox Code Playgroud)
  2. 设置___gcfg:

    window.___gcfg = {
        lang: 'pt'
    };
    
    Run Code Online (Sandbox Code Playgroud)
  3. html标记中设置lang属性

    <html lang="pt">
    
    Run Code Online (Sandbox Code Playgroud)
  4. 将参数添加到API的URL

    <script src="https://apis.google.com/js/platform.js?hl=pt" . . .
    
    Run Code Online (Sandbox Code Playgroud)

我在Google的文档中找到了与此相关的唯一地方,它重定向到一个对此没有任何说明的页面.(https://developers.google.com/identity/sign-in/web/build-button)

我真的想避免建立一个自定义按钮,因为品牌指导,有人可以帮助我吗?

PS:我正在使用React.js

非常感谢!

小智 -2

在 Google 网站登录中,您可以更改按钮的语言。

唯一的选项是遵循本节的说明: https://developers.google.com/identity/sign-in/web/build-button#building_a_button_with_a_custom_graphic

  • 我在任何地方都没有看到为指定链接处的按钮设置自定义语言的选项。 (7认同)