Skip to content

Commit

Permalink
Design phase. Just a few concept structs.
Browse files Browse the repository at this point in the history
  • Loading branch information
rizzen-yazston committed Mar 16, 2023
1 parent 65e9aaa commit c48105e
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 32 deletions.
8 changes: 5 additions & 3 deletions crates/i18n/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
//!
//! * i18n_pattern-rizzen-yazston
//!
//! * i18n_message-rizzen-yazston
//!
//! # Usage
//!
//! For most use cases, just the use of `i18n-rizzen-yazston` crate will be sufficient to use the multilingual message
Expand All @@ -21,14 +23,14 @@
//! ```
//! [dependencies]
//! icu_locid = "1.0.0"
//! i18n-rizzen-yazston = "0.3.1"
//! i18n-rizzen-yazston = "0.4.0"
//! ```
//!
//! ## Examples
//!
//! See the various component crates for usage examples.

pub use i18n_lstring-rizzen-yazston as lstring;
pub use i18n_lexer-rizzen-yazston as lexer;
pub use i18n_lexer-rizzen-yazston as pattern;
pub use i18n_pattern-rizzen-yazston as pattern;
//pub use i18n_message-rizzen-yazston as message;
pub use i18n_message-rizzen-yazston as message;
2 changes: 2 additions & 0 deletions crates/message/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
icu_locid = "1.0.0"
i18n_lstring-rizzen-yazston = { version = "0.3.0", path = "../lstring" }
i18n_lexer-rizzen-yazston = { version = "0.3.0", path = "../lexer" } # Needed for Token, TokenType
i18n_pattern-rizzen-yazston = { version = "0.3.0", path = "../pattern" }
tree-rizzen-yazston = { version = "0.2.0", path = "../../../tree" }
Expand Down
70 changes: 70 additions & 0 deletions crates/message/src/formatter.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// This file is part of `i18n_message-rizzen-yazston` crate. For the terms of use, please see the file
// called `LICENSE-BSD-3-Clause` at the top level of the `i18n_message-rizzen-yazston` crate.

//! TODO: Complete crate description
//!
//! # Examples
//!
//! ```
//! // TODO: crate example
//! ```

use icu_locid::Locale;
use std::rc::Rc;
use i18n_lstring::LString;
use i18n_lexer::{Lexer, Token, TokenType};
use tree::{Tree, NodeFeatures};
use i18n_pattern::{NodeType, parse};
use std::collections::HashMap;
//use std::fmt; this is needed if implementing Display on something

pub struct System {
lexer: Lexer,
}

impl System {
pub fn try_new( lexer: Lexer ) -> Result<Self, String> {

}
}

pub struct Formatter {
locale: Rc<Locale>,
ast: Tree,
}

impl Formatter {

/// Creates a Formatter for the language string.
pub fn try_new( string: LString ) -> Result<Self, String> {
Err( "Temporary error until implemented.".to_string() )
}

/// Format the language string with supplied values.
pub fn format( self ) -> Result<LString, String> {
Err( "Temporary error until implemented.".to_string() )
}


}







#[cfg(test)]
mod tests {
use super::*;
use icu_testdata::buffer;

#[test]
fn test1() {
}

#[test]
fn test2() {
}
}

37 changes: 8 additions & 29 deletions crates/message/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,32 +1,11 @@
// This file is part of `i18n_message-rizzen-yazston` crate. For the terms of use, please see the file
// called `LICENSE-BSD-3-Clause` at the top level of the `i18n_message-rizzen-yazston` crate.
// called LICENSE-BSD-3-Clause at the top level of the `i18n_message-rizzen-yazston` crate.

//! TODO: Complete crate description
//!
//! # Examples
//!
//! ```
//! // TODO: crate example
//! ```

use i18n_lexer::{Lexer, Token, TokenType};
use std::rc::Rc;
use tree::{Tree, NodeFeatures};
use i18n_pattern::{NodeType, parse};
use std::collections::HashMap;
//use std::fmt; this is needed if implementing Display on something

#[cfg(test)]
mod tests {
use super::*;
use icu_testdata::buffer;

#[test]
fn test1() {
}

#[test]
fn test2() {
}
}
//! The `i18n_message` crate contains the messaging system.
//!
//! Contains the follow modules:
//!
//! * `formatter`: Takes an AST with supplied values to create a language string of the specified `Locale`.

pub mod formatter;
pub use formatter::*;

0 comments on commit c48105e

Please sign in to comment.