Skip to content

Commit

Permalink
feat(ssg): 🎨 migrating to langweave
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienrousseau committed Oct 20, 2024
1 parent 62cd513 commit fc77e6e
Show file tree
Hide file tree
Showing 23 changed files with 186 additions and 834 deletions.
388 changes: 169 additions & 219 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["ssg", "ssg-cli", "ssg-core", "ssg-i18n"]
members = ["ssg", "ssg-cli", "ssg-core"]
resolver = "2"

[workspace.package]
Expand Down
2 changes: 1 addition & 1 deletion ssg-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dtt = "0.0.8"
env_logger = "0.11"
html-generator = "0.0.1"
http-handle = "0.0.2"
langweave = "0.0.1"
lazy_static = "1.5"
log = { version = "0.4", features = ["std"] }
metadata-gen = "0.0.1"
Expand All @@ -37,4 +38,3 @@ vrd = "0.0.8"
[build-dependencies]
# Dependencies for build scripts.
version_check = "0.9" # Check the Rust version used to compile the package.

127 changes: 0 additions & 127 deletions ssg-core/src/languages.rs

This file was deleted.

4 changes: 3 additions & 1 deletion ssg-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ pub mod compiler;
/// Logging and diagnostic utilities
pub mod loggers;

/// Locales module for language-specific translations and templates
pub mod locales;

/// Macro definitions for common operations
pub mod macros;

Expand All @@ -43,5 +46,4 @@ pub mod utilities;
pub use compiler::service::compile;
pub use http_handle::Server;
pub use loggers::init_logger;
pub use staticweaver;
pub use utilities::uuid::generate_unique_string;
10 changes: 1 addition & 9 deletions ssg-i18n/src/languages/de.rs → ssg-core/src/locales/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use lazy_static::lazy_static;
use std::collections::HashMap;

use crate::I18nError;
use langweave::error::I18nError;

lazy_static! {
static ref TRANSLATIONS: HashMap<&'static str, &'static str> = {
Expand Down Expand Up @@ -37,14 +37,6 @@ lazy_static! {
/// The translated string if a translation is found, or the original `text` if no
/// translation is available.
///
/// # Examples
///
/// ```
/// use ssg_i18n::languages::de::translate;
///
/// assert_eq!(translate("Hello").unwrap(), "Hallo");
/// assert_eq!(translate("Untranslated").unwrap_or("Untranslated".to_string()), "Untranslated");
/// ```
pub fn translate(key: &str) -> Result<String, I18nError> {
if let Some(&translation) = TRANSLATIONS.get(key) {
Ok(translation.to_string())

Check warning on line 42 in ssg-core/src/locales/de.rs

View check run for this annotation

Codecov / codecov/patch

ssg-core/src/locales/de.rs#L40-L42

Added lines #L40 - L42 were not covered by tests
Expand Down
10 changes: 1 addition & 9 deletions ssg-i18n/src/languages/en.rs → ssg-core/src/locales/en.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::I18nError;
use langweave::error::I18nError;
use lazy_static::lazy_static;
use std::collections::HashMap;

Expand Down Expand Up @@ -27,14 +27,6 @@ lazy_static! {
/// The translated string if a translation is found, or the original `text` if no
/// translation is available.
///
/// # Examples
///
/// ```
/// use ssg_i18n::languages::en::translate;
///
/// assert_eq!(translate("Hello").unwrap(), "Hello");
/// assert_eq!(translate("Untranslated").unwrap_or("Untranslated".to_string()), "Untranslated");
/// ```
pub fn translate(key: &str) -> Result<String, I18nError> {
if let Some(&translation) = TRANSLATIONS.get(key) {
Ok(translation.to_string())

Check warning on line 32 in ssg-core/src/locales/en.rs

View check run for this annotation

Codecov / codecov/patch

ssg-core/src/locales/en.rs#L30-L32

Added lines #L30 - L32 were not covered by tests
Expand Down
10 changes: 1 addition & 9 deletions ssg-i18n/src/languages/fr.rs → ssg-core/src/locales/fr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use lazy_static::lazy_static;
use std::collections::HashMap;

use crate::I18nError;
use langweave::error::I18nError;

lazy_static! {
static ref TRANSLATIONS: HashMap<&'static str, &'static str> = {
Expand Down Expand Up @@ -37,14 +37,6 @@ lazy_static! {
/// The translated string if a translation is found, or the original `text` if no
/// translation is available.
///
/// # Examples
///
/// ```
/// use ssg_i18n::languages::fr::translate;
///
/// assert_eq!(translate("Hello").unwrap(), "Bonjour");
/// assert_eq!(translate("Untranslated").unwrap_or("Untranslated".to_string()), "Untranslated");
/// ```
pub fn translate(key: &str) -> Result<String, I18nError> {
if let Some(&translation) = TRANSLATIONS.get(key) {
Ok(translation.to_string())

Check warning on line 42 in ssg-core/src/locales/fr.rs

View check run for this annotation

Codecov / codecov/patch

ssg-core/src/locales/fr.rs#L40-L42

Added lines #L40 - L42 were not covered by tests
Expand Down
File renamed without changes.
File renamed without changes.
53 changes: 0 additions & 53 deletions ssg-i18n/Cargo.toml

This file was deleted.

Empty file removed ssg-i18n/README.md
Empty file.
26 changes: 0 additions & 26 deletions ssg-i18n/benches/translation_benchmark.rs

This file was deleted.

56 changes: 0 additions & 56 deletions ssg-i18n/build.rs

This file was deleted.

23 changes: 0 additions & 23 deletions ssg-i18n/examples/basic_usage.rs

This file was deleted.

Loading

0 comments on commit fc77e6e

Please sign in to comment.