我在我的网页上使用谷歌翻译api。我添加了谷歌翻译脚本到index.php。我的网页上有很多页面。İ如果我传递到另一个页面谷歌翻译脚本不工作,只是在我添加的页面上工作。我想使用所有的页面。我应该一个接一个地添加谷歌翻译脚本吗?İ有什么简单的方法可以添加所有页面吗?
发布于 2016-12-08 06:38:55
是的,您必须将其添加到所有页面。
在此处注册您的网站https://translate.google.com/manager/website/
一旦您在所有页面上添加代码,所有页面将根据用户的第一个选择自动转换。用户不必在每个页面上选择首选语言。
发布于 2016-12-08 07:33:36
我不确定我是否理解了你的问题。
如果您想要动态地将google translate api代码包含到所有页面中,那么您可以通过多种方式来实现
1. create one translate.js file with the api code inside.
then use include("translate.js"); in all pages where you need it.
2. create inline <script>(paste here, translate api code)</script>
in dynamic header or footer page if you've one already. than use
include("header.php"); use it in all pages where you need it.
if you place the tracking code in a header file..
include("footer.php"); use it in all pages where you need it.
if you place the translate code in a footer file..
https://stackoverflow.com/questions/38000965
复制相似问题