Module sources_parser

Parses source files and extracts translation directives on templates Examples:
  Tpl = <<"111"
          "{#Translators: btrans comment #}{%blocktrans%}btrns{%endblocktrans%}"
          "{%comment%}  TRANSLATORS: trans comment {%endcomment%}222{%trans 'trns'%}"
          "333">>,
  Phrases = sources_parser:parse_content("filename.dtl", Tpl),
  Msgids = [sources_parser:phrase_info(msgid, P) || P <- Phrases].
  %% -> ["btrns", "trns"]
  InOldFormat = [begin
                   [Str, File, Line, Col] = sources_parser:phrase_info([msgid, file, line, col], P),
                   {Str, {File, Line, Col}}
                 end || P <- Phrases].
  %% -> [{"btrns", {"filename.dtl", 1, 47}}, {"trns", {"filename.dtl", 1, 135}]
  

Description

Parses source files and extracts translation directives on templates Examples:
  Tpl = <<"111"
          "{#Translators: btrans comment #}{%blocktrans%}btrns{%endblocktrans%}"
          "{%comment%}  TRANSLATORS: trans comment {%endcomment%}222{%trans 'trns'%}"
          "333">>,
  Phrases = sources_parser:parse_content("filename.dtl", Tpl),
  Msgids = [sources_parser:phrase_info(msgid, P) || P <- Phrases].
  %% -> ["btrns", "trns"]
  InOldFormat = [begin
                   [Str, File, Line, Col] = sources_parser:phrase_info([msgid, file, line, col], P),
                   {Str, {File, Line, Col}}
                 end || P <- Phrases].
  %% -> [{"btrns", {"filename.dtl", 1, 47}}, {"trns", {"filename.dtl", 1, 135}]
  

Data Types

compat_phrase()

compat_phrase() = {string(), {string(), non_neg_integer(), non_neg_integer()}}

field()

field() = msgid | msgid_plural | context | comment | file | line | col

phrase()

abstract datatype: phrase()

Function Index

parse/0
parse/1
parse_content/2extract phrases from string / binary.
parse_file/1extract phrases from single file.
parse_pattern/1list files, using wildcard and extract phrases from them.
phrase_info/2extract info about phrase.
process_content/2

Function Details

parse/0

parse() -> any()

parse/1

parse(Pattern) -> any()

parse_content/2

parse_content(Path::string(), Content::binary()) -> [phrase()]

extract phrases from string / binary

parse_file/1

parse_file(Path) -> any()

extract phrases from single file

parse_pattern/1

parse_pattern(Pattern::[string()]) -> [phrase()]

list files, using wildcard and extract phrases from them

phrase_info/2

phrase_info(Fields::[field()] | field(), Phrase::phrase()) -> [Info] | Info

extract info about phrase. See field() type for list of available info field names.

process_content/2

process_content(Path, Content) -> any()


Generated by EDoc