= i18nprovidersqlite3 Rizzen Yazston :BufferProvider: https://docs.rs/icuprovider/latest/icuprovider/buf/trait.BufferProvider.html :CLDR: https://cldr.unicode.org/ :ICU4X: https://github.com/unicode-org/icu4x :Unicode_Consortium: https://home.unicode.org/
Sqlite3 provider for LString
s.
This crate implements LStringProvider
using Sqlite3 as the data store for language strings. As a directory path is used at the time of creating a ProviderSqlite3
object, it means that an application can have multiple data stores for both application language strings, and also for data packages' language strings.
== Acknowledgement
Stefano Angeleri for advice on various design aspects of implementing the components of the internationalisation project, and also providing the Italian translation of error message strings.
== Cargo.toml
[dependencies]
i18n_lstring-rizzen-yazston = "0.6.1"
i18n_provider-rizzen-yazston = "0.6.1"
i18n_provider_sqlite3-rizzen-yazston = "0.6.1"
== Examples
use i18n_provider_sqlite3::ProviderSqlite3;
use i18n_provider::LStringProvider;
use i18n_registry::LanguageTagRegistry;
use std::rc::Rc;
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
let path = "./i18n/";
let registry = Rc::new( LanguageTagRegistry::new() );
let tag = registry.get_language_tag( "en" )?;
let provider = ProviderSqlite3::try_new(
path,
®istry
)?;
let strings = provider.get(
"i18n_provider_sqlite3/invalid_path",
&tag
)?.expect( "No string found for language tag." );
assert_eq!( strings.len(), 1, "There should be 1 string." );
assert_eq!( strings[ 0 ].as_str(), "Invalid path provided: ‘{path}’.", "Not correct string." );
assert_eq!( strings[ 0 ].language_tag().as_str(), "en-ZA", "Must be en-ZA." );
Ok( () )
}