lingo

Internationalise a Rust program and translate strings quickly and simply. Make any software open to multiple languages

Installation

In your "Cargo.toml" file : toml [dependencies] lingo_lib = "*" Check the current version on crates.io.

Unfortunately, the crate "lingo" already exists in crates.io. Waiting to get the name, be careful to not import "lingo" but "lingo_lib".

How to use

```rust let mut lingo = lingo![ ( "", strings![ s!("", ""), s!("", "") // ... ] ) // ... ];

// If not set, it's the operating system locale that will be used. lingo.setcontextlocale(/* app locale /); // If not set, it's locale!("en"). lingo.set_default_locale(/ locale */);

println!("{}", lingo.string("").unwrap()); ```

Example

A French application using lingo. ```rust let mut lingo = lingo![ ( "helloworld", strings![ s!("frBE", "Bonjour le monde !"), // Belgium s!("enGB", "Hello world!") ] ), ( "love", strings![ s!("frFR", "J'adore Lingo"), // France s!("en_GB", "I love Lingo") ] ) ];

lingo.setcontextlocale(locale!("frFR")); lingo.setdefaultlocale(locale!("frFR"));

println!("{}", lingo.string("hello_world").unwrap()); println!("{}", lingo.string("love").unwrap()); ```

Bonjour le monde ! J'adore Lingo

If there were no fr string, it would use : s!("en_GB", "Hello world!").

Imports for the example

```rust use std::collections::HashMap;

use lingolib::locales::Locale; use lingolib::strings::getstring; use lingolib::Lingo; use lingo_lib::{lingo, locale, s, strings}; ```