seriyps / gettexter

GNU-gettext compatible Erlang translation app.
Apache License 2.0
18 stars 3 forks source link

Cannot get translated string #9

Closed Spoowy closed 6 years ago

Spoowy commented 6 years ago

Hi everyone,

I am just trying this out and the ets:lookup returns undefined in gettexter_server:42 (while ets table of gettexter_server_ets is populated)

  gettexter:bindtextdomain(?GETTEXT_DOMAIN, "apps/web/priv/locale"),
  gettexter:textdomain(?GETTEXT_DOMAIN),
  gettexter:setlocale(lc_messages, "ru"),
  ?_("Wanna sleep?")
ets:tab2list(gettexter_server_ets).
[{{hdr,my_app,"ru",<<"x-generator">>},
  <<"Poedit 1.5.4">>},
 {{msg,my_app,"ru",undefined,<<"One other domain">>,
       <<"~p other domains">>,2},
  <<"~p других доменов"/utf8>>},
 {{msg,my_app,"ru",undefined,<<"Wanna sleep?">>,
       undefined,0},
  <<"Хочешь спать?"/utf8>>},
 {{binding,my_app},"apps/web/priv/locale"},
 {{msg,my_app,"ru",undefined,<<"go sleep a hour">>,
       <<"go sleep ~p hours">>,1},
  <<"сходи поспи ~p часа"/utf8>>},
 {{hdr,my_app,"ru",<<"po-revision-date">>},
  <<"2014-02-26 05:40+0300">>},
 {{hdr,my_app,"ru",<<"report-msgid-bugs-to">>},<<>>},
 {{hdr,my_app,"ru",<<"language">>},<<"ru">>},
 {{hdr,my_app,"ru",<<"language-team">>},
  <<"Russian <ru@li.org>">>},
 {{msg,my_app,"ru",undefined,<<"Wanna eat?">>,
       undefined,0},
  <<"Хочешь есть?"/utf8>>},
 {{msg,my_app,"ru",undefined,<<"One other domain">>,
       <<"~p other domains">>,1},
  <<"~p других домена"/utf8>>},
 {{hdr,my_app,"ru",<<"pot-creation-date">>},
  <<"2014-02-21 01:34+0400">>},
 {{hdr,my_app,"ru",<<"content-transfer-encoding">>},
  <<"8bit">>}, 
 {{msg,my_app,"ru",undefined,<<"Hello, ~p! ~ts">>,
       undefined,0},
  <<"Привет, ~p! ~ts"/utf8>>},
 {{msg,my_app,"ru",<<"the-context">>,
       <<"One other domain">>,
       <<"~p other domains">>,0},
  <<"~p другой домен"/utf8>>},
 {{msg,my_app,"ru",undefined,<<"go sleep a hour">>,
       <<"go sleep ~p hours">>,0},
  <<"сходи поспи ~p час"/utf8>>},
 {{loaded,my_app,"ru"},
  "................../apps/web/priv/locale/ru/LC_MESSAGES/my_app.mo"},
 {{hdr,my_app,"ru",<<"plural-forms">>},
  <<"nplurals=3; plural=(n%10==1 && n%100"...>>},
 {{msg,my_app,"ru",undefined,<<"take one babana">>,
       <<"take ~p bana"...>>,2},
  <<"возьми ~p бананов"/utf8>>},
 {{msg,my_app,"ru",undefined,<<"So, you may "...>>,
       undefined,0},
  <<"Итак, ты говоришь ~ts"/utf8>>},
 {{hdr,my_app,"ru",<<"content-type">>},
  <<"text/plain; charset=UTF-"...>>},
 {{hdr,my_app,"ru",<<"last-tra"...>>},
  <<"Sergey Prokhorov <me"...>>},
 {{msg,my_app,"ru",<<"the-"...>>,<<...>>,...},
  <<"~p других домено"/utf8...>>},
 {{msg,my_app,"ru",undefined,...},
  <<"возьми ~p ба"/utf8...>>},
 {{hdr,my_app,[...],...},<<"1.0">>},
 {{msg,my_app,...},<<"возь"/utf8...>>},
 {{msg,...},<<...>>},
 {{...},...},
 {...}|...]

(using ru translation from test) .po file has been compiled to .mo as well.

What step am I missing?

Cheers! Erwin

Spoowy commented 6 years ago

This worked: gettexter:ensure_loaded(my_app, lc_messages, "ru").

Is this to be called on init in production?

Cheers