mirror of
https://github.com/mirego/accent.git
synced 2024-09-11 18:58:14 +03:00
Fix gettext line break reject
This commit is contained in:
parent
042dc7e0a2
commit
773fd24f2a
@ -7,8 +7,8 @@ defmodule Langue.Formatter.Gettext.Parser do
|
||||
def parse(%{render: render, document: document}) do
|
||||
{:ok, po} = Gettext.PO.parse_string(render)
|
||||
entries = parse_translations(po)
|
||||
top_of_the_file_comment = join_string(po.top_of_the_file_comments)
|
||||
header = join_string(po.headers)
|
||||
top_of_the_file_comment = join_string(po.top_of_the_file_comments, "\n")
|
||||
header = join_string(po.headers, "\n")
|
||||
|
||||
%Langue.Formatter.ParserResult{
|
||||
entries: entries,
|
||||
@ -73,8 +73,9 @@ defmodule Langue.Formatter.Gettext.Parser do
|
||||
]
|
||||
end
|
||||
|
||||
defp join_string([]), do: nil
|
||||
defp join_string(list), do: Enum.join(list, "\n")
|
||||
defp join_string(list, joiner \\ "")
|
||||
defp join_string([], _joiner), do: nil
|
||||
defp join_string(list, joiner), do: Enum.join(list, joiner)
|
||||
|
||||
defp key_suffix(id), do: ".__KEY__#{id}"
|
||||
|
||||
|
@ -91,7 +91,6 @@ defmodule Langue.Formatter.Gettext.Serializer do
|
||||
["\n" | rest] -> ["" | rest]
|
||||
values -> values
|
||||
end
|
||||
|> Enum.reject(&(&1 === "\n"))
|
||||
end
|
||||
|
||||
defp remove_key_suffix(string), do: String.replace(string, ".__KEY___", "")
|
||||
|
@ -172,15 +172,15 @@ defmodule LangueTest.Formatter.Gettext.Expectation do
|
||||
def render do
|
||||
"""
|
||||
msgid "test"
|
||||
msgstr ""
|
||||
"a\\n"
|
||||
"a\\n"
|
||||
msgstr "This is a test\\n"
|
||||
"\\n"
|
||||
"multi line break"
|
||||
"""
|
||||
end
|
||||
|
||||
def entries do
|
||||
[
|
||||
%Entry{index: 1, key: "test", value: "\na\n\na\n", value_type: "string"}
|
||||
%Entry{index: 1, key: "test", value: "This is a test\n\nmulti line break", value_type: "string"}
|
||||
]
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user