Koka / gettext-rs

GNU Gettext FFI binding for Rust
51 stars 25 forks source link

Support optional format directives in `ngettext!` macro #110

Open zefr0x opened 9 months ago

zefr0x commented 9 months ago

In the plural forms for some languages we might not use a number inside the string.

For example in Arabic we use

"Plural-Forms: nplurals=6; plural=(n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 "
"&& n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5);\n"

so for numbers, zero, one and two we have special forms where we use words rather then numbers in the string. In this case we will get:

thread '<unnamed>' panicked at 'Argument count has to match number of format directives ({})', src/main.rs:x:y
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

We should be able to optionally not use {} in the locale string. This behaviour is supported in other gettext implementations in other languages.