{"id":22843351,"url":"https://github.com/milahu/translate-richtext","last_synced_at":"2026-07-09T10:31:10.037Z","repository":{"id":225814150,"uuid":"766932763","full_name":"milahu/translate-richtext","owner":"milahu","description":"translate rich-text documents between human languages, online or offline","archived":false,"fork":false,"pushed_at":"2024-03-16T13:59:47.000Z","size":146,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-19T12:44:21.250Z","etag":null,"topics":["argos-translate","deepl-translate","document-translator","google-translate","html-translator","human-languages","offline-translator","translate-html","translation","translator"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/milahu.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-04T12:01:30.000Z","updated_at":"2024-07-31T12:44:32.000Z","dependencies_parsed_at":"2024-03-04T13:29:11.777Z","dependency_job_id":"3ff995db-c433-4237-b246-5220b950ac83","html_url":"https://github.com/milahu/translate-richtext","commit_stats":null,"previous_names":["milahu/translate-richtext"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/milahu/translate-richtext","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milahu%2Ftranslate-richtext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milahu%2Ftranslate-richtext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milahu%2Ftranslate-richtext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milahu%2Ftranslate-richtext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/milahu","download_url":"https://codeload.github.com/milahu/translate-richtext/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milahu%2Ftranslate-richtext/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35296693,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-09T02:00:07.329Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["argos-translate","deepl-translate","document-translator","google-translate","html-translator","human-languages","offline-translator","translate-html","translation","translator"],"created_at":"2024-12-13T02:14:26.838Z","updated_at":"2026-07-09T10:31:10.010Z","avatar_url":"https://github.com/milahu.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# translate richtext\n\ntranslate rich-text documents between human languages, online or offline\n\nsolve two conflicting goals:\n\n1. preserve the original structure of the document, including whitespace, newlines, indents\n2. preserve sentences across structure boundaries like `\u003cp\u003e\u003cb\u003ehello\u003c/b\u003e world.\u003c/p\u003e`\n\n\n\n## use cases\n\n- translate text documents: html, epub, odt, docx, pdf, rtf, latex\n- translate video subtitles: srt, vtt\n\n\n\n## challenges\n\n\n\n### preserve sentences\n\nsentences may be broken by\n\n- newlines in the source text\n- markup tags\n\nthis is a problem, because when we feed sentence-parts to translators,\nthen the translators will return worse quality\nthan in the case, where we feed full sentences to translators\n\n\n\n### align similar texts\n\nour solution is using two translations:\n\n1. a \"splitted\" translation\n2. a \"joined\" translation\n\nthe \"splitted\" translation serves as a \"sourcemap\",\nit has the correct positions of sentence-parts,\nbut the translation has worse quality,\nbecause sentences are broken into sentence-parts.\n\nthe \"joined\" translation provides the translated sentences,\nwith better quality than the \"splitted\" translation,\nbut the locations of sentence-parts are lost.\n\ncurrently, we align the two translations with a \"character diff\":\n\n```sh\ngit diff --word-diff=color --word-diff-regex=. --no-index \\\n  $(readlink -f translation.joined.txt) \\\n  $(readlink -f translation.splitted.txt) |\nsed -E $'s/\\e\\[32m.*?\\e\\[m//g; s/\\e\\\\[[0-9;:]*[a-zA-Z]//g' |\ntail -n +6 \u003etranslation.aligned.txt\n```\n\n\n\n## related\n\n- [produce sourcemap of translation argos-translate#372](https://github.com/argosopentech/argos-translate/issues/372)\n- [Prohibit the translation of pieces of text in Google Translate](https://webapps.stackexchange.com/questions/52668/prohibit-the-translation-of-pieces-of-text-in-google-translate/154694#154694)\n\n\n\n### similar projects\n\n- [argos-translate](https://github.com/argosopentech/argos-translate) - Open-source offline translation library written in Python\n  - [argos-translate-files](https://github.com/LibreTranslate/argos-translate-files)\n  - [argos-translate-html](https://github.com/argosopentech/translate-html) - too simple, no merging of \"splitted\" and \"joined\" translations\n- [subtitlestranslator.com](https://subtitlestranslator.com/en/translate.php)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmilahu%2Ftranslate-richtext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmilahu%2Ftranslate-richtext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmilahu%2Ftranslate-richtext/lists"}