国内谷歌翻译用不了怎么办解决谷歌翻译失效的方法

 2年前     71  

文章目录

由于谷歌公司关闭了中国大陆地区的谷歌翻译服务器,导致谷歌浏览器在使用网页翻译功能时失败并显示无法翻译此页,Google官方的说法是由于在国内使用率太低。关闭后国内大量使用谷歌浏览器的用户(包括我)都在网上寻找解决办法。在此,为了正常使用翻译功能爱颜兮把网上的解决办法一一收集罗列如下。

解决办法一

Windows系统手动修复

首先我们要找到可以恢复谷歌翻译的IP地址,访问链接: https://tools.ipip.net/ping.php输入translate.google.cn,点击“Ping”。

国内谷歌翻译用不了怎么办解决谷歌翻译失效的方法

选一个离你最近的IP,按照IP+空格+translate.googleapis.com格式添加到hosts文件末尾。不同系统hosts文件位置如下:

win:C:\Windows\System32\drivers\etc\hosts
mac:/etc/hosts
Linux:/etc/hosts
ios:/etc/hosts
安卓:/system/etc/hosts

国内谷歌翻译用不了怎么办解决谷歌翻译失效的方法

保存修改并重启谷歌浏览器即可恢复谷歌翻译功能。

修改hosts的方法很可能有时效性,如果失效可以再执行一遍脚本或手动更改重定向IP。当然其实也只是恢复谷歌翻译这个功能而已,谷歌翻译的官网依旧是无法使用的,除非使用“科学上网”的方式,你懂得。

解决办法二

脚本修复

如果你用的是Windows系统,最快速的解决就是执行修复脚本

国内谷歌翻译用不了怎么办解决谷歌翻译失效的方法

代码如下:

@setlocal enabledelayedexpansion
@echo off

set "source_domain=google.cn"
set "target_domain=translate.googleapis.com"

set "hosts_file=C:\Windows\System32\drivers\etc\hosts"

::for /f "skip=4 tokens=2" %%a in ('"nslookup %source_domain% 2>NUL"') do set ip=%%a
set "ip=172.253.124.90"
set "old_rule=null"
set "new_rule=%ip% %target_domain%"

for /f "tokens=*" %%i in ('type %hosts_file%') do (
set "line=%%i"
:: Retrieve the rule If the target domain has been exists in the line.
if not "!line:%target_domain%=!"=="%%i" set "old_rule=%%i"
)

if not "%old_rule%"=="null" (
if not "%old_rule%"=="%new_rule%" (
echo Deleting the rule "%old_rule%"
echo Adding the rule "%new_rule%"
for /f "tokens=*" %%i in ('type "%hosts_file%" ^| find /v /n "" ^& break ^> "%hosts_file%"') do (
set "rule=%%i"
set "rule=!rule:*]=!"
if "%old_rule%"=="!rule!" set "rule=%new_rule%"
>>%hosts_file% echo(!rule!
)
) else (
echo The rule already exists, nothing to do.
)
) else (
echo Adding the rule "%new_rule%"
echo.>>%hosts_file%
echo.>>%hosts_file%
echo # Fix Google Translate CN>>%hosts_file%
echo %new_rule%>>%hosts_file%
)
@ipconfig /flushdns
@echo "修改谷歌翻译和刷新dns完成,请关闭!"
echo Done.
pause

当然替代谷歌翻译的软件有很多,在线的百度翻译、网易有道词典等都是大家常用的翻译方式。

以上就是修复谷歌翻译功能的全部内容,希望对大家有所帮助。

暂无评论

暂无评论...