sid*_*and 5 locale internationalization google-one-tap
目前,谷歌一键提示仅以英文呈现。有没有一种方法可以将区域设置传递给 javascript api,以便以该特定语言呈现提示?
小智 1
抱歉这么晚才回复,但是我最近遇到了同样的问题。
官方文档没有提供处理即时本地化的直接方法。我发现的最接近的想法是:link。考虑到这一点,我加载了 Google 客户端:
<script src="https://accounts.google.com/gsi/client?hl=iso-639-code" async defer></script>
Run Code Online (Sandbox Code Playgroud)
其中iso-639-code是所需的语言,例如 en、zh、de 等。
然后我有一个提示状态的侦听器,如果状态有效(显示通知),iframe 的源将更改为与上面的脚本类似
// initizalization
google.accounts.id.initialize({
client_id: clientId,
callback: handleCredentialResponse,
});
// prompt initalization and callback function
google.accounts.id.prompt((notification) => {
if (notification.isNotDisplayed()) return;
const googlePromptFrame = document.querySelector("#credential_picker_container iframe");
if (googlePromptFrame) googlePromptFrame.src = googlePromptFrame.src + "iso-639-code";
});
Run Code Online (Sandbox Code Playgroud)
这对于我的目的来说效果很好。
| 归档时间: |
|
| 查看次数: |
308 次 |
| 最近记录: |