justinas / gettext Goto Github PK
View Code? Open in Web Editor NEWGettext for Rust. Kind of.
License: MIT License
Gettext for Rust. Kind of.
License: MIT License
TODO: description.
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)
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(...)
.
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.
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!)
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
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
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?
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.
It would probably be a good style to return the underlying Io
error from Error::cause()
.
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.