From febdc6fdf95188f3fdc285811e3206dca95e721a Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 10 Mar 2021 18:08:54 +0100 Subject: [PATCH] Add language --- manifest.json | 10 ++++++++++ scripts/install | 13 ++++++++++--- scripts/upgrade | 12 ++++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/manifest.json b/manifest.json index 5c52be5..b05e18a 100644 --- a/manifest.json +++ b/manifest.json @@ -53,6 +53,16 @@ "fr": "Si cette case est cochée, TiddlyWiki sera accessible aux personnes n’ayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin." }, "default": true + }, + { + "name": "language", + "type": "string", + "ask": { + "en": "Choose the application language", + "fr": "Choisissez la langue de l'application" + }, + "choices": ["fr", "en"], + "default": "fr" } ] } diff --git a/scripts/install b/scripts/install index de02526..6d31eb5 100755 --- a/scripts/install +++ b/scripts/install @@ -22,6 +22,7 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC +language=$YNH_APP_ARG_LANGUAGE app=$YNH_APP_INSTANCE_NAME @@ -42,8 +43,9 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= ynh_script_progression --message="Storing installation settings..." --weight=2 -ynh_app_setting_set --app=$app --key=domain --value=$domain -ynh_app_setting_set --app=$app --key=path --value=$path_url +ynh_app_setting_set --app=$app --key=domain --value=$domain +ynh_app_setting_set --app=$app --key=path --value=$path_url +ynh_app_setting_set --app=$app --key=language --value=$language #================================================= # STANDARD MODIFICATIONS @@ -58,7 +60,12 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path #ynh_setup_source --dest_dir="$final_path" mkdir -p $final_path -cp -a ../sources/empty.html $final_path/empty.html + +if [ "$language" = "fr" ]; then + cp -a ../sources/empty_fr.html $final_path/empty.html +else + cp -a ../sources/empty.html $final_path/empty.html +fi #================================================= # NGINX CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index 90cac05..1a882b3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -18,6 +18,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +language=$(ynh_app_setting_get --app=$app --key=language) #================================================= # CHECK VERSION @@ -36,6 +37,12 @@ if [ -z "$final_path" ]; then ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi +# Save the language used if not present +if [ -z "$language" ]; then + language="en" + ynh_app_setting_set --app=$app --key=language --value=$language +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -61,7 +68,12 @@ then # Download, check integrity, uncompress and patch the source from app.src #ynh_setup_source --dest_dir="$final_path" mkdir -p $final_path + + if [ "$language" = "fr" ]; then + cp -a ../sources/empty_fr.html $final_path/empty.html + else cp -a ../sources/empty.html $final_path/empty.html + fi fi #=================================================