谷歌翻译退出大陆市场? 10秒“复活”攻略来袭!

谷歌翻译退出大陆市场? 10秒“复活”攻略来袭!

最近,谷歌官方宣布“谷歌翻译”因使用率低关闭大陆市场!大陆用户已经无法直接访问网页版Google Translate,这也导致Google Translate浏览器插件、Chrome浏览器右键翻译、Google Translate APP全部失效。

本文章就给大家带来两种“复活”谷歌翻译的方法。

修改Host文件“复活”

通过记事本方式,打开此电脑C盘的host文件

文件位置:C:\Windows\System32\drivers\etc

不同系统打开路径如下,本文章以Windows 为例

  • Windows 系统:C:\Windows\System32\drivers\etc\hosts
  • Mac 系统:/etc/hosts
  • Linux 系统:/etc/hosts
  • Android 系统:/system/etc/hosts
  • iOS 系统:/etc/hosts

找到Host文件,右键→打开方式→选择记事本进行打开→在Host文件最下面添加以下任意1行:

  • 203.208.40.66 http://translate.google.com
  • 203.208.40.66 http://translate.googleapis.com
  • 220.181.174.226 http://translate.googleapis.com

将Host文件保存后,重启浏览器即生效

注意事项:

1、按照以上操作完成后,依然无法访问,则需要刷新 DNS ,使用Win + R键运行cmd 窗口,输入指令 ipconfig /flushdns 即可

2、当刷新完DNS过后如果还是不能进行使用,则需要更换前面的IP地址,找最新可用IP地址方法如下:

  • 按下键盘上的Win键+R键,然后输入ping google.cn -t,点击回车,记住找到的IP地址,将上面给大家提供的Hots文件代码前面的IP进行替换,然后在将其保存到Host文件中即可;
  • 还有另外的方法来获取大陆可用的IP,打开这个网站:https://ping.chinaz.com/translate.google.cn
  • 打开后,向下滑动页面,找到离自己最近的服务器,最好是和自己对应的运营商,复制里面的IP地址,将其替换。

3、部分朋友因为权限不够,无法修改 hosts 文件的内容,按照以下方法设置文件权限:

  • 选择hosts文件 – hosts属性 – 安全 – 点击自己的用户名 – 编辑 – 点击完全控制(或把写入权限打勾) – 再修改文件内容

Windows批处理“复活”

新建一个文本文档,将以下代码粘贴在文档中并保存,保存后将文本文档的.txt格式更改成.bat格式,右键→以管理员权限运行;

注:如看不到文件后缀扩展名称,可以打开此电脑→在标题栏点击“查看”→勾选”文件扩展名“。

代码来源于Github仓库开源,开源地址:点击进入

:: 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

@echo off
setlocal enabledelayedexpansion
chcp 437 >NUL

set "ips[0]=74.125.137.90"
set "ips[1]=74.125.193.186"
set "ips[2]=74.125.196.113"
set "ips[3]=108.177.97.100"
set "ips[4]=108.177.111.90"
set "ips[5]=108.177.122.90"
set "ips[6]=108.177.125.186"
set "ips[7]=108.177.126.90"
set "ips[8]=108.177.127.90"
set "ips[9]=142.250.0.90"
set "ips[10]=142.250.1.90"
set "ips[11]=142.250.4.90"
set "ips[12]=142.250.8.90"
set "ips[13]=142.250.9.90"
set "ips[14]=142.250.10.90"
set "ips[15]=142.250.11.90"
set "ips[16]=142.250.12.90"
set "ips[17]=142.250.13.90"
set "ips[18]=142.250.27.90"
set "ips[19]=142.250.28.90"
set "ips[20]=142.250.30.90"
set "ips[21]=142.250.31.90"
set "ips[22]=142.250.96.90"
set "ips[23]=142.250.97.90"
set "ips[24]=142.250.98.90"
set "ips[25]=142.250.99.90"
set "ips[26]=142.250.100.90"
set "ips[27]=142.250.101.90"
set "ips[28]=142.250.102.90"
set "ips[29]=142.250.103.90"
set "ips[30]=142.250.105.90"
set "ips[31]=142.250.107.90"
set "ips[32]=142.250.111.90"
set "ips[33]=142.250.112.90"
set "ips[34]=142.250.113.90"
set "ips[35]=142.250.114.90"
set "ips[36]=142.250.115.90"
set "ips[37]=142.250.123.90"
set "ips[38]=142.250.125.90"
set "ips[39]=142.250.126.90"
set "ips[40]=142.250.128.90"
set "ips[41]=142.250.138.90"
set "ips[42]=142.250.141.90"
set "ips[43]=142.250.142.90"
set "ips[44]=142.250.145.90"
set "ips[45]=142.250.152.90"
set "ips[46]=142.250.153.90"
set "ips[47]=142.250.157.90"
set "ips[48]=142.250.157.183"
set "ips[49]=142.250.157.184"
set "ips[50]=142.250.157.186"
set "ips[51]=142.250.158.90"
set "ips[52]=142.250.159.90"
set "ips[53]=142.251.1.90"
set "ips[54]=142.251.2.90"
set "ips[55]=142.251.4.90"
set "ips[56]=142.251.5.90"
set "ips[57]=142.251.6.90"
set "ips[58]=142.251.8.90"
set "ips[59]=142.251.9.90"
set "ips[60]=142.251.10.90"
set "ips[61]=142.251.12.90"
set "ips[62]=142.251.15.90"
set "ips[63]=142.251.16.90"
set "ips[64]=142.251.18.90"
set "ips[65]=142.251.107.90"
set "ips[66]=142.251.111.90"
set "ips[67]=142.251.112.90"
set "ips[68]=142.251.116.90"
set "ips[69]=142.251.117.90"
set "ips[70]=142.251.120.90"
set "ips[71]=142.251.160.90"
set "ips[72]=142.251.161.90"
set "ips[73]=142.251.162.90"
set "ips[74]=142.251.163.90"
set "ips[75]=142.251.166.90"
set "ips[76]=172.217.192.90"
set "ips[77]=172.217.195.90"
set "ips[78]=172.217.203.90"
set "ips[79]=172.217.204.90"
set "ips[80]=172.217.214.90"
set "ips[81]=172.217.215.90"
set "ips[82]=172.253.58.90"
set "ips[83]=172.253.62.90"
set "ips[84]=172.253.63.90"
set "ips[85]=172.253.112.90"
set "ips[86]=172.253.113.90"
set "ips[87]=172.253.114.90"
set "ips[88]=172.253.115.90"
set "ips[89]=172.253.116.90"
set "ips[90]=172.253.117.90"
set "ips[91]=172.253.118.90"
set "ips[92]=172.253.119.90"
set "ips[93]=172.253.123.90"
set "ips[94]=172.253.124.90"
set "ips[95]=172.253.125.90"
set "ips[96]=172.253.126.90"
set "ips[97]=172.253.127.90"
set "ips[98]=216.58.227.65"
set "ips[99]=216.58.227.66"
set "ips[100]=216.58.227.67"

set /a "index=%RANDOM% %% 101"
set "random_ip=!ips[%index%]!"

set "divider=----------------------------------------------"
set "target_domain=translate.googleapis.com"
set "hosts_file=C:\Windows\System32\drivers\etc\hosts"

goto :start

:generate_new_rule
    echo Modify hosts file to fix Google translate service.
    echo %divider%
    echo [1] Automatically [2] Manually
    echo %divider%
    set /p action="Enter a number to choose an IP adding method:"

    if "%action%"=="2" (
        set /p ip="Please enter a valid IP address: "
    )

    if "%ip%"=="" (
        set "ip=!random_ip!"
    )

    set "new_rule=%ip% %target_domain%"
goto:EOF

:start

set "old_rule=null"
set "comment=# Fix Google Translate CN"

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

if not "%old_rule%"=="null" (
    echo A rule has been added to the hosts file.
    echo %divider%
    echo [1] Update [2] Delete
    echo %divider%
    set /p action="Enter a number to choose an action: "
    if "!action!"=="1" (
        call :generate_new_rule
        if not "%old_rule%"=="!new_rule!" (
            echo Deleting the rule "%old_rule%"
            echo Adding the rule "!new_rule!"
            set "new_line=false"
            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!"
                if "!new_line!"=="true" >>%hosts_file% echo.
                >>%hosts_file% <NUL set /p="!rule!"
                set "new_line=true"
            )
        ) else (
            echo The rule already exists, nothing to do.
        )
    ) else (
        if "!action!"=="2" (
            echo Deleting the rule "%old_rule%"
            set "new_line=false"
            for /f "tokens=*" %%i in ('
                type "%hosts_file%" ^| findstr /v /c:"%comment%" ^| findstr /v "%target_domain%" ^| find /v /n "" ^& break ^> "%hosts_file%"
            ') do (
                set "line=%%i"
                set "line=!line:*]=!"
                if "!new_line!"=="true" >>%hosts_file% echo.
                >>%hosts_file% <NUL set /p="!line!"
                set "new_line=true"
            )
        )
    )
) else (
    call :generate_new_rule
    echo Adding the rule "!new_rule!"
    echo.>>%hosts_file%
    echo %comment%>>%hosts_file%
    <NUL set /p="!new_rule!">>%hosts_file%
)

echo Done.
pause

Mac OS批处理“复活”

操作方法与Windows类似,将以下代码另存为.sh文件格式

 

#!/bin/bash
# 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

set -e

IPS=(
    74.125.137.90
    74.125.193.186
    74.125.196.113
    108.177.97.100
    108.177.111.90
    108.177.122.90
    108.177.125.186
    108.177.126.90
    108.177.127.90
    142.250.0.90
    142.250.1.90
    142.250.4.90
    142.250.8.90
    142.250.9.90
    142.250.10.90
    142.250.11.90
    142.250.12.90
    142.250.13.90
    142.250.27.90
    142.250.28.90
    142.250.30.90
    142.250.31.90
    142.250.96.90
    142.250.97.90
    142.250.98.90
    142.250.99.90
    142.250.100.90
    142.250.101.90
    142.250.102.90
    142.250.103.90
    142.250.105.90
    142.250.107.90
    142.250.111.90
    142.250.112.90
    142.250.113.90
    142.250.114.90
    142.250.115.90
    142.250.123.90
    142.250.125.90
    142.250.126.90
    142.250.128.90
    142.250.138.90
    142.250.141.90
    142.250.142.90
    142.250.145.90
    142.250.152.90
    142.250.153.90
    142.250.157.90
    142.250.157.183
    142.250.157.184
    142.250.157.186
    142.250.158.90
    142.250.159.90
    142.251.1.90
    142.251.2.90
    142.251.4.90
    142.251.5.90
    142.251.6.90
    142.251.8.90
    142.251.9.90
    142.251.10.90
    142.251.12.90
    142.251.15.90
    142.251.16.90
    142.251.18.90
    142.251.107.90
    142.251.111.90
    142.251.112.90
    142.251.116.90
    142.251.117.90
    142.251.120.90
    142.251.160.90
    142.251.161.90
    142.251.162.90
    142.251.163.90
    142.251.166.90
    172.217.192.90
    172.217.195.90
    172.217.203.90
    172.217.204.90
    172.217.214.90
    172.217.215.90
    172.253.58.90
    172.253.62.90
    172.253.63.90
    172.253.112.90
    172.253.113.90
    172.253.114.90
    172.253.115.90
    172.253.116.90
    172.253.117.90
    172.253.118.90
    172.253.119.90
    172.253.123.90
    172.253.124.90
    172.253.125.90
    172.253.126.90
    172.253.127.90
    216.58.227.65
    216.58.227.66
    216.58.227.67
)

SED_CMD=/usr/bin/sed
GREP_CMD=/usr/bin/grep
CURL_CMD=/usr/bin/curl

DIVIDER='--------------------------------------'
API='https://translate.googleapis.com/translate_a/single?client=gtx&sl=en&tl=fr&dt=t&dj=1&q=hello'
TARGET_DOMAIN='translate.googleapis.com'
HOSTS_FILE=/etc/hosts

function test_translate_api() {
    $CURL_CMD -sk $API --resolve $TARGET_DOMAIN:443:$1 \
    | $GREP_CMD '"trans":"bonjour"'
}

function generate_new_rule() {
    echo 'Modify hosts file to fix Google translate service.'
    echo $DIVIDER
    echo '[1] Automatically [2] Manually'
    echo $DIVIDER
    echo -n 'Enter a number to choose an IP adding method: '
    read action

    if [ "$action" == '2' ]; then
        echo -n 'Please enter a valid IP address: '
        read IP
        if [ ! -n "$(test_translate_api $IP)" ]; then
            echo 'The IP is not available. Trying to choose one for you ...'
            unset IP
        fi
    fi

    if [ ! -n "$(test_translate_api $IP)" ]; then
        for i in ${IPS[@]}; do
            if [ -n "$(test_translate_api $i)" ]; then IP=$i; break; fi
        done
        if [ ! -n "$IP" ]; then
            echo 'There is no available ip to use. Press any key to exit.';
            read; exit;
        fi
    fi

    NEW_RULE="$IP $TARGET_DOMAIN"
}

OLD_RULE=$(cat $HOSTS_FILE | $GREP_CMD $TARGET_DOMAIN || :)
COMMENT="# Fix Google Translate CN"

if [ -n "$OLD_RULE" ]; then
    echo 'A rule has been added to the hosts file. '
    echo $DIVIDER
    echo '[1] Update [2] Delete'
    echo $DIVIDER
    echo -n 'Enter a number to choose an action: '
    read action
    if [ "$action" == '1' ]; then
        generate_new_rule
        if [ "$OLD_RULE" != "$NEW_RULE" ]; then
            echo "Deleting the rule \"$OLD_RULE\""
            echo "Adding the rule \"$NEW_RULE\""
            $SED_CMD -i '' "s/.*${TARGET_DOMAIN}/${NEW_RULE}/" $HOSTS_FILE
        else
            echo 'The rule already exists, nothing to do.'
        fi
    elif [ "$action" == '2' ]; then
        echo "Deleting the rule \"$OLD_RULE\""
        PATTERN="s/\n*${COMMENT}\n.* ${TARGET_DOMAIN}//"
        $SED_CMD -i '' -e ':a' -e 'N' -e '$!ba' -e "$PATTERN" $HOSTS_FILE
    fi
else
    generate_new_rule
    echo "Adding the rule \"$NEW_RULE\""
    echo -ne "\n${COMMENT}\n${NEW_RULE}" >> $HOSTS_FILE
fi

echo 'Done.'

 

 

阅读剩余
THE END