var pot_path = locale_dir / module_name
var arr = vi.strings.values.to_a
- var po = new POFile.with_strings(arr)
+ var po = new POFile(arr)
po.write_template(pot_path)
if lang != null then
redef class AStringExpr
redef fun accept_string_finder(v) do
- var str = value.as(not null).escape_to_gettext
+ var str = value.escape_to_gettext
var code = "\"{str}\".get_translation(\"{v.domain}\", \"{v.languages_location}\")"
var parse = v.toolcontext.parse_expr(code)
replace_with(parse)
for i in n_exprs do
if i isa AStartStringExpr or i isa AEndStringExpr or i isa AMidStringExpr then
assert i isa AStringFormExpr
- fmt += i.value.as(not null)
+ var str = i.value
+ fmt += str.replace("%", "%%")
else
fmt += "%"
exprs.push i
- fmt += exprs.length.to_s
+ fmt += (exprs.length-1).to_s
end
end
fmt = fmt.escape_to_gettext
# Read from a PO file
var strings: Array[PObject]
- # Creates a PO file with strings built-in
- init with_strings(sm: Array[PObject])do
- strings = new Array[PObject].with_capacity(sm.length)
- strings.add_all sm
- end
-
redef fun write_to_file(path) do
if not path.has_suffix(".po") then path += ".po"
super path