Ideation continues below... 2013/5/4 Mikhail Zabaluev <mikhail.zabal...@gmail.com>
> In fact, there is nothing preventing fully flexible logic in translations > if they are themselves written in Rust (penging some variadic trait mojo in > the macro that will invoke the translation): > > pub static messages: &'static [Tr] = &[ > Tr("Simple text", > &Text("Простой текст") as &Message), > Tr("%d elements", > &Fmt(|n: int| { > match (ru::num_case(n)) { > ru::NumCaseNone => ~"ни одного элемента", > ru::NumCase1 => fmt!("%d элемент", n), > ru::NumCase2 => fmt!("%d элемента", n), > _ => fmt!("%d элементов", n) > } > }) as &Message) > ]; > This looks boilerplatey, but: 1) I tried to make it legal in my limited understanding of the current Rust; 2) this looks like a perfect application for macros; 3) for a proper i18n system, there would be a tool that would extract tr!() macro invocations from the program source and generate the message catalog boilerplate including properly typed lambdas, with unedited placeholder values marked as untranslated!(), fuzzy!(), etc. to perform later updates gettext-style. Cheers, Mikhail
_______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev