前几天谷歌不是发通知说因为中国大陆使用量太少,停止给谷歌翻译提供服务(信你个鬼,糟老头子坏得很)了吗?
但是咱们时不能这么轻易就让这个神器寄了的(虽然有另外个deepl翻译神器,效果貌似比谷歌还要好,但是无奈这个网站实在是太慢,就用的比较少),所以通过博众家之所长,知道了解决谷歌翻译无法使用的问题的方法。
从此谷歌翻译原地复活,嘻嘻!
方法很简单,就是把下面的代码复制到一个新建的txt文件后,把后缀名改成’’ .bat ‘’,然后右键单击用管理员运行模式运行该批处理文件即可。原理就是通过获得谷歌翻译的动态主机来提供服务。
格么,今朝的分享就到此位置了,如果您喜欢,欢迎点赞+关注+收藏!
:: Copyright (c)2022 https://bookfere.com
:: This is a batch script for fixing Google Translate and making it available
:: in the Chinese mainland. If you experience any problem, visit the page below:
:: https://bookfere.com/post/1020.html
@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 "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%
)
echo Done.
pause