/* * Created by PyramIDE. * User: フランスのトトロ aka (David RENÉ) * Date: 17/04/2020 * Time: 15:00 * © David RENÉ */ read system/logger.anubis read locale/L3.anubis read locale/L3LanguageInfo.anubis read xlib/web/types/controllers_web_site.anubis read xlib/web/CXM_web_session.anubis public define One set_dictionary(WEB_Session s, String n) = replace_String(s.fields, "AWS_CURRENT_DICTIONARY", n). public define One set_dictionary(Var(List(Session_Field)) fields, String n) = replace_String(fields, "AWS_CURRENT_DICTIONARY", n). public define String get_dictionary(WEB_Session s) = get_String (s.fields, "AWS_CURRENT_DICTIONARY", ""). public define String default_language = "en". public define (String symbolic_name) -> String make_translate_function ( String dictionary_collection_name, String lang, (LogLevel, String) -> One logger ) = if l3_load_base(dictionary_collection_name) is { failure then logger(logError, "Can't load translation dictionnary for '"+dictionary_collection_name+"'"); (String symbolic_name) |-> "<" + symbolic_name + ">", success(L3 local) then //now we set the current language with _l3_object = l3_set_current(local, lang), l3_object = l3_set_default(_l3_object, default_language), if lang = "symb" then (String symbolic_name) |-> "[" + l3_get_text(l3_object, symbolic_name) + "]" else (String symbolic_name) |-> l3_get_text(l3_object, symbolic_name) } . public define (String symbolic_name) -> String make_translate_function ( WEB_Session _session, (LogLevel, String) -> One logger ) = with lang = _session.language, app_dictionnary = get_String(_session.fields, "AWS_CURRENT_DICTIONARY", ""), make_translate_function(app_dictionnary, lang, logger) . public define (String symbolic_name) -> String make_translate_function ( WEB_Session _session ) = make_translate_function(_session, (LogLevel level, String txt) |-> println(txt)) . public define List((List(CoreAttrs),WebArgValue, String)) language_list_for_combo ( String dictionary_collection_name //means application name ) = map((L3LangDicProperty dico_prop) |-> since dico_prop is l3LangDicProperty( _, _, lang_code, _, _, _), with lang_info = l3_get_language_info(lang_code), ((List(CoreAttrs))[], wav(lang_code), self_name(lang_info)) , l3_get_all_dicos(dictionary_collection_name) ) . define HTML_Off_Form language_line ( String language_code, String language )= li([style("background-image: url(../flags/"+language_code+".png);"), event(onclick, "language_changed('"+language_code+"');")], text(language)) . public define HTML_Partial_Content flags_menu ( String dictionary_collection_name, String lang, Bool show_symbolic, (LogLevel, String) -> One logger ) = with make_line = (L3LangDicProperty dico_prop) |-> if dico_prop is l3LangDicProperty( _, sha1, lang_code, user_def, creat, update) then with lang_info = l3_get_language_info(lang_code), if lang_code = lang then empty else language_line(lang_code, self_name(lang_info)), partial_content([ css(css_file("css/flags_menu.css")), js(js_file("js/cxm/cxm.js")) ], [ dl([ //literal("
 
\n"), literal(""), dd([style("display: none"),id("drapo1"), event(onmouseover, "montre('drapo1');"), event(onmouseout, "montre();")], ul( map(make_line, l3_get_all_dicos(dictionary_collection_name))+ [ if show_symbolic then language_line("symb", "symbolic") else empty ] )), ]) //!dl ] ) . public define HTML_Partial_Content flags_menu ( WEB_Session _session, Bool show_symbolic, (LogLevel, String) -> One logger ) = with lang = _session.language, app_dictionnary = get_dictionary(_session), flags_menu(app_dictionnary, lang, show_symbolic, logger) .