Commit 068d794002eebc966981493bc3a54dd6b4ab48d6
1 parent
e4322160
add L3 web controller
Showing
1 changed file
with
40 additions
and
10 deletions
Show diff stats
web_controllers/language/language_management.anubis
| ... | ... | @@ -6,31 +6,61 @@ |
| 6 | 6 | * © David RENÉ |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | +read system/logger.anubis | |
| 9 | 10 | read locale/L3.anubis |
| 11 | +read locale/L3LanguageInfo.anubis | |
| 12 | +read xlib/web/types/controllers_web_site.anubis | |
| 10 | 13 | read xlib/web/CXM_web_session.anubis |
| 11 | -read app/app_loggers.anubis | |
| 14 | + | |
| 12 | 15 | |
| 13 | 16 | public define String default_language = "en". |
| 14 | 17 | |
| 15 | 18 | public define (String symbolic_name) -> String |
| 16 | 19 | make_translate_function |
| 17 | 20 | ( |
| 18 | - WEB_Session _session | |
| 21 | + WEB_Session _session, | |
| 22 | + (LogLevel, String) -> One logger | |
| 19 | 23 | ) = |
| 20 | 24 | with lang = _session.language, |
| 21 | 25 | app_dictionnary = get_String(_session.fields, "AWS_CURRENT_DICTIONARY", ""), |
| 22 | 26 | if l3_load_base(app_dictionnary) is |
| 23 | 27 | { |
| 24 | - failure then logError(debug_log,"Can't load translation dictionnary for '"+app_dictionnary+"'"); | |
| 25 | - (String symbolic_name) |-> "<" + symbolic_name + ">", | |
| 26 | - success(L3 local) then | |
| 28 | + failure then | |
| 29 | + logger(logError, "Can't load translation dictionnary for '"+app_dictionnary+"'"); | |
| 30 | + (String symbolic_name) |-> "<" + symbolic_name + ">", | |
| 27 | 31 | |
| 28 | - //now we set the current language | |
| 29 | - with _l3_object = l3_set_current(local, lang), | |
| 32 | + success(L3 local) then | |
| 33 | + //now we set the current language | |
| 34 | + with _l3_object = l3_set_current(local, lang), | |
| 30 | 35 | l3_object = l3_set_default(_l3_object, default_language), |
| 31 | 36 | if lang = "symb" then |
| 32 | - (String symbolic_name) |-> "[" + l3_get_text(l3_object, symbolic_name) + "]" | |
| 33 | - else | |
| 34 | - (String symbolic_name) |-> l3_get_text(l3_object, symbolic_name) | |
| 37 | + (String symbolic_name) |-> "[" + l3_get_text(l3_object, symbolic_name) + "]" | |
| 38 | + else | |
| 39 | + (String symbolic_name) |-> l3_get_text(l3_object, symbolic_name) | |
| 35 | 40 | } |
| 36 | 41 | . |
| 42 | + | |
| 43 | +public define (String symbolic_name) -> String | |
| 44 | + make_translate_function | |
| 45 | + ( | |
| 46 | + WEB_Session _session | |
| 47 | + ) = | |
| 48 | + make_translate_function(_session, (LogLevel level, String txt) |-> println(txt)) | |
| 49 | +. | |
| 50 | + | |
| 51 | + | |
| 52 | +public define List((List(CoreAttrs),WebArgValue, String)) | |
| 53 | + language_list_for_combo | |
| 54 | + ( | |
| 55 | + String dictionary_collection_name //means application name | |
| 56 | + ) | |
| 57 | + = | |
| 58 | + map((L3LangDicProperty dico_prop) | |
| 59 | + |-> | |
| 60 | + since dico_prop is l3LangDicProperty( _, _, lang_code, _, _, _), | |
| 61 | + with lang_info = l3_get_language_info(lang_code), | |
| 62 | + ((List(CoreAttrs))[], wav(lang_code), self_name(lang_info)) | |
| 63 | + , | |
| 64 | + l3_get_all_dicos(dictionary_collection_name) | |
| 65 | + ) | |
| 66 | +. | ... | ... |