Created
May 3, 2024 08:00
-
-
Save equwal/865272f14ec6aaae2766d9438e3e7bfc to your computer and use it in GitHub Desktop.
Translation has not been available in China since about one day ago #9574
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- To be used if a DNS lookup for translate.googleapis.com would fail | |
local Translator = require("ui/translator") | |
local http = require("socket.http") | |
Translator.getTransServer = function() | |
-- Change this with a usable/working IP address (that would work if added to a HOSTS file) | |
return "https://180.163.151.162/" | |
end | |
local orig_http_request = http.request | |
local hacked_http_request = function(reqt) | |
-- Keep this unchanged | |
reqt["host"] = "translate.googleapis.com" | |
return orig_http_request(reqt) | |
end | |
local orig_translator_loadPage = Translator.loadPage | |
Translator.loadPage = function(self, text, target_lang, source_lang) | |
http.request = hacked_http_request | |
local result = orig_translator_loadPage(self, text, target_lang, source_lang) | |
http.request = orig_http_request | |
return result | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment