{"id":42513289,"url":"https://github.com/foyoux/docts","last_synced_at":"2026-01-28T14:16:54.229Z","repository":{"id":57423412,"uuid":"381055892","full_name":"foyoux/docts","owner":"foyoux","description":"翻译 xlf 文件","archived":false,"fork":false,"pushed_at":"2024-09-03T03:14:55.000Z","size":25903,"stargazers_count":18,"open_issues_count":2,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-27T19:06:35.141Z","etag":null,"topics":["chm","document","sisulizer","translate","xlf"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/foyoux.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-28T14:15:15.000Z","updated_at":"2025-01-17T18:49:03.000Z","dependencies_parsed_at":"2022-09-07T01:11:17.242Z","dependency_job_id":null,"html_url":"https://github.com/foyoux/docts","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/foyoux/docts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foyoux%2Fdocts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foyoux%2Fdocts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foyoux%2Fdocts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foyoux%2Fdocts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/foyoux","download_url":"https://codeload.github.com/foyoux/docts/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foyoux%2Fdocts/sbom","scorecard":{"id":408310,"data":{"date":"2025-08-11","repo":{"name":"github.com/foyoux/docts","commit":"77cf026cce8a0363d9f87bfc7df4bbb120241182"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.2,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":1,"reason":"Found 1/8 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: topLevel 'contents' permission set to 'write': .github/workflows/python-publish.yml:17","Warn: no topLevel permission defined: .github/workflows/started-notify.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python-publish.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/foyoux/docts/python-publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python-publish.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/foyoux/docts/python-publish.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/python-publish.yml:40: update your workflow using https://app.stepsecurity.io/secureworkflow/foyoux/docts/python-publish.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/python-publish.yml:44: update your workflow using https://app.stepsecurity.io/secureworkflow/foyoux/docts/python-publish.yml/main?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/python-publish.yml:33","Warn: pipCommand not pinned by hash: .github/workflows/python-publish.yml:34","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned","Info:   0 out of   2 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: GNU General Public License v3.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Signed-Releases","score":0,"reason":"Project has not signed or included provenance with any releases.","details":["Warn: release artifact v0.2.3 not signed: https://api.github.com/repos/foyoux/docts/releases/101200649","Warn: release artifact v0.2.2 not signed: https://api.github.com/repos/foyoux/docts/releases/101073460","Warn: release artifact v0.2.1 not signed: https://api.github.com/repos/foyoux/docts/releases/101064197","Warn: release artifact v0.2.0 not signed: https://api.github.com/repos/foyoux/docts/releases/101061657","Warn: release artifact v0.1.0 not signed: https://api.github.com/repos/foyoux/docts/releases/54172420","Warn: release artifact v0.2.3 does not have provenance: https://api.github.com/repos/foyoux/docts/releases/101200649","Warn: release artifact v0.2.2 does not have provenance: https://api.github.com/repos/foyoux/docts/releases/101073460","Warn: release artifact v0.2.1 does not have provenance: https://api.github.com/repos/foyoux/docts/releases/101064197","Warn: release artifact v0.2.0 does not have provenance: https://api.github.com/repos/foyoux/docts/releases/101061657","Warn: release artifact v0.1.0 does not have provenance: https://api.github.com/repos/foyoux/docts/releases/54172420"],"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-18T21:57:37.978Z","repository_id":57423412,"created_at":"2025-08-18T21:57:37.978Z","updated_at":"2025-08-18T21:57:37.978Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28846058,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T13:02:32.985Z","status":"ssl_error","status_checked_at":"2026-01-28T13:02:04.945Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chm","document","sisulizer","translate","xlf"],"created_at":"2026-01-28T14:16:53.690Z","updated_at":"2026-01-28T14:16:54.223Z","avatar_url":"https://github.com/foyoux.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# docts\n\n`docts` 是一个利用 pygtrans 库翻译和处理 XLF 文件的 Python 包。\n\n## 功能简介\n\n- **XLF 文件解析**：提取 XLF 文件中的源文本。\n- **文本过滤**：通过自定义过滤器，排除不需要翻译的内容。\n- **文本映射**：替换特定符号或字符串。\n- **批量翻译**：利用 Google 翻译 API 进行批量翻译。\n- **XLF 文件写入**：将翻译结果写回新的 XLF 文件。\n\n## 安装\n\n你可以通过以下几种方式安装 `docts`：\n\n```sh\npip install -U docts\npip install git+ssh://git@github.com/foyoux/docts.git\npip install git+https://github.com/foyoux/docts.git\n```\n\n## 使用方法\n\n### 基本使用\n\n`docts` 主要用于将 XLF 文件中的内容提取、翻译并重新保存。以下是一个基本的使用示例：\n\n```python\nfrom pygtrans import Translate\nfrom docts import Docts\n\nif __name__ == '__main__':\n    # 创建翻译客户端，指定代理（如有需要）\n    translator = Translate(proxies={'https': 'http://localhost:10809'})\n    \n    # 初始化 Docts 实例，指定 XLF 文件路径和翻译客户端\n    doc = Docts('\u003cxlf_file_path\u003e', translator)\n    \n    # 过滤无效或不需要翻译的文本（可选）\n    doc.add_filter(lambda word: 'filter_condition' in word)\n    \n    # 执行翻译并保存结果，翻译后的 XLF 文件将保存在同一目录下\n    translated_file_path = doc.save_words()\n    print(f\"翻译完成，结果保存至: {translated_file_path}\")\n```\n\n### 进阶使用\n\n#### 自定义过滤器\n\n你可以通过添加不同的过滤器来定制处理流程。例如，过滤掉所有包含等号（`=`）的行：\n\n```python\ndoc.add_filter(lambda word: '=' in word)\n```\n\n#### 使用正则表达式过滤\n\n支持通过正则表达式过滤文本。例如，过滤所有以 `error` 开头的字符串：\n\n```python\nimport re\n\ndoc.add_contain_filter(re.compile(r'^error'))\n```\n\n#### 自定义文本映射\n\n将特定符号映射为其他符号，例如将 `•` 替换为 `●`：\n\n```python\ndoc.add_map(lambda word: word.replace('•', '●'))\n```\n\n#### 重置过滤\n\n如果想要撤销之前的过滤操作，可以使用 `reset()` 方法恢复原始文本列表：\n\n```python\ndoc.reset()\n```\n\n#### 保存忽略的文本\n\n除了保存翻译结果外，你还可以将被过滤掉的文本单独保存：\n\n```python\nignored_file_path = doc.save_ignores()\nprint(f\"忽略的文本已保存至: {ignored_file_path}\")\n```\n\n## 具体流程\n\n请参阅 [旧文档](https://github.com/foyoux/docts/wiki/%E6%97%A7%E6%96%87%E6%A1%A3) （仅作参考）。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoyoux%2Fdocts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffoyoux%2Fdocts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoyoux%2Fdocts/lists"}