6

百分百修复 Chrome浏览器 谷歌翻译 google translate 无法使用的问题

 1 year ago
source link: https://uzbox.com/tech/google-translate.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
首页技术宅百分百修复 Chrome浏览器 谷歌翻译 google translate 无法使用的问题

百分百修复 Chrome浏览器 谷歌翻译 google translate 无法使用的问题

谷歌翻译 google translate 不能用了?百分百可以修复 谷歌翻译 在线翻译网站

谷歌翻译Chrome 浏览器中无法使用,这是一个很棘手的问题,因为 谷歌翻译 停止了在中国的服务,所以谷歌浏览器 Chrome 中的内置翻译功能也同时无法使用了,谷歌发言人称,由于 Google Translate 谷歌翻译在中国零使用率的原因,已停止向中国大陆的用户提供 谷歌翻译 服务。中国用户曾经是可以使用谷歌浏览器 Chrome 内置翻译功能的,很多用户也养成了使用谷歌浏览器翻译的习惯,虽然微软的Edge浏览器也内置了翻译功能,但是习惯是很难一时间改过来的。

由于用户在访问英文或其他语言网页,非常需要浏览器内置的 google translate 翻译功能,下面就介绍一下在国内如何使用谷歌浏览器内置翻译功能的方法。

百分百修复 Chrome浏览器 谷歌翻译 无法使用的问题

如何修复无法使用谷歌翻译

谷歌翻译功能无法正常工作的根本原因是互联网防火墙的阻断,使用 谷歌翻 译会请求域名为 translate.googleapis.com 的API,而该域名在 谷歌翻译 正式关闭服务后就已经不可使用了。

使用脚本修复谷歌翻译

如果你使用的是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 OK uzbox.com"
echo Done.
pause
@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 OK uzbox.com"
echo Done.
pause

把上面的代码复制,在桌面上新建一个记事本,将脚本代码粘贴在记事本中,然后把记事本的.txt扩展名改为.bat,使用管理员身份执行脚本。

百分百修复 Chrome浏览器 谷歌翻译 无法使用的问题

如果命令窗口提示拒绝访问,那么说明你的hosts文件没有开启修改权限,修改方法也很简单。找到 C:\WINDOWS\System32\drivers\etc\hosts 文件,鼠标右键选择“属性”,将“只读”取消勾选。

百分百修复 Chrome浏览器 谷歌翻译 无法使用的问题

打开hosts文件我们会发现,其实就是添加了两行内容,原理就是通过hosts重定向到国内其它的服务器上,从而恢复使用。

百分百修复 Chrome浏览器 谷歌翻译 无法使用的问题

下面打开GitHub测试一下,点击浏览器右上角的翻译按钮,已经可以将英文网站翻译成中文了。

百分百修复 Chrome浏览器 谷歌翻译 无法使用的问题

是不是很简单, 谷歌翻译 百分百可以修复成功。

手动修复谷歌翻译

通过上面的修复过程我们了解到,使用脚本只不过是自动将代码添加到 C:\WINDOWS\System32\drivers\etc\hosts 文件中,如果你不想使用脚本,或者你使用的是MAC或者其它操作系统,可以使用手工修改hosts的方法来修复谷歌翻译

Windows

修改 C:\WINDOWS\System32\drivers\etc\hosts 文件。

Mac OS X

在应用程序里面打开终端(terminal),输入 sudo vi /etc/hosts ,然后使用vi编辑器修改保存文件。

Linux

例如 Ubuntu,定位到/etc,取得hosts读写权限,然后修改保存。

你只需要将下面内容粘贴在hosts文件末尾就可以了。在ip地址和域名之间有一个空格。

172.253.124.90 translate.googleapis.com
142.250.4.90 translate.googleapis.com
172.253.124.90 translate.googleapis.com
142.250.4.90 translate.googleapis.com

如果谷歌翻译的IP地址失效的话,在 https://ping.chinaz.com/translate.google.com 中查找一条可以ping通的IP地址替换一下即可。

需要注意的是,这种修改只能恢复Chrome浏览器的内置翻译功能,并不能恢复Web版谷歌翻译 http://translate.google.com 的访问​。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK