Git Product home page Git Product logo

polib's People

Contributors

brettdong avatar mgeisler avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mgeisler yossyx

polib's Issues

msgctxt() should return an Option<&str>

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.

Panic on missing metadata.

Metadata::parse panics if some metadata header is not present because it unwraps the result of get()

polib/src/metadata.rs

Lines 69 to 81 in a1b9b57

project_id_version: key_values.get("Project-Id-Version").unwrap().to_string(),
pot_creation_date: key_values.get("POT-Creation-Date").unwrap().to_string(),
po_revision_date: key_values.get("PO-Revision-Date").unwrap().to_string(),
last_translator: key_values.get("Last-Translator").unwrap_or(&"").to_string(),
language_team: key_values.get("Language-Team").unwrap().to_string(),
mime_version: key_values.get("MIME-Version").unwrap().to_string(),
content_type: key_values.get("Content-Type").unwrap().to_string(),
content_transfer_encoding: key_values
.get("Content-Transfer-Encoding")
.unwrap()
.to_string(),
language: key_values.get("Language").unwrap().to_string(),
plural_rules: CatalogPluralRules::parse(key_values.get("Plural-Forms").unwrap())?,

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.

Possible name squatting on crates.io?

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:

  • Suggesting you to use rspolib as is implementing a full PO and MO manipulation library.
  • To request the crate name polib.

Is not a big deal, but probably more consistent for the Rust ecosystem.

Thanks for reading this and cheers.

Add fuzzer to check round-tripping

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.

Provide previous versions of fuzzy strings

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.