Skip to content

Commit

Permalink
feat: 更新中文翻译
Browse files Browse the repository at this point in the history
  • Loading branch information
yuhldr committed Nov 17, 2024
1 parent 858dfd1 commit 0b2067d
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 58 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ test-aur: clear
cp -r ../../../data lfy-${VERSION}/ && \
cp -r ../../../po lfy-${VERSION}/ && \
cp -r ../../../pkg lfy-${VERSION}/ && \
cp -r ../../../lfy.in lfy-${VERSION}/ && \
cp -r ../../../define.in lfy-${VERSION}/ && \
cp -r ../../../lfy.py lfy-${VERSION}/ && \
cp -r ../../../define.py lfy-${VERSION}/ && \
cp -r ../../../meson.build lfy-${VERSION}/ && \
zip -r v${VERSION}.zip lfy-${VERSION} && \
rm -r lfy-${VERSION} && \
Expand Down
1 change: 1 addition & 0 deletions define.in → define.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'初始信息'
import os

APP_NAME = '@APP_NAME@'
Expand Down
13 changes: 7 additions & 6 deletions lfy.in → lfy.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import os
import subprocess
import sys
from gettext import gettext as _

import gi

Expand Down Expand Up @@ -84,14 +85,14 @@ def main():
"""
set_internationalization()

parser = argparse.ArgumentParser(description='命令行翻译或文本识别,如 lfy -t "who am i" -s bing -l 1lfy -o "/tmp/xxx.png" -s baidu -l 1')
parser = argparse.ArgumentParser(description=_('Command line translation or text recognition, such as {} or {}').format('lfy -t "who am i" -s bing -l 1', 'lfy -o "/tmp/xxx.png" -s baidu -l 1'))

parser.add_argument('-t', type=str, help='翻译,后面接文字')
parser.add_argument('-o', type=str, help='识别图片,后面接文件路径')
parser.add_argument('-c', action='store_true', help='自动翻译剪贴板,暂时无效')
parser.add_argument('-t', type=str, help=_('Translate, followed by text'))
parser.add_argument('-o', type=str, help=_('Recognize image, followed by file path'))
parser.add_argument('-c', action='store_true', help=_('Automatically translate clipboard, temporarily invalid'))

parser.add_argument('-s', type=str, help='使用什么服务引擎,若未输入-s,将根据 -t -o 提供帮助', default="", nargs='?')
parser.add_argument('-l', type=int, help='待翻译/识别的语言,若未输入-l,将根据 -s 的输入自动提供对应帮助', default=-1, nargs='?')
parser.add_argument('-s', type=str, help=_('Which service engine to use, if -s is not entered, help will be provided based on -t or -o'), default="", nargs='?')
parser.add_argument('-l', type=int, help=_('The language to be translated/recognized, if -l is not entered, corresponding help will be provided based on the input of -s'), default=-1, nargs='?')

args = parser.parse_args()

Expand Down
4 changes: 2 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ conf.set('PACKAGE_URL_BUG', PACKAGE_URL_BUG)


configure_file(
input: 'define.in',
input: 'define.py',
output: '__init__.py',
configuration: conf,
install: true,
Expand All @@ -61,7 +61,7 @@ configure_file(


configure_file(
input: meson.project_name() + '.in',
input: meson.project_name() + '.py',
output: meson.project_name(),
configuration: conf,
install: true,
Expand Down
18 changes: 11 additions & 7 deletions po/POTFILES
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ data/cool.ldr.lfy.in.in.desktop
data/cool.ldr.lfy.in.gschema.xml
data/resources/cool.ldr.lfy.in.appdata.xml

lfy.py
lfy/main.py
lfy/preference.py
lfy/translate.py
Expand All @@ -11,13 +12,16 @@ lfy/api/utils/__init__.py
lfy/api/utils/bak.py
lfy/api/utils/check_update.py
lfy/api/server/__init__.py
lfy/api/server/baidu.py
lfy/api/server/google.py
lfy/api/server/tencent.py
lfy/api/server/bing.py
lfy/api/server/aliyun.py
lfy/api/server/com.py
lfy/api/server/huoshan.py
lfy/api/server/tra/baidu.py
lfy/api/server/tra/google.py
lfy/api/server/tra/tencent.py
lfy/api/server/tra/bing.py
lfy/api/server/tra/aliyun.py
lfy/api/server/tra/com.py
lfy/api/server/tra/huoshan.py
lfy/api/server/ocr/baidu.py
lfy/api/server/ocr/easyocr.py
lfy/api/server/ocr/pytesseract.py
lfy/widgets/server_preferences.py

data/resources/translate.ui
Expand Down
81 changes: 62 additions & 19 deletions po/lfy.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: cool.ldr.lfy\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2024-09-24 13:36+0800\n"
"POT-Creation-Date: 2024-11-17 17:20+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -185,6 +185,34 @@ msgstr ""
msgid "Basic functions completed"
msgstr ""

#: lfy.py:88
msgid "Command line translation or text recognition, such as {} or {}"
msgstr ""

#: lfy.py:90
msgid "Translate, followed by text"
msgstr ""

#: lfy.py:91
msgid "Recognize image, followed by file path"
msgstr ""

#: lfy.py:92
msgid "Automatically translate clipboard, temporarily invalid"
msgstr ""

#: lfy.py:94
msgid ""
"Which service engine to use, if -s is not entered, help will be provided "
"based on -t or -o"
msgstr ""

#: lfy.py:95
msgid ""
"The language to be translated/recognized, if -l is not entered, "
"corresponding help will be provided based on the input of -s"
msgstr ""

#: lfy/main.py:115
msgid "translator_credits"
msgstr ""
Expand Down Expand Up @@ -227,7 +255,7 @@ msgstr ""
msgid "You can go to {} to view the beta version."
msgstr ""

#: lfy/preference.py:69 lfy/api/server/com.py:74
#: lfy/preference.py:69 lfy/api/server/tra/com.py:67
msgid "compare"
msgstr ""

Expand All @@ -252,9 +280,10 @@ msgid ""
"This time the content contains private information and is not translated"
msgstr ""

#: lfy/translate.py:288 lfy/translate.py:321 lfy/api/server/baidu.py:40
#: lfy/api/server/tencent.py:150 lfy/api/server/aliyun.py:98
#: lfy/api/server/com.py:29 lfy/api/server/huoshan.py:136
#: lfy/translate.py:288 lfy/translate.py:321 lfy/api/server/tra/baidu.py:40
#: lfy/api/server/tra/tencent.py:150 lfy/api/server/tra/aliyun.py:98
#: lfy/api/server/tra/com.py:29 lfy/api/server/tra/huoshan.py:136
#: lfy/api/server/ocr/baidu.py:139
msgid "something error:"
msgstr ""

Expand Down Expand Up @@ -314,60 +343,74 @@ msgstr ""
msgid "Italian"
msgstr ""

#: lfy/api/server/baidu.py:28 lfy/api/server/tencent.py:127
#: lfy/api/server/aliyun.py:68 lfy/api/server/huoshan.py:67
#: lfy/api/server/tra/baidu.py:28 lfy/api/server/tra/tencent.py:127
#: lfy/api/server/tra/aliyun.py:68 lfy/api/server/tra/huoshan.py:67
#: lfy/api/server/ocr/baidu.py:30
msgid "please input API Key in preference"
msgstr ""

#: lfy/api/server/baidu.py:69
#: lfy/api/server/tra/baidu.py:69 lfy/api/server/ocr/baidu.py:91
msgid "baidu"
msgstr ""

#: lfy/api/server/baidu.py:81
#: lfy/api/server/tra/baidu.py:81
msgid "please input app_id and secret_key like:"
msgstr ""

#: lfy/api/server/google.py:45
#: lfy/api/server/tra/google.py:45
msgid "google"
msgstr ""

#: lfy/api/server/google.py:61 lfy/api/server/bing.py:78
#: lfy/api/server/tra/google.py:61 lfy/api/server/tra/bing.py:78
msgid "something error, try other translate engine?"
msgstr ""

#: lfy/api/server/google.py:74
#: lfy/api/server/tra/google.py:74
msgid "The connection timed out. Maybe there is a network problem"
msgstr ""

#: lfy/api/server/tencent.py:64
#: lfy/api/server/tra/tencent.py:64
msgid "tencent"
msgstr ""

#: lfy/api/server/tencent.py:83
#: lfy/api/server/tra/tencent.py:83
msgid "please input secret_id and secret_key like:"
msgstr ""

#: lfy/api/server/bing.py:61
#: lfy/api/server/tra/bing.py:61
msgid "bing"
msgstr ""

#: lfy/api/server/bing.py:131
#: lfy/api/server/tra/bing.py:131
#, python-brace-format
msgid "1000 characters limit! You send {len_text} characters."
msgstr ""

#: lfy/api/server/aliyun.py:120
#: lfy/api/server/tra/aliyun.py:119
msgid "aliyun"
msgstr ""

#: lfy/api/server/aliyun.py:132 lfy/api/server/huoshan.py:178
#: lfy/api/server/tra/aliyun.py:131 lfy/api/server/tra/huoshan.py:178
msgid "please input {} and {} like:"
msgstr ""

#: lfy/api/server/huoshan.py:166
#: lfy/api/server/tra/huoshan.py:166
msgid "huoshan"
msgstr ""

#: lfy/api/server/ocr/baidu.py:162
msgid "please input API Key and Secret Key like:"
msgstr ""

#: lfy/api/server/ocr/easyocr.py:30 lfy/api/server/ocr/pytesseract.py:38
#: lfy/api/server/ocr/pytesseract.py:77
msgid "please install python whl"
msgstr ""

#: lfy/api/server/ocr/pytesseract.py:73
msgid "Tesseract OCR database {} is not installed"
msgstr ""

#: lfy/widgets/server_preferences.py:39
msgid "Text translate"
msgstr ""
Expand Down
Loading

0 comments on commit 0b2067d

Please sign in to comment.