GithubHelp home page GithubHelp logo

gettext's People

Contributors

elegaanz avatar justinas avatar marcospb19 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gettext's Issues

pgettext/npgettext allocate

Catalog::pgettext and Catalog::npgettext allocate a String on every call due to the need to form a key {context}\x04{msgid}.

The reference implementation of gettext solves this elegantly via a macro that concatenates the string literals at compile time.

# define pgettext(Msgctxt, Msgid) \
   pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)

Possible solutions

Macros

A macro like pgettext!(catalog, "context", "msgid") could be made that would expand to catalog.gettext(concat!("context", "\x04", "msgid")). However, now we have two API styles: pgettext!(catalog, ...) and catalog.pgettext(...).

Change internal format

Index the internal translation dictionary by (msgid, context): (&str, Option<&str>). Get rid of \x04 past the parsing stage altogether. I am leaning towards this solution.

Add ability to get metadata

Hi there! Thanks for the great library :)

I'm working on a project right now that involves replacing an existing gettext implementation, and in order to do so, I need to be able to effectively export parts of the .mo data; namely, I need to be able to pull the Plural-Forms metadata back out verbatim.

parse_catalog calls out to parse_metadata(), but the map value is discarded once the charset and plural forms are read out; rather than calling parse_metadata() manually again later, I think it would make sense to store the map in the Catalog struct?

(I can PR this if you're interested!)

Failed to build for wasm32-unknown-unknown target

I'm having trouble with this library compiling for wasm target, I would like to use it for localizing a wasm front-end.

error: failed to run custom build command for `gettext-sys v0.19.9`

Caused by:
  process didn't exit successfully: `/home/luke/programming/rust/coster/gui/target/release/build/gettext-sys-73a6d95dee0cc0d1/build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=WASM32_UNKNOWN_UNKNOWN_GETTEXT_SYSTEM
cargo:rerun-if-env-changed=GETTEXT_SYSTEM
cargo:rerun-if-env-changed=WASM32_UNKNOWN_UNKNOWN_GETTEXT_DIR
cargo:rerun-if-env-changed=GETTEXT_DIR
cargo:rerun-if-env-changed=WASM32_UNKNOWN_UNKNOWN_GETTEXT_BIN_DIR
cargo:rerun-if-env-changed=GETTEXT_BIN_DIR
cargo:rerun-if-env-changed=WASM32_UNKNOWN_UNKNOWN_GETTEXT_LIB_DIR
cargo:rerun-if-env-changed=GETTEXT_LIB_DIR
cargo:rerun-if-env-changed=WASM32_UNKNOWN_UNKNOWN_GETTEXT_INCLUDE_DIR
cargo:rerun-if-env-changed=GETTEXT_INCLUDE_DIR
OPT_LEVEL = Some("3")
TARGET = Some("wasm32-unknown-unknown")
HOST = Some("x86_64-unknown-linux-gnu")
CC_wasm32-unknown-unknown = None
CC_wasm32_unknown_unknown = None
TARGET_CC = None
CC = None
CFLAGS_wasm32-unknown-unknown = None
CFLAGS_wasm32_unknown_unknown = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
running: "tar" "xJf" "/home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/gettext-sys-0.19.9/gettext-0.19.8.1.tar.xz" "--strip-components" "1"
running: "sh" "/home/luke/programming/rust/coster/gui/target/wasm32-unknown-unknown/release/build/gettext-sys-1a0c67a101a60b0a/out/gettext/configure" "--without-emacs" "--disable-java" "--disable-csharp" "--disable-c++" "--disable-shared" "--enable-static" "--enable-fast-install" "--with-included-gettext" "--with-included-glib" "--with-included-libcroco" "--with-included-libunistring" "--prefix=/home/luke/programming/rust/coster/gui/target/wasm32-unknown-unknown/release/build/gettext-sys-1a0c67a101a60b0a/out" "--build=x86_64-unknown-linux-gnu" "--host=wasm32-unknown-unknown"
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for wasm32-unknown-unknown-strip... no
checking for strip... strip
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... 
--- stderr
configure: WARNING: using cross tools not prefixed with host triplet
Invalid configuration `wasm32-unknown-unknown': system `unknown' not recognized
configure: error: /bin/sh /home/luke/programming/rust/coster/gui/target/wasm32-unknown-unknown/release/build/gettext-sys-1a0c67a101a60b0a/out/gettext/build-aux/config.sub wasm32-unknown-unknown failed
thread 'main' panicked at '
command did not execute successfully, got: exit code: 1

Make force_plurals Sync + Send?

Hello, I'm trying to use this package in multi-threaded environment and it complaints about force_plurals.

I was able to make it compile by changing signature to Fn(u64) -> usize + Send + Sync + 'static inside gettext package itself, but I'm not sure if that's the right way (still in that borrow checker fighting phase). Is this the right way to do this or am I missing something and it's possible without modifying gettext source itself?

Thank you

Add a method to get an empty Catalog?

I'd like to be able to construct an empty Catalog, in order to fallback for unsupported languages. I see that there is a Catalog::new, but it's private.

Alternatively, is there a better way to do this?

Document how to generate pot files

I'm currently adding translations to my rust application, and I'm having a hard time getting any tools to generate the .pot files.

It would be very helpful to have some documentation on the whole workflow.

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.