Expand description

Welcome to the i18n_provider_sqlite3 crate of the Internationalisation (i18n) project.

This crate consists of five modules:

  • error: Contains the error enum for the Sqlite3 provider,

  • provider: The provider implementation using Sqlite3 for the data store.

§Features

Available features for i18n_provider_sqlite3 crate:

  • logging: To provide some logging information.

  • sync: Allow for rust’s concurrency capabilities to be used. Use of Arc and Mutex instead Rc and RefCell.

§Modules

§provider: Sqlite3 provider for localisation strings.

This crate implements LocalisationProviderTrait using Sqlite3 as the data store for localisation strings. As a directory path is used at the time of creating a LocalisationProviderSqlite3 instance, it means that an application can have multiple data stores for both application localisation strings, and also for data packages’ localisation strings.

§Examples

use i18n_provider_sqlite3::LocalisationProviderSqlite3;
use i18n_provider::LocalisationProviderTrait;
use i18n_utility::LanguageTagRegistry;
use std::rc::Rc;
use std::error::Error;

fn main() -> Result<(), Box<dyn Error>> {
    let path = "./l10n/";
    let registry = Rc::new( LanguageTagRegistry::new() );
    let tag = registry.tag( "en" )?;
    let provider = LocalisationProviderSqlite3::try_new(
        path,
        &registry,
        false
    )?;
    let strings = provider.strings(
        "i18n_provider_sqlite3",
        "path_conversion",
        &tag,
    )?;
    assert_eq!( strings.len(), 1, "There should be 1 string." );
    assert_eq!( strings[ 0 ].as_str(), "Conversion to {`PathBuf`} error.", "Not correct string." );
    assert_eq!( strings[ 0 ].tag().as_str(), "en-ZA", "Must be en-ZA." );
    Ok( () )
}

§Localisation Sqlite3 templates

Can find the templates all_in_one.sqlite3 and component application.sqlite3 for the application in the l10n directory.

Re-exports§

Modules§