Browse Source

fix #171 by cleaning out some unused i18n files.

the remaining files still need some work to be better integrated.
Andreas Stenius 11 years ago
parent
commit
0ba11ce75f

+ 0 - 17
src/erlydtl_i18n.erl

@@ -1,17 +0,0 @@
-%% Author: dave
-%% Created: Feb 25, 2010
-%% Description: Bridge between erlydtl compiler and gettext server 
--module(erlydtl_i18n).
-
-%%
-%% Include files
-%%
-%% Exported Functions
-%%
--export([translate/2]).
-
-%%
-%% API Functions
-%%
-%% Makes i18n conversion using gettext
-translate(String, Locale) -> gettext:key2str(String, Locale).

+ 0 - 4
src/i18n/Makefile

@@ -1,4 +0,0 @@
-include ../../../../support/include.mk
-EBIN_DIR := ../../ebin
-
-all: $(EBIN_FILES_NO_DOCS) 

+ 0 - 50
src/i18n/blocktrans_extractor.erl

@@ -1,50 +0,0 @@
--module(blocktrans_extractor).
-
--export([extract/1]).
-
--include("include/erlydtl_ext.hrl").
-
-extract(Path) when is_list(Path) ->
-    {ok, Contents} = file:read_file(Path),
-    extract(Contents);
-
-extract(Contents) when is_binary(Contents) ->
-    case erlydtl_compiler:do_parse_template(Contents, #dtl_context{}) of
-        {ok, ParseTree} ->
-            Blocks = process_tree(ParseTree),
-            {ok, Blocks};
-        Error ->
-            Error
-    end.
-
-process_tree(ParseTree) ->
-    process_tree(ParseTree, []).
-
-process_tree([], Acc) ->
-    lists:reverse(Acc);
-process_tree([{'autoescape', _, Contents}|Rest], Acc) ->
-    process_tree(Rest, lists:reverse(process_tree(Contents), Acc));
-process_tree([{'block', _, Contents}|Rest], Acc) ->
-    process_tree(Rest, lists:reverse(process_tree(Contents), Acc));
-process_tree([{'blocktrans', _, Contents}|Rest], Acc) ->
-    process_tree(Rest, [lists:flatten(erlydtl_unparser:unparse(Contents))|Acc]); % <-- where all the action happens
-process_tree([{'filter', _, Contents}|Rest], Acc) ->
-    process_tree(Rest, lists:reverse(process_tree(Contents), Acc));
-process_tree([{'for', _, Contents}|Rest], Acc) ->
-    process_tree(Rest, lists:reverse(process_tree(Contents), Acc));
-process_tree([{'for', _, Contents, EmptyPartContents}|Rest], Acc) ->
-    process_tree(Rest, lists:reverse(process_tree(Contents) ++ process_tree(EmptyPartContents), Acc));
-process_tree([{Instruction, _, Contents}|Rest], Acc) when Instruction =:= 'if'; 
-                                                          Instruction =:= 'ifequal'; 
-                                                          Instruction =:= 'ifnotequal' ->
-    process_tree(Rest, lists:reverse(process_tree(Contents), Acc));
-process_tree([{Instruction, _, IfContents, ElseContents}|Rest], Acc) when Instruction =:= 'ifelese'; 
-                                                                          Instruction =:= 'ifequalelse'; 
-                                                                          Instruction =:= 'ifnotequalelse' ->
-    process_tree(Rest, lists:reverse(process_tree(IfContents) ++ process_tree(ElseContents), Acc));
-process_tree([{'spaceless', Contents}|Rest], Acc) ->
-    process_tree(Rest, lists:reverse(process_tree(Contents), Acc));
-process_tree([{'with', _, Contents}|Rest], Acc) ->
-    process_tree(Rest, lists:reverse(process_tree(Contents), Acc));
-process_tree([_|Rest], Acc) ->
-    process_tree(Rest, Acc).

+ 0 - 13
src/i18n/blocktrans_parser.erl

@@ -1,13 +0,0 @@
--module(blocktrans_parser).
-
--export([parse/1]).
-
-parse(Tokens) ->
-    parse(Tokens, []).
-
-parse([], Acc) ->
-    lists:reverse(Acc);
-parse([{open_blocktrans, _, _}, {text, _, Text}, {close_blocktrans, _}|Rest], Acc) ->
-    parse(Rest, [Text|Acc]);
-parse([{text, _, _}|Rest], Acc) ->
-    parse(Rest, Acc).

+ 0 - 146
src/i18n/blocktrans_scanner.erl

@@ -1,146 +0,0 @@
-% Module for extracting blocktrans blocks with original source formatting preserved.
-
--module(blocktrans_scanner).
-
--export([scan/1]).
-
-scan(Template) ->
-    scan(Template, [], {1, 1}, in_text).
-
-scan([], Scanned, _, in_text) ->
-    {ok, lists:reverse(lists:map(
-                fun
-                    ({text, Pos, Text}) ->
-                        {text, Pos, lists:reverse(Text)};
-                    (Other) ->
-                        Other
-                end, Scanned))};
-
-scan([], _Scanned, _, {in_comment, _}) ->
-    {error, "Reached end of file inside a comment."};
-
-scan([], _Scanned, _, _) ->
-    {error, "Reached end of file inside a code block."};
-
-scan("<!--{{" ++ T, Scanned, {Row, Column}, in_text) ->
-    scan(T, append_text("<!--{{", {Row, Column}, Scanned), {Row, Column + length("<!--{{")}, {in_code, "}}-->"});
-
-scan("{{" ++ T, Scanned, {Row, Column}, in_text) ->
-    scan(T, append_text("{{", {Row, Column}, Scanned), {Row, Column + 2}, {in_code, "}}"});
-
-scan("<!--{#" ++ T, Scanned, {Row, Column}, in_text) ->
-    scan(T, append_text("<!--{#", {Row, Column}, Scanned), {Row, Column + length("<!--{#")}, {in_comment, "#}-->"});
-
-scan("{#" ++ T, Scanned, {Row, Column}, in_text) ->
-    scan(T, append_text("{#", {Row, Column}, Scanned), {Row, Column + length("{#")}, {in_comment, "#}"});
-
-scan("#}-->" ++ T, Scanned, {Row, Column}, {in_comment, "#}-->"}) ->
-    scan(T, append_text("#}-->", {Row, Column}, Scanned), {Row, Column + length("#}-->")}, in_text);
-
-scan("#}" ++ T, Scanned, {Row, Column}, {in_comment, "#}"}) ->
-    scan(T, append_text("#}", {Row, Column}, Scanned), {Row, Column + length("#}")}, in_text);
-
-scan("<!--{% blocktrans " ++ T, Scanned, {Row, Column}, in_text) ->
-    scan(T, [{open_blocktrans, {Row, Column}, ""} | Scanned], 
-        {Row, Column + length("<!--{% blocktrans ")}, {in_code, "%}-->"});
-
-scan("{% blocktrans " ++ T, Scanned, {Row, Column}, in_text) ->
-    scan(T, [{open_blocktrans, {Row, Column}, ""} | Scanned], 
-        {Row, Column + length("{% blocktrans ")}, {in_code, "%}"});
-
-scan("{% endblocktrans %}" ++ T, Scanned, {Row, Column}, in_text) ->
-    scan(T, [{close_blocktrans, {Row, Column}} | Scanned],
-        {Row, Column + length("{% endblocktrans %}")}, in_text);
-
-scan("<!--{% endblocktrans %}-->" ++ T, Scanned, {Row, Column}, in_text) ->
-    scan(T, [{close_blocktrans, {Row, Column}} | Scanned],
-        {Row, Column + length("<!--{% endblocktrans %}-->")}, {in_text});
-
-scan("<!--{%" ++ T, Scanned, {Row, Column}, in_text) ->
-    scan(T, append_text("<!--{%", {Row, Column}, Scanned),
-        {Row, Column + length("<!--{%")}, {in_code, "%}-->"});
-
-scan("{%" ++ T, Scanned, {Row, Column}, in_text) ->
-    scan(T, append_text("{%", {Row, Column}, Scanned),
-        {Row, Column + length("{%")}, {in_code, "%}"});
-
-scan([H | T], Scanned, {Row, Column}, {in_comment, Closer}) ->
-    scan(T, append_text([H], {Row, Column}, Scanned), {Row, Column + 1}, {in_comment, Closer});
-
-scan("\n" ++ T, Scanned, {Row, Column}, in_text) ->
-    scan(T, append_text("\n", {Row, Column}, Scanned), {Row + 1, 1}, in_text);
-
-scan([H | T], Scanned, {Row, Column}, in_text) ->
-    scan(T, append_text([H], {Row, Column}, Scanned), {Row, Column + 1}, in_text);
-
-scan("\"" ++ T, Scanned, {Row, Column}, {in_code, Closer}) ->
-    scan(T, append_text("\"", {Row, Column}, Scanned), {Row, Column + 1} , {in_double_quote, Closer});
-
-scan("\'" ++ T, Scanned, {Row, Column}, {in_code, Closer}) ->
-    scan(T, append_text("\'", {Row, Column}, Scanned), {Row, Column + 1}, {in_single_quote, Closer});
-
-scan("\\" ++ T, Scanned, {Row, Column}, {in_double_quote, Closer}) ->
-    scan(T, append_text("\\", {Row, Column}, Scanned), {Row, Column + 1}, {in_double_quote_slash, Closer});
-
-scan([H | T], Scanned, {Row, Column}, {in_double_quote_slash, Closer}) ->
-    scan(T, append_text([H], {Row, Column}, Scanned), {Row, Column + 1}, {in_double_quote, Closer});
-
-scan("\\" ++ T, Scanned, {Row, Column}, {in_single_quote, Closer}) ->
-    scan(T, append_text("\\", {Row, Column}, Scanned), {Row, Column + 1}, {in_single_quote_slash, Closer});
-
-scan([H | T], Scanned, {Row, Column}, {in_single_quote_slash, Closer}) ->
-    scan(T, append_text([H], {Row, Column}, Scanned), {Row, Column + 1}, {in_single_quote, Closer});
-
-% end quote
-scan("\"" ++ T, Scanned, {Row, Column}, {in_double_quote, Closer}) ->
-    scan(T, append_text("\"", {Row, Column}, Scanned), {Row, Column + 1}, {in_code, Closer});
-
-scan("\'" ++ T, Scanned, {Row, Column}, {in_single_quote, Closer}) ->
-    scan(T, append_text("\'", {Row, Column}, Scanned), {Row, Column + 1}, {in_code, Closer});
-
-scan([H | T], Scanned, {Row, Column}, {in_double_quote, Closer}) ->
-    scan(T, append_text([H], {Row, Column}, Scanned), {Row, Column + 1}, {in_double_quote, Closer});
-
-scan([H | T], Scanned, {Row, Column}, {in_single_quote, Closer}) ->
-    scan(T, append_text([H], {Row, Column}, Scanned), {Row, Column + 1}, {in_single_quote, Closer});
-
-
-scan("}}-->" ++ T, Scanned, {Row, Column}, {_, "}}-->"}) ->
-    scan(T, append_text("}}-->", {Row, Column}, Scanned),
-        {Row, Column + length("}}-->")}, in_text);
-
-scan("}}" ++ T, Scanned, {Row, Column}, {_, "}}"}) ->
-    scan(T, append_text("}}", {Row, Column}, Scanned), {Row, Column + length("}}")}, in_text);
-
-scan("%}-->" ++ T, Scanned, {Row, Column}, {_, "%}-->"}) ->
-    scan(T, append_text("%}-->", {Row, Column}, Scanned),
-        {Row, Column + length("%}-->")}, in_text);
-
-scan("%}" ++ T, Scanned, {Row, Column}, {_, "%}"}) ->
-    scan(T, append_text("%}", {Row, Column}, Scanned),
-        {Row, Column + length("%}")}, in_text);
-
-
-scan([H | T], Scanned, {Row, Column}, {in_code, Closer}) ->
-    scan(T, append_text([H], {Row, Column}, Scanned), {Row, Column + 1}, {in_code, Closer}).
-
-% internal functions
-
-append_text(Text, Pos, []) ->
-    [{text, Pos, Text}];
-append_text(Text, Pos, [{close_blocktrans, _}|_] = Scanned) ->
-    [{text, Pos, Text}|Scanned];
-append_text([C], _Pos, [{open_blocktrans, BPos, ""}|Rest]) when ((C >= $a) and (C =< $z)) or ((C >= $A) and (C =< $Z)) or (C =:= $_) ->
-    [{open_blocktrans, BPos, [C]}|Rest];
-append_text(" ", _Pos, [{open_blocktrans, BPos, ""}|Rest]) ->
-    [{open_blocktrans, BPos, ""}|Rest];
-append_text([C], _Pos, [{open_blocktrans, BPos, Name}|Rest]) when ((C >= $a) and (C =< $z)) or ((C >= $A) and (C =< $Z)) or (C =:= $_) orelse (C >= $0 andalso C =< $9) ->
-    [{open_blocktrans, BPos, [C|Name]}|Rest];
-append_text(" ", _Pos, [{open_blocktrans, BPos, Name}|Rest]) when is_list(Name) ->
-    [{open_blocktrans, BPos, lists:reverse(Name)}|Rest];
-append_text("%}", {Row, Column}, [{open_blocktrans, _BPos, _Name}|_] = Scanned) ->
-    [{text, {Row, Column + 2}, ""}|Scanned];
-append_text(_Chars, _Pos, [{open_blocktrans, _BPos, _Name}|_] = Scanned) ->
-    Scanned;
-append_text(Chars, _Pos, [{text, TPos, TChars}|Rest]) ->
-    [{text, TPos, lists:reverse(Chars, TChars)}|Rest].