aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEvgeny Khramtsov <ekhramtsov@process-one.net>2019-07-11 00:13:39 +0300
committerEvgeny Khramtsov <ekhramtsov@process-one.net>2019-07-11 00:13:39 +0300
commit19cbbf69b278c18fed15e5887cc2bf95de295230 (patch)
tree6adc55b280675847c3b4b8f5c5991269c472c195 /src
parentGracefully report invalid encoding of a translation file (diff)
Improve previous commit
Diffstat (limited to 'src')
-rw-r--r--src/translate.erl10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/translate.erl b/src/translate.erl
index 12d5b6c04..2c277c5da 100644
--- a/src/translate.erl
+++ b/src/translate.erl
@@ -147,10 +147,12 @@ load_file(File) ->
{ok, Lines} ->
lists:map(
fun({In, Out}) ->
- try
- InB = unicode:characters_to_binary(In, utf8),
- OutB = unicode:characters_to_binary(Out, utf8),
- {{Lang, InB}, OutB}
+ try {unicode:characters_to_binary(In, utf8),
+ unicode:characters_to_binary(Out, utf8)} of
+ {InB, OutB} when is_binary(InB), is_binary(OutB) ->
+ {{Lang, InB}, OutB};
+ _ ->
+ {error, File, bad_encoding}
catch _:badarg ->
{error, File, bad_encoding}
end;