diff options
-rw-r--r-- | doc/de/autogen/user/script_options.txt | 5 | ||||
-rw-r--r-- | doc/en/autogen/user/script_options.txt | 5 | ||||
-rw-r--r-- | doc/fr/autogen/user/script_options.txt | 5 | ||||
-rw-r--r-- | doc/it/autogen/user/script_options.txt | 5 | ||||
-rw-r--r-- | doc/ja/autogen/user/script_options.txt | 5 | ||||
-rw-r--r-- | po/cs.po | 7 | ||||
-rw-r--r-- | po/de.po | 7 | ||||
-rw-r--r-- | po/es.po | 7 | ||||
-rw-r--r-- | po/fr.po | 11 | ||||
-rw-r--r-- | po/hu.po | 7 | ||||
-rw-r--r-- | po/it.po | 7 | ||||
-rw-r--r-- | po/ja.po | 7 | ||||
-rw-r--r-- | po/pl.po | 7 | ||||
-rw-r--r-- | po/pt_BR.po | 7 | ||||
-rw-r--r-- | po/ru.po | 7 | ||||
-rw-r--r-- | po/weechat.pot | 7 | ||||
-rw-r--r-- | src/plugins/script/script-config.c | 20 | ||||
-rw-r--r-- | src/plugins/script/script-config.h | 1 | ||||
-rw-r--r-- | src/plugins/script/script-repo.c | 105 |
19 files changed, 199 insertions, 33 deletions
diff --git a/doc/de/autogen/user/script_options.txt b/doc/de/autogen/user/script_options.txt index e7424911b..f5f3ddb48 100644 --- a/doc/de/autogen/user/script_options.txt +++ b/doc/de/autogen/user/script_options.txt @@ -138,6 +138,11 @@ ** Typ: Zeichenkette ** Werte: beliebige Zeichenkette (Standardwert: `"p,n"`) +* [[option_script.look.translate_description]] *script.look.translate_description* +** Beschreibung: `translate description of scripts (if translation is available in your language, otherwise english version is used)` +** Typ: boolesch +** Werte: on, off (Standardwert: `on`) + * [[option_script.scripts.cache_expire]] *script.scripts.cache_expire* ** Beschreibung: `local cache expiration time, in minutes (-1 = never expires, 0 = always expire)` ** Typ: integer diff --git a/doc/en/autogen/user/script_options.txt b/doc/en/autogen/user/script_options.txt index 8f83803b1..f5a61dd47 100644 --- a/doc/en/autogen/user/script_options.txt +++ b/doc/en/autogen/user/script_options.txt @@ -138,6 +138,11 @@ ** type: string ** values: any string (default value: `"p,n"`) +* [[option_script.look.translate_description]] *script.look.translate_description* +** description: `translate description of scripts (if translation is available in your language, otherwise english version is used)` +** type: boolean +** values: on, off (default value: `on`) + * [[option_script.scripts.cache_expire]] *script.scripts.cache_expire* ** description: `local cache expiration time, in minutes (-1 = never expires, 0 = always expire)` ** type: integer diff --git a/doc/fr/autogen/user/script_options.txt b/doc/fr/autogen/user/script_options.txt index 1ebe7639c..fc0ac1af6 100644 --- a/doc/fr/autogen/user/script_options.txt +++ b/doc/fr/autogen/user/script_options.txt @@ -138,6 +138,11 @@ ** type: chaîne ** valeurs: toute chaîne (valeur par défaut: `"p,n"`) +* [[option_script.look.translate_description]] *script.look.translate_description* +** description: `traduire la description des scripts (si une traduction est disponible dans votre langue, sinon la version anglaise est utilisée)` +** type: booléen +** valeurs: on, off (valeur par défaut: `on`) + * [[option_script.scripts.cache_expire]] *script.scripts.cache_expire* ** description: `temps d'expiration du cache local, en minutes (-1 = n'expire jamais, 0 = expire toujours)` ** type: entier diff --git a/doc/it/autogen/user/script_options.txt b/doc/it/autogen/user/script_options.txt index d5154a591..5baed43cd 100644 --- a/doc/it/autogen/user/script_options.txt +++ b/doc/it/autogen/user/script_options.txt @@ -138,6 +138,11 @@ ** tipo: stringa ** valori: qualsiasi stringa (valore predefinito: `"p,n"`) +* [[option_script.look.translate_description]] *script.look.translate_description* +** descrizione: `translate description of scripts (if translation is available in your language, otherwise english version is used)` +** tipo: bool +** valori: on, off (valore predefinito: `on`) + * [[option_script.scripts.cache_expire]] *script.scripts.cache_expire* ** descrizione: `local cache expiration time, in minutes (-1 = never expires, 0 = always expire)` ** tipo: intero diff --git a/doc/ja/autogen/user/script_options.txt b/doc/ja/autogen/user/script_options.txt index 68f19ad1e..21a1de21f 100644 --- a/doc/ja/autogen/user/script_options.txt +++ b/doc/ja/autogen/user/script_options.txt @@ -138,6 +138,11 @@ ** タイプ: 文字列 ** 値: 未制約文字列 (デフォルト値: `"p,n"`) +* [[option_script.look.translate_description]] *script.look.translate_description* +** 説明: `translate description of scripts (if translation is available in your language, otherwise english version is used)` +** タイプ: ブール +** 値: on, off (デフォルト値: `on`) + * [[option_script.scripts.cache_expire]] *script.scripts.cache_expire* ** 説明: `local cache expiration time, in minutes (-1 = never expires, 0 = always expire)` ** タイプ: 整数 @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.9-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-08-16 12:01+0200\n" +"POT-Creation-Date: 2012-08-16 12:18+0200\n" "PO-Revision-Date: 2012-08-16 12:01+0200\n" "Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -8394,6 +8394,11 @@ msgid "" "scripts first, sorted by update date" msgstr "" +msgid "" +"translate description of scripts (if translation is available in your " +"language, otherwise english version is used)" +msgstr "" + #, fuzzy msgid "color for status \"popular\" (\"*\")" msgstr "barva textu pro čas (stavový řádek)" @@ -23,7 +23,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-08-16 12:01+0200\n" +"POT-Creation-Date: 2012-08-16 12:18+0200\n" "PO-Revision-Date: 2012-08-16 12:01+0200\n" "Last-Translator: Nils Görs <weechatter@arcor.de>\n" "Language-Team: German <weechatter@arcor.de>\n" @@ -8968,6 +8968,11 @@ msgid "" "scripts first, sorted by update date" msgstr "" +msgid "" +"translate description of scripts (if translation is available in your " +"language, otherwise english version is used)" +msgstr "" + #, fuzzy msgid "color for status \"popular\" (\"*\")" msgstr "Textfarbe für die Uhrzeit (Statusbar)" @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.9-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-08-16 12:01+0200\n" +"POT-Creation-Date: 2012-08-16 12:18+0200\n" "PO-Revision-Date: 2012-08-16 12:01+0200\n" "Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -8667,6 +8667,11 @@ msgid "" "scripts first, sorted by update date" msgstr "" +msgid "" +"translate description of scripts (if translation is available in your " +"language, otherwise english version is used)" +msgstr "" + #, fuzzy msgid "color for status \"popular\" (\"*\")" msgstr "color para el texto de la hora (en la barra de estado)" @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.9-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-08-16 12:01+0200\n" -"PO-Revision-Date: 2012-08-16 12:01+0200\n" +"POT-Creation-Date: 2012-08-16 12:18+0200\n" +"PO-Revision-Date: 2012-08-16 12:19+0200\n" "Last-Translator: Sebastien Helleu <flashcode@flashtux.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language: French\n" @@ -8794,6 +8794,13 @@ msgstr "" "caractère \"-\" peut être utilisé avant l'identifiant pour inverser l'ordre; " "exemple: \"i,u\": scripts installés en premier, triés par date de mise à jour" +msgid "" +"translate description of scripts (if translation is available in your " +"language, otherwise english version is used)" +msgstr "" +"traduire la description des scripts (si une traduction est disponible dans " +"votre langue, sinon la version anglaise est utilisée)" + msgid "color for status \"popular\" (\"*\")" msgstr "couleur du statut \"populaire\" (\"*\")" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.9-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-08-16 12:01+0200\n" +"POT-Creation-Date: 2012-08-16 12:18+0200\n" "PO-Revision-Date: 2012-08-16 12:01+0200\n" "Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -7875,6 +7875,11 @@ msgid "" "scripts first, sorted by update date" msgstr "" +msgid "" +"translate description of scripts (if translation is available in your " +"language, otherwise english version is used)" +msgstr "" + #, fuzzy msgid "color for status \"popular\" (\"*\")" msgstr "státuszsor színe" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.9-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-08-16 12:01+0200\n" +"POT-Creation-Date: 2012-08-16 12:18+0200\n" "PO-Revision-Date: 2012-08-16 12:01+0200\n" "Last-Translator: Marco Paolone <marcopaolone@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -8657,6 +8657,11 @@ msgid "" "scripts first, sorted by update date" msgstr "" +msgid "" +"translate description of scripts (if translation is available in your " +"language, otherwise english version is used)" +msgstr "" + #, fuzzy msgid "color for status \"popular\" (\"*\")" msgstr "colore del testo per l'ora (barra di stato)" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.9-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-08-16 12:01+0200\n" +"POT-Creation-Date: 2012-08-16 12:18+0200\n" "PO-Revision-Date: 2012-08-16 12:01+0200\n" "Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n" "Language-Team: Japanese <https://github.com/l/WeeChat>\n" @@ -8456,6 +8456,11 @@ msgid "" "scripts first, sorted by update date" msgstr "" +msgid "" +"translate description of scripts (if translation is available in your " +"language, otherwise english version is used)" +msgstr "" + #, fuzzy msgid "color for status \"popular\" (\"*\")" msgstr "時間のテキスト色 (ステータスバー)" @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.9-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-08-16 12:01+0200\n" +"POT-Creation-Date: 2012-08-16 12:18+0200\n" "PO-Revision-Date: 2012-08-16 12:01+0200\n" "Last-Translator: Krzysztof Korościk <soltys@szluug.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -8590,6 +8590,11 @@ msgid "" "scripts first, sorted by update date" msgstr "" +msgid "" +"translate description of scripts (if translation is available in your " +"language, otherwise english version is used)" +msgstr "" + #, fuzzy msgid "color for status \"popular\" (\"*\")" msgstr "kolor czasu (pasek statusu)" diff --git a/po/pt_BR.po b/po/pt_BR.po index ee7b6161b..23d75ef46 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.9-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-08-16 12:01+0200\n" +"POT-Creation-Date: 2012-08-16 12:18+0200\n" "PO-Revision-Date: 2012-08-16 12:02+0200\n" "Last-Translator: Sergio Durigan Junior <sergiosdj@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -8025,6 +8025,11 @@ msgid "" "scripts first, sorted by update date" msgstr "" +msgid "" +"translate description of scripts (if translation is available in your " +"language, otherwise english version is used)" +msgstr "" + #, fuzzy msgid "color for status \"popular\" (\"*\")" msgstr "cor de texto para o tempo (barra de status)" @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.9-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-08-16 12:01+0200\n" +"POT-Creation-Date: 2012-08-16 12:18+0200\n" "PO-Revision-Date: 2012-08-16 12:02+0200\n" "Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -7898,6 +7898,11 @@ msgid "" "scripts first, sorted by update date" msgstr "" +msgid "" +"translate description of scripts (if translation is available in your " +"language, otherwise english version is used)" +msgstr "" + #, fuzzy msgid "color for status \"popular\" (\"*\")" msgstr "цвет строки состояния" diff --git a/po/weechat.pot b/po/weechat.pot index fdbc21cee..eb7b9c686 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-08-16 12:01+0200\n" +"POT-Creation-Date: 2012-08-16 12:18+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -6950,6 +6950,11 @@ msgid "" "scripts first, sorted by update date" msgstr "" +msgid "" +"translate description of scripts (if translation is available in your " +"language, otherwise english version is used)" +msgstr "" + msgid "color for status \"popular\" (\"*\")" msgstr "" diff --git a/src/plugins/script/script-config.c b/src/plugins/script/script-config.c index 1a3f78de8..7de9d1440 100644 --- a/src/plugins/script/script-config.c +++ b/src/plugins/script/script-config.c @@ -41,6 +41,7 @@ struct t_config_section *script_config_section_scripts = NULL; struct t_config_option *script_config_look_columns; struct t_config_option *script_config_look_sort; +struct t_config_option *script_config_look_translate_description; /* script config, color section */ @@ -155,8 +156,8 @@ script_config_get_script_download_filename (struct t_repo_script *script) } /* - * script_config_refresh_cb: callback called when user changes xfer option that - * needs a refresh of script list + * script_config_refresh_cb: callback called when script buffer needs to be + * refreshed */ void @@ -171,12 +172,12 @@ script_config_refresh_cb (void *data, struct t_config_option *option) } /* - * script_config_change_sort_cb: callback called when default sort keys are - * changed + * script_config_reload_scripts_cb: callback called list of scripts must be + * reloaded from file (plugins.xml.gz) */ void -script_config_change_sort_cb (void *data, struct t_config_option *option) +script_config_reload_scripts_cb (void *data, struct t_config_option *option) { /* make C compiler happy */ (void) data; @@ -350,7 +351,14 @@ script_config_init () "order; example: \"i,u\": installed scripts first, sorted by update " "date"), NULL, 0, 0, "p,n", NULL, 0, - NULL, NULL, &script_config_change_sort_cb, NULL, NULL, NULL); + NULL, NULL, &script_config_reload_scripts_cb, NULL, NULL, NULL); + script_config_look_translate_description = weechat_config_new_option ( + script_config_file, ptr_section, + "translate_description", "boolean", + N_("translate description of scripts (if translation is available in " + "your language, otherwise english version is used)"), + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, &script_config_reload_scripts_cb, NULL, NULL, NULL); /* color */ ptr_section = weechat_config_new_section (script_config_file, "color", diff --git a/src/plugins/script/script-config.h b/src/plugins/script/script-config.h index b28071863..ca9f5aaf8 100644 --- a/src/plugins/script/script-config.h +++ b/src/plugins/script/script-config.h @@ -26,6 +26,7 @@ struct t_repo_script; extern struct t_config_option *script_config_look_columns; extern struct t_config_option *script_config_look_sort; +extern struct t_config_option *script_config_look_translate_description; extern struct t_config_option *script_config_color_status_popular; extern struct t_config_option *script_config_color_status_installed; diff --git a/src/plugins/script/script-repo.c b/src/plugins/script/script-repo.c index 4b88d160f..1eb15a48c 100644 --- a/src/plugins/script/script-repo.c +++ b/src/plugins/script/script-repo.c @@ -816,11 +816,13 @@ script_repo_file_read (int quiet) { char *filename, *ptr_line, line[4096], *pos, *pos2, *pos3; char *name, *value1, *value2, *value3, *value, *error; - const char *version; + char *locale, *locale_language; + const char *version, *ptr_locale, *ptr_desc; gzFile file; struct t_repo_script *script; int version_number, version_ok, script_ok, length; struct tm tm_script; + struct t_hashtable *descriptions; script_get_loaded_scripts (); @@ -866,6 +868,39 @@ script_repo_file_read (int quiet) return 0; } + /* + * get locale and locale_languages + * example: if LANG=fr_FR.UTF-8, result is: + * locale = "fr_FR" + * locale_language = "fr" + */ + locale = NULL; + locale_language = NULL; + ptr_locale = weechat_info_get ("locale", NULL); + if (ptr_locale) + { + pos = strchr (ptr_locale, '.'); + if (pos) + locale = weechat_strndup (ptr_locale, pos - ptr_locale); + else + locale = strdup (ptr_locale); + } + if (locale) + { + pos = strchr (locale, '_'); + if (pos) + locale_language = weechat_strndup (locale, pos - locale); + else + locale_language = strdup (locale); + } + + descriptions = weechat_hashtable_new (8, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING, + NULL, + NULL); + + /* read plugins.xml.gz */ while (!gzeof (file)) { ptr_line = gzgets (file, line, sizeof (line) - 1); @@ -874,6 +909,7 @@ script_repo_file_read (int quiet) if (strstr (ptr_line, "<plugin id=")) { script = script_repo_alloc (); + weechat_hashtable_remove_all (descriptions); } else if (strstr (ptr_line, "</plugin>")) { @@ -895,20 +931,43 @@ script_repo_file_read (int quiet) } if (version_ok) { - length = strlen (script->name) + 1 + - strlen (script_extension[script->language]) + 1; - script->name_with_extension = malloc (length); - if (script->name_with_extension) + ptr_desc = NULL; + if (weechat_config_boolean (script_config_look_translate_description)) { - snprintf (script->name_with_extension, - length, - "%s.%s", - script->name, - script_extension[script->language]); + /* try translated description (format "fr_FR") */ + ptr_desc = weechat_hashtable_get (descriptions, + locale); + if (!ptr_desc) + { + /* try translated description (format "fr") */ + ptr_desc = weechat_hashtable_get (descriptions, + locale_language); + } + } + if (!ptr_desc) + { + /* default description (english) */ + ptr_desc = weechat_hashtable_get (descriptions, + "en"); + } + if (ptr_desc) + { + script->description = strdup (ptr_desc); + length = strlen (script->name) + 1 + + strlen (script_extension[script->language]) + 1; + script->name_with_extension = malloc (length); + if (script->name_with_extension) + { + snprintf (script->name_with_extension, + length, + "%s.%s", + script->name, + script_extension[script->language]); + } + script_repo_update_status (script); + script_repo_add (script); + script_ok = 1; } - script_repo_update_status (script); - script_repo_add (script); - script_ok = 1; } } if (!script_ok) @@ -948,8 +1007,17 @@ script_repo_file_read (int quiet) script->version = strdup (value); else if (strcmp (name, "license") == 0) script->license = strdup (value); - else if (strcmp (name, "desc_en") == 0) - script->description = strdup (value); + else if (strncmp (name, "desc_", 5) == 0) + { + /* + * store translated description in hashtable + * (will be used later, by choosing + * appropriate language according to locale) + */ + weechat_hashtable_set (descriptions, + name + 5, + value); + } else if (strcmp (name, "tags") == 0) script->tags = strdup (value); else if (strcmp (name, "requirements") == 0) @@ -1034,6 +1102,13 @@ script_repo_file_read (int quiet) SCRIPT_PLUGIN_NAME); } + if (locale) + free (locale); + if (locale_language) + free (locale_language); + if (descriptions) + weechat_hashtable_free (descriptions); + return 1; } |