Skip to content

Commit

Permalink
rebarification
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuel Rubio committed Sep 19, 2012
1 parent 2765673 commit 9c3122c
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 98 deletions.
23 changes: 0 additions & 23 deletions Makefile

This file was deleted.

1 change: 1 addition & 0 deletions rebar.config
@@ -0,0 +1 @@
{erl_opts, [debug_info]}.
52 changes: 0 additions & 52 deletions src/Makefile

This file was deleted.

23 changes: 16 additions & 7 deletions src/gettext_compile.erl
Expand Up @@ -27,6 +27,7 @@

-export([parse_transform/2, epot2po/0]).
-export([write_pretty/2]).
-export([get_env/1]).

-include("gettext_internal.hrl").

Expand Down Expand Up @@ -197,11 +198,9 @@ mk_header(true = _UseOrigHeader, _LC) ->
%%% --------------------------------------------------------------------
%%% NB: We assume that the surrounding code does some preparations:
%%%
%%% 1. Setup the environment variables: 'GETTEXT_DIR' and 'GETTEXT_TMP_NAME'
%%%
%%% 2. The compiler is called with the 'gettext' flag.
%%% 1. The compiler is called with the 'gettext' flag.
%%%
%%% 3. The file $(GETTEXT_DIR)/lang/$(GETTEXT_TMP_NAME)/epot.dets is
%%% 2. The file priv/lang/epot.dets is
%%% removed before the first erlang/yaws file is processed.
%%% (entrys are appended to the file)
%%% --------------------------------------------------------------------
Expand All @@ -221,10 +220,20 @@ parse_transform(Form,Opts) ->
Form
end.

get_env(Key) ->
case application:get_env(gettext, Key) of
undefined ->
case Key of
path -> ".";
lang -> ?DEFAULT_LANG;
name -> "tmp"
end;
{ok, Value} ->
Value
end.

get_env() ->
{os:getenv(?ENV_TMP_NAME),
os:getenv(?ENV_ROOT_DIR),
os:getenv(?ENV_DEF_LANG)}.
{get_env(name), get_env(path), get_env(lang)}.


pt(Form, Opts) ->
Expand Down
3 changes: 0 additions & 3 deletions src/gettext_internal.hrl
Expand Up @@ -29,7 +29,4 @@
-define(CUSTOM_DIR, "custom").
-define(POFILE, "gettext.po").

-define(ENV_TMP_NAME, "GETTEXT_TMP_NAME").
-define(ENV_ROOT_DIR, "GETTEXT_DIR").
-define(ENV_DEF_LANG, "GETTEXT_DEF_LANG").
-define(ENV_CBMOD, "GETTEXT_CBMOD").
8 changes: 4 additions & 4 deletions src/gettext_server.erl
Expand Up @@ -245,8 +245,8 @@ get_gettext_dir(CallBackMod, Config) ->
end.

get_gettext_dir(CallBackMod) ->
case os:getenv(?ENV_ROOT_DIR) of
false ->
case gettext_compile:get_env(path) of
undefined ->
try CallBackMod:gettext_dir()
catch
_:_ -> gettext_dir() % fallback
Expand All @@ -261,8 +261,8 @@ get_default_lang(CallBackMod, Config) ->
end.

get_default_lang(CallBackMod) ->
case os:getenv(?ENV_DEF_LANG) of
false ->
case gettext_compile:get_env(lang) of
undefined ->
case catch CallBackMod:gettext_def_lang() of
Dir when is_list(Dir) -> Dir;
_ -> gettext_def_lang() % fallback
Expand Down
10 changes: 2 additions & 8 deletions test/Makefile
Expand Up @@ -17,10 +17,7 @@ po: $(dir)/lang/default/$(def_lang)/gettext.po
pot: $(dir)/lang/default/$(def_lang)/gettext.pot

$(dir)/lang/default/$(def_lang)/gettext.pot: $(EBIN_FILES)
(export GETTEXT_TMP_NAME=$(tmp_name); \
export GETTEXT_DIR=$(dir); \
export GETTEXT_DEF_LANG=$(def_lang); \
erl -noshell -pa ../ebin -s gettext_compile epot2po)
erl -noshell -pa ../ebin -s gettext_compile epot2po
install -D $(dir)/lang/$(tmp_name)/$(def_lang)/gettext.po \
$(dir)/lang/default/$(def_lang)/gettext.pot; \

Expand All @@ -31,10 +28,7 @@ clean:
rm -f $(EBIN_FILES)

../ebin/%.beam: %.erl $(INCLUDES) Makefile
(export GETTEXT_TMP_NAME=$(tmp_name); \
export GETTEXT_DIR=$(dir); \
export GETTEXT_DEF_LANG=$(def_lang); \
erlc -pa ../ebin -o ../ebin $(ERLC_FLAGS) +gettext $<)
erlc -pa ../ebin -o ../ebin $(ERLC_FLAGS) +gettext $<

test:
@erl -pa ../ebin -noshell \
Expand Down
1 change: 0 additions & 1 deletion vsn.mk

This file was deleted.

0 comments on commit 9c3122c

Please sign in to comment.