Commit cdc104b7e9fcb978956b06dea539f8c4ad3c2cdd

Authored by David RENÉ
1 parent 004c6d11

[+] add many function to be able to translate with different dictionary of the a…

…pplication. For example countries dictionary is not a part of an application because it can be use in many applications.
Showing 1 changed file with 60 additions and 5 deletions   Show diff stats
web_controllers/language/language_management.anubis
@@ -28,7 +28,7 @@ public define (String symbolic_name) -> String @@ -28,7 +28,7 @@ public define (String symbolic_name) -> String
28 if l3_load_base(dictionary_collection_name) is 28 if l3_load_base(dictionary_collection_name) is
29 { 29 {
30 failure then 30 failure then
31 - logger(logError, "Can't load translation dictionnary for '"+dictionary_collection_name+"'"); 31 + logger(logError, "Can't load translation dictionary for '"+dictionary_collection_name+"'");
32 (String symbolic_name) |-> "<" + symbolic_name + ">", 32 (String symbolic_name) |-> "<" + symbolic_name + ">",
33 33
34 success(L3 local) then 34 success(L3 local) then
@@ -41,6 +41,29 @@ public define (String symbolic_name) -&gt; String @@ -41,6 +41,29 @@ public define (String symbolic_name) -&gt; String
41 (String symbolic_name) |-> l3_get_text(l3_object, symbolic_name) 41 (String symbolic_name) |-> l3_get_text(l3_object, symbolic_name)
42 } 42 }
43 . 43 .
  44 +
  45 +public define (String symbolic_name) -> String
  46 + make_translate_function_for_lang
  47 + (
  48 + WEB_Session _session,
  49 + String lang,
  50 + (LogLevel, String) -> One logger
  51 + ) =
  52 + with app_dictionary = get_String(_session.fields, "AWS_CURRENT_DICTIONARY", ""),
  53 + make_translate_function(app_dictionary, lang, logger)
  54 +.
  55 +
  56 +public define (String symbolic_name) -> String
  57 + make_translate_function_for_lang
  58 + (
  59 + WEB_Session _session,
  60 + String lang
  61 + ) =
  62 + with app_dictionary = get_String(_session.fields, "AWS_CURRENT_DICTIONARY", ""),
  63 + make_translate_function(app_dictionary, lang, (LogLevel level, String txt) |-> println(txt))
  64 +.
  65 +
  66 +
44 public define (String symbolic_name) -> String 67 public define (String symbolic_name) -> String
45 make_translate_function 68 make_translate_function
46 ( 69 (
@@ -48,9 +71,9 @@ public define (String symbolic_name) -&gt; String @@ -48,9 +71,9 @@ public define (String symbolic_name) -&gt; String
48 (LogLevel, String) -> One logger 71 (LogLevel, String) -> One logger
49 ) = 72 ) =
50 with lang = _session.language, 73 with lang = _session.language,
51 - app_dictionnary = get_String(_session.fields, "AWS_CURRENT_DICTIONARY", ""),  
52 -  
53 - make_translate_function(app_dictionnary, lang, logger) 74 + app_dictionary = get_String(_session.fields, "AWS_CURRENT_DICTIONARY", ""),
  75 +
  76 + make_translate_function(app_dictionary, lang, logger)
54 . 77 .
55 78
56 public define (String symbolic_name) -> String 79 public define (String symbolic_name) -> String
@@ -62,7 +85,18 @@ public define (String symbolic_name) -&gt; String @@ -62,7 +85,18 @@ public define (String symbolic_name) -&gt; String
62 . 85 .
63 86
64 public define (String symbolic_name) -> String 87 public define (String symbolic_name) -> String
65 - make_translate_function 88 + make_translate_function_for_dictionary
  89 + (
  90 + WEB_Session _session,
  91 + String dictionary_collection_name,
  92 + (LogLevel, String) -> One logger
  93 + ) =
  94 + with lang = _session.language,
  95 + make_translate_function(dictionary_collection_name, lang, logger)
  96 +.
  97 +
  98 +public define (String symbolic_name) -> String
  99 + make_translate_function_for_dictionary
66 ( 100 (
67 WEB_Session _session, 101 WEB_Session _session,
68 String dictionary_collection_name, 102 String dictionary_collection_name,
@@ -81,6 +115,27 @@ public define (String symbolic_name, List((String, String)) list_key_value) -&gt; S @@ -81,6 +115,27 @@ public define (String symbolic_name, List((String, String)) list_key_value) -&gt; S
81 find_and_replace_dict(translated_sentence, list_key_value) 115 find_and_replace_dict(translated_sentence, list_key_value)
82 . 116 .
83 117
  118 +public define (String symbolic_name, List((String, String)) list_key_value) -> String
  119 + make_translate_with_key_value_function_for_lang
  120 + (
  121 + WEB_Session _session,
  122 + String lang,
  123 + ) =
  124 + (String symbolic_name, List((String, String)) list_key_value) |->
  125 + with translated_sentence = make_translate_function_for_lang(_session, lang)(symbolic_name),
  126 + find_and_replace_dict(translated_sentence, list_key_value)
  127 +.
  128 +
  129 +public define (String symbolic_name, List((String, String)) list_key_value) -> String
  130 + make_translate_with_key_value_function_for_dictionary
  131 + (
  132 + WEB_Session _session,
  133 + String dictionary_collection_name,
  134 + ) =
  135 + (String symbolic_name, List((String, String)) list_key_value) |->
  136 + with translated_sentence = make_translate_function_for_dictionary(_session, dictionary_collection_name)(symbolic_name),
  137 + find_and_replace_dict(translated_sentence, list_key_value)
  138 +.
84 139
85 public define List((List(CoreAttrs),WebArgValue, String)) 140 public define List((List(CoreAttrs),WebArgValue, String))
86 language_list_for_combo 141 language_list_for_combo