brettdong / polib Goto Github PK
View Code? Open in Web Editor NEWA Rust library for loading translation data in GNU gettext PO format.
Home Page: https://crates.io/crates/polib
License: MIT License
A Rust library for loading translation data in GNU gettext PO format.
Home Page: https://crates.io/crates/polib
License: MIT License
When messages have no context, msgctxt()
returns an empty &str
.
find_message()
on the other hand expects an Option<&str>
for the context parameter. That makes more sense, as it means no context is represented by None
.
Metadata::parse panics if some metadata header is not present because it unwraps the result of get()
Lines 69 to 81 in a1b9b57
Example: parsing this basic file generated with xgettext with default options
Notice that it doesn't contains Plural-Forms
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-06-09 17:34+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: main.cpp:28
msgid "item"
msgstr ""
And parsing this files with polib::po_file::parse
will panics with
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/polib-0.2.0/src/metadata.rs:81:84
It should use unwrap_or_default or something like that instead
Ideally, the MetaData should also keep the metadata as is so i can add messages to a .pot file without changing most metadata.
Hi.
I just recently worked on a Rust port (rspolib) of the Python library polib. Have used the rspolib
name because this crate is taking the name polib
. It's not a problem at all for me to keep the name as rspolib
, as it shares consistency with the name of the Python bindings, clearly pointing that is a port.
So I'm opening this issue for:
polib
.Is not a big deal, but probably more consistent for the Rust ecosystem.
Thanks for reading this and cheers.
Hi @BrettDong, thanks for maintaining the library. It's been very useful for me in mdbook-i18n-helpers!
Would you be up for adding some fuzzers to the library? I ran into an issue where I accidentally generated a .pot
file with a update msgid ""
entry: google/mdbook-i18n-helpers#64. I'm thinking to add fuzzers to guard against this: google/mdbook-i18n-helpers#65.
The fuzzer I have in mind would essentially use the public polib API to generate a .pot
file and then check that it can be loaded โ thereby checking that polib can load all files it generates. After loading the generated file, the fuzzer would check that the entries are identical to what was saved. This way we can be use that the library preserves the information.
msgmerge has a --previous
option that keeps the previous version of a string as a comment when it creates a fuzzy one. It is extremely useful in determining why a given string turned into a fuzzy and what changes need to be applied to the translation, if any.
Could you please add that to the fields of a message?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.