Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #14 from bosqueviejo/master

gettext rebarified
  • Loading branch information...
commit 2a103f9f506baf1b8226d16d658cfdd5aabf14ed 2 parents 2765673 + 9c3122c
@etnt authored
View
23 Makefile
@@ -1,23 +0,0 @@
-.PHONY: all debug test clean conf_clean docs example
-
-all:
- (cd src;$(MAKE))
-
-debug:
- (cd src;$(MAKE) debug)
-
-test: all
- (cd test;$(MAKE))
-
-clean:
- (cd src;$(MAKE) clean)
- (cd test;$(MAKE) clean)
- rm -f priv/gettext_server_db.dets
-
-conf_clean:
-
-docs:
- (cd src;$(MAKE) docs)
-
-example:
- $(MAKE) -f Makefile.gettext
View
1  rebar.config
@@ -0,0 +1 @@
+{erl_opts, [debug_info]}.
View
52 src/Makefile
@@ -1,52 +0,0 @@
-
-include ../vsn.mk
-VSN=$(GETTEXT_VSN)
-
-MODULES=gettext \
- gettext_compile \
- gettext_format \
- gettext_server \
- gettext_validate \
- gettext_validate_no_trans \
- gettext_validate_bad_case \
- gettext_validate_bad_punct \
- gettext_validate_bad_stxt \
- gettext_validate_bad_html \
- gettext_validate_bad_ws \
- gettext_yaws_html \
- gettext_checker \
- gettext_sup \
- gettext_app \
- gettext_iso639
-
-EBIN_FILES=$(MODULES:%=../ebin/%.beam)
-ERL_FILES=$(MODULES:%=%.erl)
-
-ERLC_FLAGS+=+debug_info
-
-INCLUDES=gettext_internal.hrl
-
-#
-# Targets
-#
-
-all: $(EBIN_FILES) ../ebin/gettext.app
-
-debug:
- $(MAKE) ERLC_FLAGS+="$(ERLC_FLAGS) -Ddebug"
-
-docs: ../doc/index.html
-
-../doc/index.html: ../doc/overview.edoc $(ERL_FILES) $(INCLUDES)
- erl -noshell -run edoc_run application "gettext" '".."' '[]'
-
-clean:
- rm -f $(EBIN_FILES) ../ebin/gettext.app \
- ../doc/*.html ../doc/edoc-info \
- ../doc/stylesheet.css ../doc/erlang.png
-
-../ebin/%.beam: %.erl $(INCLUDES) Makefile
- erlc -o ../ebin $(ERLC_FLAGS) $<
-
-../ebin/gettext.app: gettext.app.src
- cp gettext.app.src ../ebin/gettext.app
View
23 src/gettext_compile.erl
@@ -27,6 +27,7 @@
-export([parse_transform/2, epot2po/0]).
-export([write_pretty/2]).
+-export([get_env/1]).
-include("gettext_internal.hrl").
@@ -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)
%%% --------------------------------------------------------------------
@@ -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) ->
View
3  src/gettext_internal.hrl
@@ -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").
View
8 src/gettext_server.erl
@@ -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
@@ -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
View
10 test/Makefile
@@ -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; \
@@ -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 \
View
1  vsn.mk
@@ -1 +0,0 @@
-GETTEXT_VSN=2.1.0
Please sign in to comment.
Something went wrong with that request. Please try again.