poreader
a parser for GNU gettext Portable Objects (.po) files
Types
pub type Comment {
Flag(String)
Translator(String)
Extracted(String)
Reference(filename: String, line_number: option.Option(Int))
Previous(String)
}
Constructors
-
Flag(String) -
Translator(String) -
Extracted(String) -
Reference(filename: String, line_number: option.Option(Int)) -
Previous(String)
pub type Message {
Singular(
msgid: String,
msgstr: String,
msgctx: option.Option(String),
comments: List(Comment),
)
Plural(
msgid: String,
msgid_plural: String,
msgstr: dict.Dict(Int, String),
msgctx: option.Option(String),
comments: List(Comment),
)
}
Constructors
-
Singular( msgid: String, msgstr: String, msgctx: option.Option(String), comments: List(Comment), ) -
Plural( msgid: String, msgid_plural: String, msgstr: dict.Dict(Int, String), msgctx: option.Option(String), comments: List(Comment), )
pub type ParseError {
LexerError(row: Int, col: Int, lexeme: String)
ParserError(List(String))
}
Constructors
-
LexerError(row: Int, col: Int, lexeme: String) -
ParserError(List(String))
Values
pub fn get_context(message: Message) -> option.Option(String)
returns the context of the message
pub fn get_plural_id(message: Message) -> option.Option(String)
returns the plural id of the message
pub fn get_plural_text(
message: Message,
idx: Int,
) -> option.Option(String)
returns the plural translation of the message when given a singular message, the single translation is returned
pub fn get_text(message: Message) -> option.Option(String)
returns the text of the message when given a plural message, the first translation is returned
pub fn is_plural(message: Message) -> Bool
returns true when the message is of type plural
pub fn is_singular(message: Message) -> Bool
returns true when the message is of type singular
pub fn parse(
content: String,
) -> Result(List(Message), ParseError)
parses the given string into a list of messages