Authors: Håkan Stenholm (hokan@kreditor.se).
Use this module to validate po files returned by translators. This validator assumes the po file to be valid (parsable without errors by gettext/poEdit/GNU po file tools). Its use is to check for errors introduced by translators in the msgstr part in the po file; this is done by supplying checker callback module names to the validate(...) function.
A number of default checkers that should work on most texts can check for:ignore_entry_type() -> atom().
Returns the typename to use in the ignore file.
heading() -> string().
Returns a short text used as heading when listing errors/warnings for this checker.
check({OriginalFormatStr::string(), TranslatedFormatStr::string()},
Ignores, Acc::[acc()]) -> UpdatedAcc::[acc()]
Returns an updated accumulator UpdatedAcc after checking
OriginalFormatStr against TranslatedFormatStr. One or more entries
must be added to the head of Acc if problems are found. Ignores
contains an ETS table reference used by gettext_validate:do_ignore(...)
to check if the error/warning should be reported - this filtering should
be done after the check, so that the code crashes if the checker is
broken - ignore files could otherwise hide broken checks.
{alert_level(),
ErrorMsg::string(),
Pairs::{Name::atom(), Info::term()} ....}
where alert_level() is either 'ERROR', indicating an error that
may cause a crash (e.g., in STXT) or generate invalid output, or 'Warning', indicating a possible problem. Pairs contain check
specific error information - usually at least the msgid and msgstr, so
that they can be found in a po file and fixed.
output() = [{{heading, string()}, {ignore_type, atom()}, {po_file_path, string()}, {ignore_file_path, string()}, CheckRes::[acc()]}]
| default_opts/0 | |
| do_ignore/4 | |
| validate/3 | Takes a valid (parsable) po file and checks that there are no inconsistencies between the msgid and msgstr texts. |
| validate_q/1 | |
| validate_q/2 | |
| validate_qf/2 | |
| validate_qf/3 |
default_opts() -> any()
do_ignore(Ignores, Key, Bad, Acc) -> any()
validate(PoFilePath::string(), IgnoreFilePath::[] | string(), Opts::[{Key, Val}]) -> ok | output()
Takes a valid (parsable) po file and checks that there are no inconsistencies between the msgid and msgstr texts.
The function prints a result listing.
PoFilePath - the po file check
IgnoreFilePath - a optional file that can be used to specify
{CheckType, MsgId, MsgStr} combinations that should
not be reported as a errors/warnings - false
positives.
Each (language) po file should usualy have one such
ignore file.
Opts:
{to_file, SaveLocation} - force output to file rather than shell
{checkers, ModuleNames} - checkers to use, ModuleNames = [atom()]
{end_user, Format} - output format:
human - print readable text (default) to shell, file, ...
computer - fuction returns output() to describe
the check results - this is useful for automated
po file validation
validate_q(PoFilePath) -> any()
validate_q(PoFilePath, IgnoreFilePath) -> any()
validate_qf(PoFilePath, SaveFile) -> any()
validate_qf(PoFilePath, IgnoreFilePath, SaveFile) -> any()
Generated by EDoc