I don't know how to change the language of my google sign in button

34 Views Asked by At

This is my code so far, I tried using this library @react-oauth/google, but also tried to use google's oficial documentation. I can't achieve a good result. I want the button to open the popup method not the redirect one (that is working with current code, just clarifying)

Using this code, I can log the user in but the button language is always spanish ( I'm from Argentina ) and it looks super weird in my app when I select italian as default app language.

Anyone can help guys? Thanks in advance

import React from 'react';
import { GoogleLogin, CredentialResponse } from '@react-oauth/google';
import { useTranslation } from 'react-i18next';

interface Props {
  onSuccess: (credentialResponse: CredentialResponse) => void;
  onFailure: (error: string) => void; 
}

const GoogleLoginButton = ({ onSuccess, onFailure }: Props) => {
  const { t, i18n } = useTranslation();

  return (
    <>
      <GoogleLogin
        onSuccess={(credentialResponse) => onSuccess(credentialResponse)}
        onError={() => onFailure("")}
        text='continue_with'
        locale={i18n.language}
        logo_alignment='center'
      />
    </>
  )
};

export default GoogleLoginButton;

I also found a useGoogleLogin hook from this library but that returns a different access_token, not a tokenId which is what the backend expects.

0

There are 0 best solutions below