Skip to content

Commit 2cf057d

Browse files
committed
removed support for locales
1 parent 6745f97 commit 2cf057d

File tree

5 files changed

+7
-373
lines changed

5 files changed

+7
-373
lines changed

src/lib.rs

Lines changed: 2 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,6 @@ mod locales;
3333
mod parsers;
3434
mod url;
3535
use locales::en_us::Site;
36-
use once_cell::{self, sync::OnceCell};
37-
38-
/// The markup formats supported.
39-
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)]
40-
pub enum Markup {
41-
/// Common markdown `(LINK TEXT)[URL]`
42-
Markdown,
43-
/// Asciidoc markdown `URL[LINK TEXT]`
44-
Asciidoc,
45-
/// HTML `<a href="URL">LINK TEXT</a>`
46-
HTML,
47-
}
48-
49-
// Initialize a safe global variable.
50-
// Can be only set once but read many times.
51-
static LOCALE: OnceCell<Locale> = OnceCell::new();
5236

5337
#[allow(non_camel_case_types)]
5438
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)]
@@ -58,25 +42,6 @@ pub enum Locale {
5842
es_es,
5943
}
6044

61-
#[allow(unused_must_use)]
62-
impl Locale {
63-
/// Sets the value of `LOCALE`. Can only set once.
64-
//TODO: Should be a result since it can panic if ran twice
65-
pub fn new(locale: Locale) {
66-
LOCALE.set(locale);
67-
}
68-
69-
/// Retrieves the value of `LOCALE`, may retrieve an arbitrary number of times.
70-
//TODO: Should be a result since it can panic
71-
pub fn get() -> &'static Locale {
72-
match LOCALE.get().expect("LOCALE was not initialized"){
73-
Locale::en_us => &Locale::en_us,
74-
Locale::es_es => &Locale::es_es,
75-
}
76-
77-
}
78-
}
79-
8045
/// Adds the prefix and postfix around each scripture found in the `text`.
8146
pub fn surround<'a, S: Into<String> + Clone>(text: S, prefix: &'a str, postfix: &'a str) -> String {
8247
parsers::surround::Script::new(text)
@@ -89,7 +54,7 @@ pub fn surround<'a, S: Into<String> + Clone>(text: S, prefix: &'a str, postfix:
8954
/// Links scriptures found to a online Bible.
9055
pub fn url<S: Into<String> + Clone>(site: &Site, text: S) -> String {
9156
parsers::surround::Script::new(text)
92-
.url(Locale::get(), site)
57+
.url(site)
9358
.get_text()
9459
}
9560

@@ -100,38 +65,11 @@ mod test {
10065
use super::*;
10166
use pretty_assertions::assert_eq;
10267

103-
#[test]
104-
fn t_set_read_locales() {
105-
let expect = &Locale::en_us;
106-
Locale::new(Locale::en_us);
107-
let got = Locale::get();
108-
assert_eq!(got, expect);
109-
}
110-
111-
#[test]
112-
#[should_panic]
113-
// Should panic because locale was not set.
114-
fn t_read_locales_error() {
115-
let expect = &Locale::en_us;
116-
let got = Locale::get();
117-
assert_eq!(got, expect);
118-
}
119-
12068
#[test]
12169
fn t_revelations_url() {
12270
let text: &str = "A popular scriptures is Rev 12:12. It is quoted often.";
12371
let expect: String = "A popular scriptures is [Rev 12:12](https://www.jw.org/en/library/bible/study-bible/books/revelation/12/#v66012012). It is quoted often.".to_string();
124-
Locale::new(Locale::en_us);
125-
let got: String = Script::new(text).url(Locale::get(), &Site::JwOrg).get_text();
126-
assert_eq!(got, expect)
127-
}
128-
129-
#[test]
130-
fn t_mateo_url() {
131-
let text: &str = "A popular scriptures is Mateo 12:12. It is quoted often.";
132-
let expect: String = "A popular scriptures is [Mateo 12:12](https://www.jw.org/en/library/bible/study-bible/books/mateo/12/#v40012012). It is quoted often.".to_string();
133-
Locale::new(Locale::es_es);
134-
let got: String = Script::new(text).url(Locale::get(), &Site::JwOrg).get_text();
72+
let got: String = Script::new(text).url( &Site::JwOrg).get_text();
13573
assert_eq!(got, expect)
13674
}
13775

src/locales/es_es.rs

Lines changed: 0 additions & 297 deletions
This file was deleted.

0 commit comments

Comments
 (0)