Skip to content

Commit

Permalink
feat: ✨ 实现 i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
hymbz committed Sep 22, 2023
1 parent a8ff838 commit e998a0e
Show file tree
Hide file tree
Showing 62 changed files with 917 additions and 463 deletions.
18 changes: 18 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const publicConfig = {

'consistent-return': 'off',
},
reportUnusedDisableDirectives: true,
};

/** 与公用规则合并 */
Expand Down Expand Up @@ -177,5 +178,22 @@ module.exports = {
'import/no-extraneous-dependencies': 'off',
},
}),
buildConfig({
plugins: ['i18n', 'i18next'],
files: ['src/**/*.ts', 'src/**/*.tsx'],
excludedFiles: [
'display.*',
'*.test.*',
'vite.config.ts',
'**/helper/import.ts',
'**/helper/dmzjApi.ts',
'src/*.*',
'src/site/!(other|nhentai|ehentai).tsx',
],
rules: {
'i18next/no-literal-string': 'error',
'i18n/no-chinese-character': 'error',
},
}),
],
};
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"lokalise.i18n-ally"
]
}
36 changes: 36 additions & 0 deletions .vscode/i18n-ally-custom-framework.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# .vscode/i18n-ally-custom-framework.yml

# An array of strings which contain Language Ids defined by VS Code
# You can check available language ids here: https://code.visualstudio.com/docs/languages/identifiers
languageIds:
- javascript
- typescript
- javascriptreact
- typescriptreact

# An array of RegExes to find the key usage. **The key should be captured in the first match group**.
# You should unescape RegEx strings in order to fit in the YAML file
# To help with this, you can use https://www.freeformatter.com/json-escape.html
usageMatchRegex:
# The following example shows how to detect `t("your.i18n.keys")`
# the `{key}` will be placed by a proper keypath matching regex,
# you can ignore it and use your own matching rules as well
- "[^\\w\\d]t\\(\\s*['\"`]({key})['\"`]"

# A RegEx to set a custom scope range. This scope will be used as a prefix when detecting keys
# and works like how the i18next framework identifies the namespace scope from the
# useTranslation() hook.
# You should unescape RegEx strings in order to fit in the YAML file
# To help with this, you can use https://www.freeformatter.com/json-escape.html
# scopeRangeRegex: "useTranslation\\(\\s*\\[?\\s*['\"`](.*?)['\"`]"

# An array of strings containing refactor templates.
# The "$1" will be replaced by the keypath specified.
# Optional: uncomment the following two lines to use

refactorTemplates:
- t('$1')


# If set to true, only enables this custom framework (will disable all built-in frameworks)
monopoly: true
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,11 @@
"**/node_modules/*/**",
"**/*.js"
],
"i18n-ally.displayLanguage": "zh",
"i18n-ally.localesPaths": [
"locales"
],
"i18n-ally.pathMatcher": "{locale}.{ext}",
"i18n-ally.keystyle": "nested",
"i18n-ally.sortKeys": true,
}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

这是一个因为目前大部分漫画站都不支持双页显示,所以每次遇到 **漫画中的跨页大图被分割成两页** 就很不爽的人为了有更好的漫画阅读体验而写的油猴脚本,为主流漫画站增加了**双页阅读模式**和优化体验的增强功能。

脚本会在网页右下角弹出用于 **进入阅读模式** 的悬浮按钮,其上的快捷按钮用于切换站点增强功能的开启与否,脚本默认开启了**自动进入阅读模式**的功能,也可在这里关闭。脚本没有全局设置,所有修改都只会在当前站点生效保存。~~反正平时也就只上那几个站点~~
脚本会在网页右下角弹出用于 **进入阅读模式** 的悬浮按钮,其上的快捷按钮用于切换站点增强功能的开启与否,默认会开启**自动进入阅读模式**的功能,也可在这里关闭。脚本没有全局设置,所有修改都只会在当前站点生效保存。~~反正平时也就只上那几个站点~~

对于支持站点以外的网站,脚本也提供了「[简易阅读模式](#简易阅读模式)」,除了得手动跳转上/下一话外,和支持站点的使用体验没有区别。

Expand Down Expand Up @@ -99,7 +99,7 @@ Cotrans 也有自己的油猴脚本 —— 「[Cotrans 漫画/图片翻译器](h
- 动漫之家
- 解锁隐藏漫画
- [ehentai](#ehentai)
- [nhentai 匹配](#nhentai匹配)
- [关联 nhentai](#关联-nhentai)
- [nhentai](#nhentai)
- [彻底屏蔽漫画](#彻底屏蔽漫画)
- [自动翻页](#自动翻页)
Expand Down Expand Up @@ -152,9 +152,9 @@ Cotrans 也有自己的油猴脚本 —— 「[Cotrans 漫画/图片翻译器](h

除悬浮按钮外,也会在右侧边栏会增加一个「Load comic」按钮,功能和悬浮按钮一样。

### nhentai匹配
### 关联 nhentai

根据漫画标题匹配 nhentai 的本子,结果会以标签的形式显示在标签栏中,标签内容为 nhentai 上的漫画 ID ,鼠标悬停在标签上可以看到漫画标题。
根据漫画标题关联匹配 nhentai 的本子,结果会以标签的形式显示在标签栏中,标签内容为 nhentai 上的漫画 ID ,鼠标悬停在标签上可以看到漫画标题。

点击标签后,标签菜单有两个选项:

Expand Down
9 changes: 5 additions & 4 deletions docs/README-out.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

这是一个因为目前大部分漫画站都不支持双页显示,所以每次遇到 **漫画中的跨页大图被分割成两页** 就很不爽的人为了有更好的漫画阅读体验而写的油猴脚本,为主流漫画站增加了**双页阅读模式**和优化体验的增强功能。

脚本会在网页右下角弹出用于 **进入阅读模式** 的悬浮按钮,其上的快捷按钮用于切换站点增强功能的开启与否,脚本默认开启了**自动进入阅读模式**的功能,也可在这里关闭。脚本没有全局设置,所有修改都只会在当前站点生效保存。~~反正平时也就只上那几个站点~~
脚本会在网页右下角弹出用于 **进入阅读模式** 的悬浮按钮,其上的快捷按钮用于切换站点增强功能的开启与否,默认会开启**自动进入阅读模式**的功能,也可在这里关闭。脚本没有全局设置,所有修改都只会在当前站点生效保存。~~反正平时也就只上那几个站点~~

对于支持站点以外的网站,脚本也提供了「[简易阅读模式](#简易阅读模式)」,除了得手动跳转上/下一话外,和支持站点的使用体验没有区别。

Expand Down Expand Up @@ -99,11 +99,12 @@ Cotrans 也有自己的油猴脚本 —— 「[Cotrans 漫画/图片翻译器](h
- 动漫之家
- 解锁隐藏漫画
- [ehentai](#ehentai)
- [nhentai 匹配](#nhentai匹配)
- [关联 nhentai](#关联-nhentai)
- [nhentai](#nhentai)
- [彻底屏蔽漫画](#彻底屏蔽漫画)
- [自动翻页](#自动翻页)

<!-- 根据 src/index.ts 自动生成 -->
<!-- supportSiteList -->

- PonpomuYuri
Expand Down Expand Up @@ -151,9 +152,9 @@ Cotrans 也有自己的油猴脚本 —— 「[Cotrans 漫画/图片翻译器](h

除悬浮按钮外,也会在右侧边栏会增加一个「Load comic」按钮,功能和悬浮按钮一样。

### nhentai匹配
### 关联 nhentai

根据漫画标题匹配 nhentai 的本子,结果会以标签的形式显示在标签栏中,标签内容为 nhentai 上的漫画 ID ,鼠标悬停在标签上可以看到漫画标题。
根据漫画标题关联匹配 nhentai 的本子,结果会以标签的形式显示在标签栏中,标签内容为 nhentai 上的漫画 ID ,鼠标悬停在标签上可以看到漫画标题。

点击标签后,标签菜单有两个选项:

Expand Down
1 change: 1 addition & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
223 changes: 221 additions & 2 deletions locales/zh.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,224 @@
{
"tooltip": {
"fill_page": "填充页"
"alert": {
"comic_load_error": "漫画加载出错",
"get_comic_img_failed": "获取漫画图片失败",
"img_load_failed": "图片加载失败",
"repeat_load": "加载图片中,请稍候",
"server_connection_failed": "无法连接到服务器"
},
"button": {
"close_current_page_translation": "关闭当前页的翻译",
"download": "下载",
"download_completed": "下载完成",
"download_failed": "下载失败",
"downloading": "下载中",
"exit": "退出",
"page_fill": "页面填充",
"page_mode_double": "双页模式",
"page_mode_single": "单页模式",
"scroll_mode": "卷轴模式",
"setting": "设置",
"start_packaging": "开始打包",
"translate_current_page": "翻译当前页",
"zoom_in": "放大"
},
"end_page": {
"next_button": "下一话",
"prev_button": "上一话",
"tip": {
"end_jump": "已到结尾,继续向下翻页将跳至下一话",
"exit": "已到结尾,继续翻页将退出",
"start_jump": "已到开头,继续向上翻页将跳至上一话"
}
},
"hotkeys": {
"exit": "退出",
"jump_to_end": "跳至尾页",
"jump_to_home": "跳至首页",
"switch_dir": "切换阅读方向",
"switch_page_fill": "切换页面填充",
"switch_scroll_mode": "切换卷轴模式",
"switch_single_double_page_mode": "切换单双页模式",
"turn_page_down": "向下翻页",
"turn_page_left": "向左翻页",
"turn_page_right": "向右翻页",
"turn_page_up": "向上翻页",
"use_read_mode": "进入阅读模式"
},
"img_status": {
"error": "加载出错",
"loading": "正在加载",
"wait": "等待加载"
},
"language": {
"en": "英文",
"zh": "中文"
},
"other": {
"auto_use_read_mode": "自动进入阅读模式",
"disable": "禁用",
"fab_hidden": "隐藏悬浮按钮",
"fab_show": "显示悬浮按钮",
"fill_page": "填充页",
"img_loading": "图片加载中",
"loading_img": "加载图片中",
"read_mode": "阅读模式",
"use_comic_read_mode": "进入漫画阅读模式"
},
"pwa": {
"alert": {
"img_data_error": "图片数据错误",
"img_not_found": "找不到图片",
"img_not_found_dir": "文件夹下没有图片文件或含有图片文件的压缩包",
"img_not_found_files": "请选择图片文件或含有图片文件的压缩包",
"repeat_load": "正在加载其他文件中...",
"unzip_error": "解压出错",
"unzip_password_error": "解压密码错误",
"userscript_not_installed": "未安装 ComicRead 脚本"
},
"button": {
"install": "安装",
"no_more_prompt": "不再提示",
"resume_read": "恢复阅读",
"select_dir": "选择文件夹",
"select_files": "选择文件"
},
"install_md": "### 每次都要打开这个网页很麻烦?\n如果你希望\n1. 能有独立的窗口,像是在使用本地软件一样\n1. 加入本地压缩文件的打开方式之中,方便直接打开\n1. 离线使用~~(主要是担心国内网络抽风无法访问这个网页~~\n### 欢迎将本页面作为 PWA 应用安装到电脑上😃👍",
"message": {
"input_password": "请输入密码",
"unzipping": "解压缩中"
},
"tip_md": "# ComicRead PWA\n使用 [ComicRead](https://github.com/hymbz/ComicReadScript) 的阅读模式阅读**本地**漫画\n---\n### 将图片文件、文件夹、压缩包直接拖入即可开始阅读"
},
"setting": {
"hotkeys": {
"add": "添加新快捷键",
"recover": "恢复默认快捷键"
},
"language": "语言",
"option": {
"always_load_all_img": "始终加载所有图片",
"background_color": "背景颜色",
"click_page_turn_enabled": "启用点击翻页",
"click_page_turn_lr_reverse": "左右反转点击区域",
"click_page_turn_vertical": "上下翻页",
"dark_mode": "启用夜间模式",
"dir_ltr": "从左到右(美漫)",
"dir_rtl": "从右到左(日漫)",
"disable_zoom_in": "禁止放大图片",
"first_page_fill": "默认启用首页填充",
"jump_to_next": "翻页至上/下一话",
"paragraph_dir": "阅读方向",
"paragraph_display": "显示",
"paragraph_hotkeys": "快捷键",
"paragraph_operation": "操作",
"paragraph_other": "其他",
"paragraph_scrollbar": "滚动条",
"paragraph_translation": "翻译",
"reverse_page_turn_key": "左右翻页键反转",
"scrollbar_auto_hidden": "自动隐藏滚动条",
"scrollbar_show": "显示滚动条",
"scrollbar_show_img_status": "显示图片加载状态",
"show_comment": "在结束页显示评论",
"show_touch_area": "显示点击区域"
},
"translation": {
"cotrans_tip": "<p>将使用 <a href=\"https://cotrans.touhou.ai\" target=\"_blank\">Cotrans</a> 提供的接口翻译图片,该服务器由维护者用爱发电自费维护</p>\n<p>多人同时使用时需要排队等待,等待队列达到上限后再上传新图片会报错,需要过段时间再试</p>\n<p>所以还请 <b>注意用量</b></p>\n<p>更推荐使用本地部署的项目,不占用服务器资源也不需要排队</p>",
"options": {
"detection_resolution": "文本扫描清晰度",
"direction": "渲染字体方向",
"direction_auto": "跟随原文本",
"direction_horizontal": "仅限水平",
"direction_vertical": "仅限垂直",
"forceRetry": "忽略缓存强制重试",
"localUrl": "自定义服务器 URL",
"target_language": "目标语言",
"text_detector": "文本扫描器",
"translator": "翻译服务"
},
"server": "翻译服务器",
"server_selfhosted": "本地部署",
"translate_all_img_switch": "翻译全部图片"
}
},
"site": {
"add_feature": {
"associate_nhentai": "关联nhentai",
"auto_page_turn": "自动翻页",
"block_totally": "彻底屏蔽漫画",
"open_link_new_page": "在新页面中打开链接",
"shortcut_page_turn": "快捷键翻页"
},
"ehentai": {
"fetch_img_page_source_fail": "获取图片页源码失败",
"fetch_img_page_url_fail": "从详情页获取图片页地址失败",
"fetch_img_url_fail": "从图片页获取图片地址失败",
"html_changed_load_fail": "页面结构发生改变,无法加载漫画",
"html_changed_nhentai_fail": "页面结构发生改变,匹配 nhentai 漫画功能无法正常生效",
"ip_banned": "IP地址被禁",
"nhentai_error": "nhentai 匹配出错",
"nhentai_fail": "匹配失败,请在确认登录 {{nhentai}} 后刷新"
},
"nhentai": {
"fetch_next_page_fail": "获取下一页漫画数据失败",
"tag_blacklist_fetch_fail": "标签黑名单获取失败"
},
"remember_current_site": "记住当前站点",
"settings_tip": "设置",
"show_settings_menu": "显示设置菜单",
"simple": {
"auto_read_mode_message": "将在之后默认自动进入阅读模式",
"simple_read_mode": "使用简易阅读模式"
}
},
"touch_area": {
"menu": "菜 单",
"next": "下 一 页",
"prev": "上 一 页"
},
"translation": {
"status": {
"default": "未知状态",
"detection": "正在检测文本",
"downscaling": "正在缩小图片",
"error": "翻译出错",
"error-lang": "你选择的翻译服务不支持你选择的语言",
"error-translating": "翻译服务没有返回任何文本",
"error-with-id": "翻译出错",
"finished": "正在整理结果",
"inpainting": "正在修补图片",
"mask-generation": "正在生成文本掩码",
"ocr": "正在识别文本",
"pending": "正在等待",
"pending-pos": "正在等待",
"rendering": "正在渲染",
"saved": "正在返回缓存结果",
"translating": "正在翻译文本",
"upscaling": "正在放大图片"
},
"tip": {
"check_img_status_failed": "检查图片状态失败",
"download_img_failed": "下载图片失败",
"error": "翻译出错",
"get_translator_list_error": "获取部署服务的可用翻译时出错",
"id_not_returned": "未返回 id",
"img_downloading": "正在下载图片",
"img_not_fully_loaded": "图片未加载完毕",
"pending": "正在等待,列队还有 {{pos}} 张图片",
"translation_completed": "翻译完成",
"upload_error": "图片上传出错",
"upload_return_error": "服务器返回错误",
"wait_translation": "等待翻译"
},
"translator": {
"baidu": "百度",
"deepl": "DeepL",
"google": "谷歌",
"gpt3.5": "GPT-3.5",
"none": "删除文本",
"offline": "离线模型",
"original": "原文",
"youdao": "有道"
}
}
}
Loading

0 comments on commit e998a0e

Please sign in to comment.