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

Prepare extract_messages to return translator comments #107

Merged
merged 3 commits into from
Feb 20, 2024
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
2 changes: 1 addition & 1 deletion fuzz/fuzz_targets/group_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fuzz_target!(|text: String| {
let flattened_groups = group_events(&events)
.into_iter()
.flat_map(|group| match group {
Group::Translate(events) | Group::Skip(events) => events,
Group::Translate { events, .. } | Group::Skip(events) => events,
})
.collect::<Vec<_>>();

Expand Down
12 changes: 6 additions & 6 deletions i18n-helpers/src/directives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::sync::OnceLock;
#[derive(Debug, PartialEq)]
pub enum Directive {
Skip,
TranslatorComment(String),
Comment(String),
}

pub fn find(html: &str) -> Option<Directive> {
Expand All @@ -30,7 +30,7 @@ pub fn find(html: &str) -> Option<Directive> {
command.find("comment").unwrap() + "comment".len() + 1,
command.len(),
);
Some(Directive::TranslatorComment(
Some(Directive::Comment(
command[start_of_comment_offset..].trim().into(),
))
}
Expand Down Expand Up @@ -83,19 +83,19 @@ mod tests {
}

#[test]
fn test_translator_comment() {
fn test_comment() {
assert!(match find("<!-- i18n:comment: hello world! -->") {
Some(Directive::TranslatorComment(s)) => {
Some(Directive::Comment(s)) => {
s == "hello world!"
}
_ => false,
});
}

#[test]
fn test_translator_empty_comment_does_nothing() {
fn test_empty_comment_does_nothing() {
assert!(match find("<!-- i18n:comment -->") {
Some(Directive::TranslatorComment(s)) => {
Some(Directive::Comment(s)) => {
s.is_empty()
}
_ => false,
Expand Down
Loading