Commit e4322160bc99742f8283441ca12a823993ab8793
1 parent
4cc2911c
move the language and management into xlib web_controllers. This is due to move …
…of Application internal code to generic one web controller (Hayamiki). Needs to be improve
Showing
2 changed files
with
95 additions
and
0 deletions
Show diff stats
| 1 | +/* | |
| 2 | + * Created by PyramIDE. | |
| 3 | + * User: フランスのトトロ aka (David RENÉ) | |
| 4 | + * Date: 17/04/2020 | |
| 5 | + * Time: 15:06 | |
| 6 | + * © David RENÉ | |
| 7 | + */ | |
| 8 | + | |
| 9 | + | |
| 10 | +read hayamiki_lib/controller/hk_sql_utils.anubis | |
| 11 | +read database/generated/fs_file.anubis | |
| 12 | + | |
| 13 | +public define String app_fs = get_current_directory + "/fs/". | |
| 14 | + | |
| 15 | +public define One | |
| 16 | + set_file | |
| 17 | + ( | |
| 18 | + SQLite3DataBase db, | |
| 19 | + String res_model, // product_item | |
| 20 | + DB_id res_id, // 5 | |
| 21 | + String res_name, // toto | |
| 22 | + String res_type, // "64x64" | |
| 23 | + String name, // name of the file 'toto.jpg.64x64.png' | |
| 24 | + String path // path from "app_fs" where the file is located | |
| 25 | + )= | |
| 26 | + with id = get_DB_id_by_clause(db, "fs_file", "res_model = '"+res_model+"' AND res_id = "+res_id+" AND res_field = '"+res_type+"'"), | |
| 27 | + with fields = (List(SQLite3_update_field)) | |
| 28 | + [ field("write_date", bind_Datetime(":v_write_date", db_now)), | |
| 29 | + field("res_model", bind_String(":v_res_model", res_model)), | |
| 30 | + field("res_id", bind_Int(":v_res_id", to_Int(res_id))), | |
| 31 | + field("res_name", bind_String(":v_res_name", res_name)), | |
| 32 | + field("res_field", bind_String(":v_res_field", res_type)), | |
| 33 | + field("name", bind_String(":v_name", name)), | |
| 34 | + field("path", bind_String(":v_path", path)) | |
| 35 | + ], | |
| 36 | + forget(insert_or_update(db, "fs_file", id, fields)) | |
| 37 | +. | |
| 38 | + | |
| 39 | +public define Maybe(String) | |
| 40 | + get_file | |
| 41 | + ( | |
| 42 | + SQLite3DataBase db, | |
| 43 | + String res_model, | |
| 44 | + DB_id res_id, | |
| 45 | + String res_type | |
| 46 | + )= | |
| 47 | + with clause = "res_model = '"+res_model+"' AND res_id = "+res_id+" AND res_field = '"+res_type+"'", | |
| 48 | + | |
| 49 | + if get_fs_file_by_clause(db, "res_model = '"+res_model+"' AND res_id = "+res_id+" AND res_field = '"+res_type+"'") is | |
| 50 | + { | |
| 51 | + failure then | |
| 52 | + println("get_file FAILURE ["+clause+"]"); | |
| 53 | + //println("failure"); | |
| 54 | + failure, | |
| 55 | + success(the_file) then | |
| 56 | + //println("success ["+app_fs+the_file.path+the_file.name+"]"); | |
| 57 | + success(app_fs+the_file.path+the_file.name) | |
| 58 | + } | |
| 59 | +. | ... | ... |
web_controllers/language/language_management.anubis
0 → 100644
| 1 | +/* | |
| 2 | + * Created by PyramIDE. | |
| 3 | + * User: フランスのトトロ aka (David RENÉ) | |
| 4 | + * Date: 17/04/2020 | |
| 5 | + * Time: 15:00 | |
| 6 | + * © David RENÉ | |
| 7 | + */ | |
| 8 | + | |
| 9 | +read locale/L3.anubis | |
| 10 | +read xlib/web/CXM_web_session.anubis | |
| 11 | +read app/app_loggers.anubis | |
| 12 | + | |
| 13 | +public define String default_language = "en". | |
| 14 | + | |
| 15 | +public define (String symbolic_name) -> String | |
| 16 | + make_translate_function | |
| 17 | + ( | |
| 18 | + WEB_Session _session | |
| 19 | + ) = | |
| 20 | + with lang = _session.language, | |
| 21 | + app_dictionnary = get_String(_session.fields, "AWS_CURRENT_DICTIONARY", ""), | |
| 22 | + if l3_load_base(app_dictionnary) is | |
| 23 | + { | |
| 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 | |
| 27 | + | |
| 28 | + //now we set the current language | |
| 29 | + with _l3_object = l3_set_current(local, lang), | |
| 30 | + l3_object = l3_set_default(_l3_object, default_language), | |
| 31 | + 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) | |
| 35 | + } | |
| 36 | +. | ... | ... |