Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added danish #22

Merged
merged 2 commits into from
Jan 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions src/languages/danish.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
use super::super::{Language, TimeUnit};

#[derive(Default)]
pub struct Danish;
impl Language for Danish {
fn too_low (&self) -> &'static str { "nu" }
fn too_high(&self) -> &'static str { "gammel" }
fn ago(&self) -> &'static str { "siden" }
fn get_word(&self, tu: TimeUnit, x: u64) -> &'static str {
use TimeUnit::*;
if x == 1 {
match tu {
Nanoseconds => "nanosekund",
Microseconds => "mikrosekund",
Milliseconds => "millisekund",
Seconds => "sekund",
Minutes => "minut",
Hours => "time",
Days => "dag",
Weeks => "uge",
Months => "måned",
Years => "år",
}
} else {
match tu {
Nanoseconds => "nanosekunder",
Microseconds => "mikrosekunder",
Milliseconds => "millisekunder",
Seconds => "sekunder",
Minutes => "minutter",
Hours => "timer",
Days => "dage",
Weeks => "uger",
Months => "måneder",
Years => "år",
}
}
}
}
2 changes: 2 additions & 0 deletions src/languages/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub mod swedish;
pub mod turkish;
pub mod french;
pub mod spanish;
pub mod danish;

/// Helper function to make a language dynamically dispatched
pub fn boxup<L: super::Language + 'static>(x: L) -> Box<super::Language> {
Expand Down Expand Up @@ -53,6 +54,7 @@ pub fn from_isolang(x: isolang::Language) -> Option<Box<super::Language>> {
x if x.to_name() == "Turkish" => boxup(turkish::Turkish),
x if x.to_name() == "French" => boxup(french::French),
x if x.to_name() == "Spanish" => boxup(spanish::Spanish),
x if x.to_name() == "Danish" => boxup(danish::Danish),
_ => return None,
})
}