{"id":16827552,"url":"https://github.com/brettdong/polib","last_synced_at":"2026-03-05T17:41:54.134Z","repository":{"id":57656881,"uuid":"445798836","full_name":"BrettDong/polib","owner":"BrettDong","description":"A Rust library for loading translation data in GNU gettext PO format.","archived":false,"fork":false,"pushed_at":"2025-05-02T12:04:43.000Z","size":107,"stargazers_count":11,"open_issues_count":7,"forks_count":8,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-02T13:23:02.323Z","etag":null,"topics":["gettext","i18n","rust"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/polib","language":"Rust","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/BrettDong.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2022-01-08T11:19:23.000Z","updated_at":"2025-05-02T12:04:47.000Z","dependencies_parsed_at":"2025-02-08T07:20:00.981Z","dependency_job_id":"ede7404b-1864-4b1e-bbf8-62016878a0f8","html_url":"https://github.com/BrettDong/polib","commit_stats":{"total_commits":49,"total_committers":2,"mean_commits":24.5,"dds":"0.020408163265306145","last_synced_commit":"a1b9b57d8b4afd7ddb17f23b234e5a0035a35ee3"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/BrettDong/polib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrettDong%2Fpolib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrettDong%2Fpolib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrettDong%2Fpolib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrettDong%2Fpolib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BrettDong","download_url":"https://codeload.github.com/BrettDong/polib/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrettDong%2Fpolib/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270135753,"owners_count":24533349,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"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":["gettext","i18n","rust"],"created_at":"2024-10-13T11:21:45.785Z","updated_at":"2026-03-05T17:41:54.051Z","avatar_url":"https://github.com/BrettDong.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `polib`\n\n[![crates.io](https://img.shields.io/crates/v/polib.svg)](https://crates.io/crates/polib)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n![GitHub Actions](https://github.com/BrettDong/polib/actions/workflows/test.yaml/badge.svg)\n\nA Rust library to read, manipulate and write GNU gettext translation data in `.po` format.\n\n## Basic Concepts\n\nA **Message** represents a translation of a text entry from the source language to a target language. \n\nA **Catalog** holds a collection of _Messages_, and is stored in a `.po` file. \n\n## Example\n\n### Iterate over messages in a `.po` file\n\n```rust\nuse polib::po_file;\nuse std::error::Error;\nuse std::path::Path;\n\nfn main() -\u003e Result\u003c(), Box\u003cdyn Error\u003e\u003e {\n    let catalog = po_file::parse(Path::new(\"foo.po\"))?;\n    for message in catalog.messages() {\n        if message.is_translated() {\n            if message.is_singular() {\n                println!(\"{} =\u003e {}\", message.msgid(), message.msgstr()?);\n            } else { // message.is_plural()\n                println!(\"{} =\u003e {}\", message.msgid(), message.msgstr_plural()?.join(\", \"));\n            }\n        } else {\n            println!(\"{} is untranslated\", message.msgid());\n        }\n    }\n    Ok(())\n}\n```\n\n### Remove untranslated or fuzzy entries and save to another `.po` file\n\n```rust\nlet mut catalog = po_file::parse(Path::new(\u0026input_file))?;\nlet mut filtered: usize = 0;\nfor mut message in catalog.messages_mut() {\n    if !message.is_translated() || message.is_fuzzy() {\n        message.delete();\n        filtered += 1;\n    }\n}\npo_file::write_to_file(\u0026catalog, Path::new(\u0026output_file))?;\nprintln!(\"{} untranslated or fuzzy translations removed.\", filtered);\n```\n\n### Fill in missing translations from some other translation service\n\n```rust\nlet mut catalog = po_file::parse(Path::new(\u0026input_file))?;\nfor mut message in catalog.messages_mut() {\n    if !message.is_translated() {\n        if message.is_singular() {\n            message.set_msgstr(/* some 3rdparty provided */translate(message.msgid()))?;\n        }\n    }\n}\npo_file::write_to_file(\u0026catalog, Path::new(\u0026output_file))?;\n```\n\n### Compile a `.po` file to `.mo` format\n\n```rust\nmo_file::compile_from_po(Path::new(\u0026input), Path::new(\u0026output))?;\n```\n\n## Documentation\n\nRefer to [docs.rs](https://docs.rs/polib).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrettdong%2Fpolib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrettdong%2Fpolib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrettdong%2Fpolib/lists"}