use crate::message::{Message, MessageFlags};
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct MessageBuilder {
m: Message,
}
impl Message {
pub fn build_singular() -> MessageBuilder {
MessageBuilder {
m: Message {
is_plural: false,
..Message::default()
},
}
}
pub fn build_plural() -> MessageBuilder {
MessageBuilder {
m: Message {
is_plural: true,
..Message::default()
},
}
}
}
impl MessageBuilder {
pub fn with_translator_comments(&mut self, comments: String) -> &mut Self {
self.m.translator_comments = comments;
self
}
pub fn with_extracted_comments(&mut self, comments: String) -> &mut Self {
self.m.extracted_comments = comments;
self
}
pub fn with_source(&mut self, source: String) -> &mut Self {
self.m.source = source;
self
}
pub fn with_flags(&mut self, flags: MessageFlags) -> &mut Self {
self.m.flags = flags;
self
}
pub fn with_msgctxt(&mut self, msgctxt: String) -> &mut Self {
self.m.msgctxt = msgctxt;
self
}
pub fn with_msgid(&mut self, msgid: String) -> &mut Self {
self.m.msgid = msgid;
self
}
pub fn with_msgid_plural(&mut self, msgid_plural: String) -> &mut Self {
self.m.msgid_plural = msgid_plural;
self
}
pub fn with_msgstr(&mut self, msgstr: String) -> &mut Self {
self.m.msgstr = msgstr;
self
}
pub fn with_msgstr_plural(&mut self, msgstr_plural: Vec<String>) -> &mut Self {
self.m.msgstr_plural = msgstr_plural;
self
}
pub fn done(&mut self) -> Message {
std::mem::take(&mut self.m)
}
}