Skip to content

Commit

Permalink
some
Browse files Browse the repository at this point in the history
  • Loading branch information
HIllya51 committed Nov 13, 2024
1 parent f197733 commit 78c88da
Show file tree
Hide file tree
Showing 23 changed files with 105 additions and 81 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
- **HOOK** 支持使用HOOK方式获取文本,支持使用特殊码,支持自动保存游戏及HOOK、自动加载HOOK等。对于部分引擎,还支持内嵌翻译。对于不支持或支持不好的游戏,请[提交反馈](https://github.com/HIllya51/LunaTranslator/issues/new?assignees=&labels=enhancement&projects=&template=01_game_request.yaml)


- **OCR** 支持 **离线OCR** ( 除内置OCR引擎外,还支持WindowsOCR、Tessearact5、manga-ocr、WeChat/QQ OCR ) 和 **在线OCR** ( 百度、有道、飞书、讯飞、Google Lens、Google Cloud Vision、docsumo、ocrspace、Gemini、ChatGPT兼容接口 )
- **OCR** 支持 **离线OCR** ( 除内置OCR引擎外,还支持WindowsOCR、Tessearact5、manga-ocr、WeChat/QQ OCR ) 和 **在线OCR** ( 百度、有道、讯飞、Google Lens、Google Cloud Vision、docsumo、ocrspace、Gemini、ChatGPT兼容接口 )

- **剪贴板** 支持从剪贴板中获取文本进行翻译

Expand All @@ -32,7 +32,7 @@

- **免费在线翻译** 支持使用百度、必应、谷歌、阿里、有道、彩云、搜狗、讯飞、腾讯、字节、火山、DeepL/DeepLX、papago、yandex、lingva、reverso、TranslateCom、ModernMT

- **注册在线翻译** 支持使用用户注册的 **传统翻译** ( 百度、腾讯、有道、小牛、彩云、火山、DeepL、yandex、google、ibm、Azure、飞书 ) 和 **大模型翻译** ( ChatGPT兼容接口、claude、cohere、gemini、百度千帆、腾讯混元 )
- **注册在线翻译** 支持使用用户注册的 **传统翻译** ( 百度、腾讯、有道、小牛、彩云、火山、DeepL、yandex、google、ibm、Azure ) 和 **大模型翻译** ( ChatGPT兼容接口、claude、cohere、gemini、百度千帆、腾讯混元 )

- **离线翻译** 支持 **传统翻译** ( J北京7、金山快译、译典通、ezTrans、Sugoi、MT5 ) 和离线部署的 **大模型翻译** ( ChatGPT兼容接口、Sakura大模型 )

Expand Down
2 changes: 1 addition & 1 deletion cpp/LunaHook/LunaHook/engine32/Alice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ bool InsertAliceHook()
return ok;
}

bool Alice::attach_function()
bool Alice::attach_function_()
{

return InsertAliceHook();
Expand Down
7 changes: 5 additions & 2 deletions cpp/LunaHook/LunaHook/engine32/Alice.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ class Alice : public ENGINE
Alice()
{

check_by = CHECK_BY::ALL_TRUE;
check_by = CHECK_BY::CUSTOM;
check_by_target = [this]()
{ return attach_function_(); };
};
bool attach_function();
bool attach_function_();
bool attach_function() { return true; }
};
59 changes: 42 additions & 17 deletions cpp/LunaHook/LunaHook/engine32/TerraLunar.cpp
Original file line number Diff line number Diff line change
@@ -1,25 +1,50 @@
#include "TerraLunar.h"

bool TerraLunar::attach_function()
namespace
{
const BYTE bytes[] = {
// らくえん~あいかわらずなぼく。の場合~
0x8A, 0x08,
0x81, 0xF9, 0x9F, 0x00, 0x00, 0x00,
0x7E};
auto addrs = Util::SearchMemory(bytes, sizeof(bytes), PAGE_EXECUTE, processStartAddress, processStopAddress);
auto succ = false;
for (auto addr : addrs)
bool H1()
{
const BYTE bytes[] = {
// らくえん~あいかわらずなぼく。の場合~
0x8A, 0x08,
0x81, 0xF9, 0x9F, 0x00, 0x00, 0x00,
0x7E};
auto addrs = Util::SearchMemory(bytes, sizeof(bytes), PAGE_EXECUTE, processStartAddress, processStopAddress);
auto succ = false;
for (auto addr : addrs)
{
HookParam hp;
hp.address = addr;
hp.offset = get_reg(regs::eax);
hp.type = USING_STRING;
hp.filter_fun = [](TextBuffer *buffer, HookParam *hp)
{
StringFilter(buffer, "[w]", 3);
};
succ |= NewHook(hp, "TerraLunar");
}
return succ;
}
bool H2()
{
const BYTE bytes[] = {
// https://vndb.org/v2416
// ナースのお勉強 応用編~受けシチュ以外は絶対禁止!~
0X8B, 0X4D, 0X0C, 0X0F, 0XBE, 0X51, 0X01, 0XB8, 0X00, 0X01, 0X00, 0X00};
auto addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStopAddress);
if (!addr)
return false;
addr = MemDbg::findEnclosingAlignedFunction(addr);
if (!addr)
return false;
HookParam hp;
hp.address = addr;
hp.offset = get_reg(regs::eax);
hp.offset = get_stack(2);
hp.type = USING_STRING;
hp.filter_fun = [](TextBuffer *buffer, HookParam *hp)
{
StringFilter(buffer, "[w]", 3);
};
succ |= NewHook(hp, "TerraLunar");
return NewHook(hp, "AtelierD");
}
return succ;
}
bool TerraLunar::attach_function()
{

return H2() | H1();
}
2 changes: 1 addition & 1 deletion cpp/LunaHook/LunaHook/engine32/mono.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ bool monodll()
return succ;
}

bool mono::attach_function()
bool mono::attach_function_()
{

bool common = monocommon::hook_mono_il2cpp();
Expand Down
17 changes: 11 additions & 6 deletions cpp/LunaHook/LunaHook/engine32/mono.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@


class mono:public ENGINE{
public:
mono(){

check_by=CHECK_BY::ALL_TRUE;
class mono : public ENGINE
{
public:
mono()
{

check_by = CHECK_BY::CUSTOM;
check_by_target = [this]()
{ return attach_function_(); };
};
bool attach_function();
bool attach_function_();
bool attach_function() { return true; }
};
2 changes: 1 addition & 1 deletion cpp/LunaHook/LunaHook/engine64/mono.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ namespace
return suc;
}
}
bool mono::attach_function()
bool mono::attach_function_()
{
bool common = monocommon::hook_mono_il2cpp();
return common;
Expand Down
7 changes: 5 additions & 2 deletions cpp/LunaHook/LunaHook/engine64/mono.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ class mono : public ENGINE
mono()
{

check_by = CHECK_BY::ALL_TRUE;
check_by = CHECK_BY::CUSTOM;
check_by_target = [this]()
{ return attach_function_(); };
};
bool attach_function();
bool attach_function_();
bool attach_function() { return true; }
};
41 changes: 24 additions & 17 deletions cpp/LunaHook/LunaHook/engines/python/Renpy.h
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@

#include"python/python.h"
#include "python/python.h"

class Renpy:public ENGINE{
public:
Renpy(){
//使用lunatranslator启动游戏,会把cwd修改成exe所在目录,其中没有.py
check_by=CHECK_BY::ALL_TRUE;
// check_by=CHECK_BY::CUSTOM;
// check_by_target=[](){
// //Renpy - sample game https://vndb.org/v19843
// return Util::CheckFile(L"*.py")|| GetModuleHandleW(L"librenpython.dll");
// };
};
bool attach_function(){
#ifndef _WIN64
class Renpy : public ENGINE
{
public:
Renpy()
{
// 使用lunatranslator启动游戏,会把cwd修改成exe所在目录,其中没有.py
// check_by=CHECK_BY::CUSTOM;
// check_by_target=[](){
// //Renpy - sample game https://vndb.org/v19843
// return Util::CheckFile(L"*.py")|| GetModuleHandleW(L"librenpython.dll");
// };

check_by = CHECK_BY::CUSTOM;
check_by_target = [this]()
{ return attach_function_(); };
};
bool attach_function() { return true; }
bool attach_function_()
{
#ifndef _WIN64
return InsertRenpyHook();
#else
return InsertRenpyHook()||InsertRenpy3Hook();
#endif
#else
return InsertRenpyHook() || InsertRenpy3Hook();
#endif
}
};
1 change: 0 additions & 1 deletion cpp/LunaHook/LunaHook/engines/python/python2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,5 @@ bool InsertRenpyHook()
}
}
}
ConsoleOutput("Ren'py failed: failed to find python2X.dll");
return false;
}
2 changes: 1 addition & 1 deletion cpp/version.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

set(VERSION_MAJOR 5)
set(VERSION_MINOR 58)
set(VERSION_PATCH 4)
set(VERSION_PATCH 5)
set(VERSION_REVISION 0)
add_definitions(-DVERSION_MAJOR=${VERSION_MAJOR})
add_definitions(-DVERSION_MINOR=${VERSION_MINOR})
Expand Down
4 changes: 0 additions & 4 deletions docs/en/useapis/ocrapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,6 @@ If your account has multiple applications, the last application you operated wil

https://www.xfyun.cn/doc/platform/quickguide.html

#### **Feishu**

https://open.feishu.cn/document/server-docs/ai/optical_char_recognition-v1/basic_recognize

#### **Google Cloud Vision**

https://cloud.google.com/vision/docs
Expand Down
4 changes: 0 additions & 4 deletions docs/en/useapis/tsapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,6 @@ https://yandex.cloud/en/services/translate

https://www.huaweicloud.com/product/nlpmt.html

#### **Feishu**

https://open.feishu.cn/document/server-docs/ai/translation-v1/translate

#### **IBM**

https://cloud.ibm.com/apidocs/language-translator
Expand Down
4 changes: 2 additions & 2 deletions docs/other/README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

- **HOOK** Supports obtaining text using HOOK methods, supports the use of special codes, supports automatic saving of games and HOOKs, automatic loading of HOOKs, etc. For some engines, it also supports embedded translation. For games that are not supported or not well supported, please [submit feedback](https://github.com/HIllya51/LunaTranslator/issues/new?assignees=&labels=enhancement&projects=&template=01_game_request.yaml)

- **OCR** supports **offline OCR** (in addition to the built-in OCR engine, it also supports WindowsOCR, Tesseract5, manga-ocr, WeChat/QQ OCR) and **online OCR** (Baidu, Youdao, Feishu, iFlytek, Google Lens, Google Cloud Vision, docsumo, ocrspace, Gemini, ChatGPT-compatible interfaces).
- **OCR** supports **offline OCR** (in addition to the built-in OCR engine, it also supports WindowsOCR, Tesseract5, manga-ocr, WeChat/QQ OCR) and **online OCR** (Baidu, Youdao, iFlytek, Google Lens, Google Cloud Vision, docsumo, ocrspace, Gemini, ChatGPT-compatible interfaces).

- **Clipboard** Supports obtaining text from the clipboard for translation

Expand All @@ -32,7 +32,7 @@ Supports almost all conceivable translation engines, including:

- **Free Online Translation** Supports Baidu, Bing, Google, Alibaba, Youdao, Caiyun, Sogou, iFlytek, Tencent, ByteDance, Volcano, DeepL/DeepLX, papago, yandex, lingva, reverso, TranslateCom, ModernMT

- **Registered Online Translation** Supports user-registered **traditional translation** (Baidu, Tencent, Youdao, Xiaoniu, Caiyun, Volcano, DeepL, yandex, google, ibm, Azure, Lark) and **large model translation** (ChatGPT compatible interface, claude, cohere, gemini, Baidu Qianfan, Tencent Hunyuan)
- **Registered Online Translation** Supports user-registered **traditional translation** (Baidu, Tencent, Youdao, Xiaoniu, Caiyun, Volcano, DeepL, yandex, google, ibm, Azure) and **large model translation** (ChatGPT compatible interface, claude, cohere, gemini, Baidu Qianfan, Tencent Hunyuan)

- **Offline Translation** Supports **traditional translation** (J Beijing 7, Kingsoft, Yidiantong, ezTrans, Sugoi, MT5) and offline deployed **large model translation** (ChatGPT compatible interface, Sakura large model)

Expand Down
4 changes: 2 additions & 2 deletions docs/other/README_ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
- **HOOK** Поддерживает получение текста с использованием метода HOOK, поддерживает использование специальных кодов, поддерживает автоматическое сохранение игр и HOOK, автоматическое загрузка HOOK и т.д. Для некоторых движков также поддерживается встроенная трансляция. Для игр, которые не поддерживаются или плохо поддерживаются, пожалуйста, [отправьте обратную связь](https://github.com/HIllya51/LunaTranslator/issues/new?assignees=&labels=enhancement&projects=&template=01_game_request.yaml)


- **OCR** поддерживает **офлайн OCR** (помимо встроенного OCR-движка, также поддерживает WindowsOCR, Tesseract5, manga-ocr, WeChat/QQ OCR) и **онлайн OCR** (Baidu, Youdao, Feishu, iFlytek, Google Lens, Google Cloud Vision, docsumo, ocrspace, Gemini, совместимые интерфейсы ChatGPT).
- **OCR** поддерживает **офлайн OCR** (помимо встроенного OCR-движка, также поддерживает WindowsOCR, Tesseract5, manga-ocr, WeChat/QQ OCR) и **онлайн OCR** (Baidu, Youdao, iFlytek, Google Lens, Google Cloud Vision, docsumo, ocrspace, Gemini, совместимые интерфейсы ChatGPT).

- **Буфер обмена** Поддерживает получение текста из буфера обмена для перевода

Expand All @@ -33,7 +33,7 @@

- **Бесплатные онлайн переводы** Поддерживает использование Baidu, Bing, Google, Alibaba, Youdao, Caiyun, Sogou, iFlytek, Tencent, ByteDance, Volcano, DeepL/DeepLX, papago, yandex, lingva, reverso, TranslateCom, ModernMT

- **Зарегистрированные онлайн переводы** Поддерживает использование зарегистрированных пользователем **традиционных переводов** ( Baidu, Tencent, Youdao, Xiaoniu, Caiyun, Volcano, DeepL, yandex, google, ibm, Azure, Lark ) и **больших моделей перевода** ( интерфейс совместимый с ChatGPT, claude, cohere, gemini, Baidu Qianfan, Tencent Hunyuan )
- **Зарегистрированные онлайн переводы** Поддерживает использование зарегистрированных пользователем **традиционных переводов** ( Baidu, Tencent, Youdao, Xiaoniu, Caiyun, Volcano, DeepL, yandex, google, ibm, Azure ) и **больших моделей перевода** ( интерфейс совместимый с ChatGPT, claude, cohere, gemini, Baidu Qianfan, Tencent Hunyuan )

- **Оффлайн перевод** Поддерживает **традиционный перевод** ( J Beijing 7, Kingsoft, Yidiantong, ezTrans, Sugoi, MT5 ) и оффлайн развернутый **большой модельный перевод** ( интерфейс совместимый с ChatGPT, Sakura большой модель )

Expand Down
4 changes: 0 additions & 4 deletions docs/ru/useapis/ocrapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,6 @@ https://www.volcengine.com/docs/6790/116978

https://www.xfyun.cn/doc/platform/quickguide.html

#### **Feishu**

https://open.feishu.cn/document/server-docs/ai/optical_char_recognition-v1/basic_recognize

#### **Google Cloud Vision**

https://cloud.google.com/vision/docs
Expand Down
4 changes: 0 additions & 4 deletions docs/ru/useapis/tsapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,6 @@ https://yandex.cloud/en/services/translate

https://www.huaweicloud.com/product/nlpmt.html

#### **Feishu**

https://open.feishu.cn/document/server-docs/ai/translation-v1/translate

#### **IBM**

https://cloud.ibm.com/apidocs/language-translator
Expand Down
4 changes: 2 additions & 2 deletions docs/zh/useapis/ocrapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ https://www.volcengine.com/docs/6790/116978

https://www.xfyun.cn/doc/platform/quickguide.html

#### **飞书**
<!-- #### **飞书**
https://open.feishu.cn/document/server-docs/ai/optical_char_recognition-v1/basic_recognize
https://open.feishu.cn/document/server-docs/ai/optical_char_recognition-v1/basic_recognize -->

#### **Google Cloud Vision**

Expand Down
4 changes: 2 additions & 2 deletions docs/zh/useapis/tsapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ https://yandex.cloud/en/services/translate

https://www.huaweicloud.com/product/nlpmt.html

#### **飞书**
<!-- #### **飞书**
https://open.feishu.cn/document/server-docs/ai/translation-v1/translate
https://open.feishu.cn/document/server-docs/ai/translation-v1/translate -->

#### **IBM**

Expand Down
2 changes: 1 addition & 1 deletion py/LunaTranslator/gui/usefulwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def dedumpmodel(self, col):
def removeselectedrows(self):
curr = self.currentIndex()
if not curr.isValid():
return
return []
row = curr.row()
col = curr.column()
skip = []
Expand Down
8 changes: 3 additions & 5 deletions py/LunaTranslator/myutils/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
parsemayberegexreplace,
safe_escape,
is_ascii_symbo,
is_ascii_control
is_ascii_control,
)
from myutils.config import (
postprocessconfig,
Expand Down Expand Up @@ -191,10 +191,8 @@ def _13_fEX(line: str):


def _1_f(line):
r = re.compile(r"\{(.*?)/.*?\}")
line = r.sub(lambda x: x.groups()[0], line)
r = re.compile(r"\{(.*?):.*?\}")
line = r.sub(lambda x: x.groups()[0], line)
line = re.sub(r"\{(\w+)\}(.*?)\{\/\1\}", r"\2", line)
line = re.sub(r"\{(.*?)[:/](.*?)\}", r"\1", line)
return line


Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 78c88da

Please sign in to comment.