So here's my problem: I have a default Google Sign-in button in my page and need to change it's language.
I render it with:
gapi.signin2.render('google-button', {
'scope': 'profile email',
'width': 122,
'height': 39,
...
});
I've tried several solutions throughout the web. Those being:
Inserting lang object in the API's script tag:
<script src="https://apis.google.com/js/platform.js" async defer >
{lang:'pt'}
</script>
Setting ___gcfg:
window.___gcfg = {
lang: 'pt'
};
Setting the lang attribute in the html tag
<html lang="pt">
Adding a parameter to the API's URL
<script src="https://apis.google.com/js/platform.js?hl=pt" . . .
And the only place I found something about this in Google's documentation, it redirects to a page that says nothing about this. (https://developers.google.com/identity/sign-in/web/build-button)
I really would like to avoid building a custom button because of the branding guidelines, could someone help me?
PS: I'm using React.js
Many thanks!
I had the same problem, I ended with that for now. Not really clean but "it works". So it uses a callback for the platform.js
script:
<script src="https://apis.google.com/js/platform.js?onload=onLoadCallback" async defer></script>
<script>
function onLoadCallback() {
$('span[id^="not_signed_"]').html('Se connecter avec Google');
}
</script>
As the span id is dynamic we have to use a "id start with" selector. (using jQuery in this case).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With