From 2d9b20157957a55bd83875775085ed31c9062577 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 15 Mar 2014 14:58:52 -0300 Subject: Squashed 'mod/translation_editor/' content from commit 9d86955 git-subtree-dir: mod/translation_editor git-subtree-split: 9d86955e6d8b6807578f5a9da0346ac1a146881c --- CHANGES.txt | 102 ++++ README.txt | 21 + _graphics/flags/ar.png | Bin 0 -> 938 bytes _graphics/flags/bg.png | Bin 0 -> 118 bytes _graphics/flags/ca.png | Bin 0 -> 134 bytes _graphics/flags/cs.png | Bin 0 -> 191 bytes _graphics/flags/da.png | Bin 0 -> 130 bytes _graphics/flags/de.png | Bin 0 -> 111 bytes _graphics/flags/el.png | Bin 0 -> 189 bytes _graphics/flags/en.png | Bin 0 -> 210 bytes _graphics/flags/eo.png | Bin 0 -> 153 bytes _graphics/flags/es.png | Bin 0 -> 241 bytes _graphics/flags/et.png | Bin 0 -> 144 bytes _graphics/flags/eu.png | Bin 0 -> 407 bytes _graphics/flags/fa.png | Bin 0 -> 324 bytes _graphics/flags/fi.png | Bin 0 -> 145 bytes _graphics/flags/fo.png | Bin 0 -> 182 bytes _graphics/flags/fr.png | Bin 0 -> 116 bytes _graphics/flags/ga.png | Bin 0 -> 117 bytes _graphics/flags/gl.png | Bin 0 -> 396 bytes _graphics/flags/he.png | Bin 0 -> 165 bytes _graphics/flags/hi.png | Bin 0 -> 171 bytes _graphics/flags/hr.png | Bin 0 -> 304 bytes _graphics/flags/hu.png | Bin 0 -> 119 bytes _graphics/flags/id.png | Bin 0 -> 107 bytes _graphics/flags/is.png | Bin 0 -> 157 bytes _graphics/flags/it.png | Bin 0 -> 116 bytes _graphics/flags/ja.png | Bin 0 -> 154 bytes _graphics/flags/km.png | Bin 0 -> 273 bytes _graphics/flags/ko.png | Bin 0 -> 567 bytes _graphics/flags/lb.png | Bin 0 -> 119 bytes _graphics/flags/lt.png | Bin 0 -> 147 bytes _graphics/flags/lv.png | Bin 0 -> 144 bytes _graphics/flags/mn.png | Bin 0 -> 238 bytes _graphics/flags/nb.png | Bin 0 -> 128 bytes _graphics/flags/nl.png | Bin 0 -> 121 bytes _graphics/flags/nn.png | Bin 0 -> 128 bytes _graphics/flags/pl.png | Bin 0 -> 113 bytes _graphics/flags/pt-br.png | Bin 0 -> 313 bytes _graphics/flags/pt-pt.png | Bin 0 -> 271 bytes _graphics/flags/ro.png | Bin 0 -> 111 bytes _graphics/flags/ru.png | Bin 0 -> 121 bytes _graphics/flags/sco.png | Bin 0 -> 188 bytes _graphics/flags/se.png | Bin 0 -> 219 bytes _graphics/flags/sk.png | Bin 0 -> 259 bytes _graphics/flags/sl.png | Bin 0 -> 197 bytes _graphics/flags/sq.png | Bin 0 -> 266 bytes _graphics/flags/sr.png | Bin 0 -> 475 bytes _graphics/flags/sv.png | Bin 0 -> 144 bytes _graphics/flags/tg.png | Bin 0 -> 211 bytes _graphics/flags/th.png | Bin 0 -> 132 bytes _graphics/flags/tl.png | Bin 0 -> 347 bytes _graphics/flags/tr.png | Bin 0 -> 198 bytes _graphics/flags/uk.png | Bin 0 -> 108 bytes _graphics/flags/vi.png | Bin 0 -> 223 bytes _graphics/flags/zh-hans.png | Bin 0 -> 262 bytes _graphics/flags/zh-hant.png | Bin 0 -> 174 bytes _graphics/key.gif | Bin 0 -> 917 bytes actions/add_custom_key.php | 64 +++ actions/add_language.php | 19 + actions/delete.php | 20 + actions/delete_language.php | 26 + actions/disable_languages.php | 23 + actions/make_translation_editor.php | 23 + actions/merge.php | 29 + actions/translate.php | 76 +++ actions/translate_search.php | 84 +++ actions/unmake_translation_editor.php | 20 + languages/ca.php | 57 ++ languages/de.php | 56 ++ languages/en.php | 83 +++ languages/es.php | 59 +++ languages/fr.php | 80 +++ languages/nl.php | 56 ++ lib/events.php | 9 + lib/functions.php | 581 +++++++++++++++++++++ lib/hooks.php | 45 ++ manifest.xml | 17 + pages/index.php | 64 +++ pages/search.php | 32 ++ start.php | 139 +++++ views/default/core/settings/account/language.php | 42 ++ .../plugins/translation_editor/settings.php | 20 + .../default/translation_editor/add_custom_key.php | 21 + views/default/translation_editor/add_language.php | 167 ++++++ views/default/translation_editor/css/site.php | 99 ++++ views/default/translation_editor/js/site.php | 41 ++ .../translation_editor/language_selector.php | 88 ++++ views/default/translation_editor/plugin_edit.php | 147 ++++++ views/default/translation_editor/plugin_list.php | 84 +++ views/default/translation_editor/search.php | 43 ++ .../default/translation_editor/search_results.php | 78 +++ 92 files changed, 2615 insertions(+) create mode 100644 CHANGES.txt create mode 100644 README.txt create mode 100644 _graphics/flags/ar.png create mode 100644 _graphics/flags/bg.png create mode 100644 _graphics/flags/ca.png create mode 100644 _graphics/flags/cs.png create mode 100644 _graphics/flags/da.png create mode 100644 _graphics/flags/de.png create mode 100644 _graphics/flags/el.png create mode 100644 _graphics/flags/en.png create mode 100644 _graphics/flags/eo.png create mode 100644 _graphics/flags/es.png create mode 100644 _graphics/flags/et.png create mode 100644 _graphics/flags/eu.png create mode 100644 _graphics/flags/fa.png create mode 100644 _graphics/flags/fi.png create mode 100644 _graphics/flags/fo.png create mode 100644 _graphics/flags/fr.png create mode 100644 _graphics/flags/ga.png create mode 100644 _graphics/flags/gl.png create mode 100644 _graphics/flags/he.png create mode 100644 _graphics/flags/hi.png create mode 100644 _graphics/flags/hr.png create mode 100644 _graphics/flags/hu.png create mode 100644 _graphics/flags/id.png create mode 100644 _graphics/flags/is.png create mode 100644 _graphics/flags/it.png create mode 100644 _graphics/flags/ja.png create mode 100644 _graphics/flags/km.png create mode 100644 _graphics/flags/ko.png create mode 100644 _graphics/flags/lb.png create mode 100644 _graphics/flags/lt.png create mode 100644 _graphics/flags/lv.png create mode 100644 _graphics/flags/mn.png create mode 100644 _graphics/flags/nb.png create mode 100644 _graphics/flags/nl.png create mode 100644 _graphics/flags/nn.png create mode 100644 _graphics/flags/pl.png create mode 100644 _graphics/flags/pt-br.png create mode 100644 _graphics/flags/pt-pt.png create mode 100644 _graphics/flags/ro.png create mode 100644 _graphics/flags/ru.png create mode 100644 _graphics/flags/sco.png create mode 100644 _graphics/flags/se.png create mode 100644 _graphics/flags/sk.png create mode 100644 _graphics/flags/sl.png create mode 100644 _graphics/flags/sq.png create mode 100644 _graphics/flags/sr.png create mode 100644 _graphics/flags/sv.png create mode 100644 _graphics/flags/tg.png create mode 100644 _graphics/flags/th.png create mode 100644 _graphics/flags/tl.png create mode 100644 _graphics/flags/tr.png create mode 100644 _graphics/flags/uk.png create mode 100644 _graphics/flags/vi.png create mode 100644 _graphics/flags/zh-hans.png create mode 100644 _graphics/flags/zh-hant.png create mode 100644 _graphics/key.gif create mode 100644 actions/add_custom_key.php create mode 100644 actions/add_language.php create mode 100644 actions/delete.php create mode 100644 actions/delete_language.php create mode 100644 actions/disable_languages.php create mode 100644 actions/make_translation_editor.php create mode 100644 actions/merge.php create mode 100644 actions/translate.php create mode 100644 actions/translate_search.php create mode 100644 actions/unmake_translation_editor.php create mode 100644 languages/ca.php create mode 100644 languages/de.php create mode 100644 languages/en.php create mode 100644 languages/es.php create mode 100644 languages/fr.php create mode 100644 languages/nl.php create mode 100644 lib/events.php create mode 100644 lib/functions.php create mode 100644 lib/hooks.php create mode 100644 manifest.xml create mode 100644 pages/index.php create mode 100644 pages/search.php create mode 100644 start.php create mode 100644 views/default/core/settings/account/language.php create mode 100644 views/default/plugins/translation_editor/settings.php create mode 100644 views/default/translation_editor/add_custom_key.php create mode 100644 views/default/translation_editor/add_language.php create mode 100644 views/default/translation_editor/css/site.php create mode 100644 views/default/translation_editor/js/site.php create mode 100644 views/default/translation_editor/language_selector.php create mode 100644 views/default/translation_editor/plugin_edit.php create mode 100644 views/default/translation_editor/plugin_list.php create mode 100644 views/default/translation_editor/search.php create mode 100644 views/default/translation_editor/search_results.php diff --git a/CHANGES.txt b/CHANGES.txt new file mode 100644 index 000000000..a2a0e6431 --- /dev/null +++ b/CHANGES.txt @@ -0,0 +1,102 @@ += Version history = +x.x: + +- added: german translation (thanks to Originalhardy http://community.elgg.org/pg/profile/Originalhardy) +- changed: internal function for better performance +- removed: some legacy code + +1.2.1 (2012-03-02): + +- fixed: CSS issue on plugin edit +- fixed: custom translations not loaded in some cases +- fixed: language selection (on settings) sometimes displays to many languages +- fixed: not using an available function +- fixed: using define in stead of string +- fixed: issue where disabled languages could not be removed +- changed: layout to be consistent with Elgg design +- removed: some icons where replaced by Elgg default icons + +1.2 (2011-12-06): + +- added: French translation for version 1.1, thanks to Jean-Baptiste Duclos (http://community.elgg.org/pg/profile/Duclos) +- fixed: a deadloop problem with detecting vsprintf aguments is some cases + +1.1 (2011-11-28): + +- added: event trigger on merge of a translation "language:merge" => "translation_editor" +- fixed: page_handler issue with Elgg 1.8.1 + +1.0 (2011-11-14): + +- added: check on missing params in sprintf strings +- fixed: removing of custom translations failed due to missing JS function +- fixed: depricated notice in add language form +- fixed: translations reload on plugin enable/disable +- fixed: translations reload when running upgrade.php +- changed: links to merge and delete custom translation + +1.0 beta (2011-10-05): + +- added: shortcut link from translation search results to related plugins +- added: breadcrumb navigation +- changed: support for Elgg 1.8 +- changed: layout cleanup + +0.6 (2011-07-27): + +- added: key search +- fixed: typo in translate action +- changed: improved search performance + +0.5.4 (2011-05-31): + +- fixed: translation caching on multisite setup + +0.5.3 (2011-05-17): + +- changed: translations event moved to jQuery Live +- changed: loading of translation now from one file + +0.5.2 (2011-04-05): + +- fixed: language save bug when only one language is available + +0.5.1 (2011-01-04): + +- fixed: division by zero error +- fixed: disableing languages when simplecache is enabled +- fixed: apache warning when no customkeys have been made yet +- fixed: elgg_deprecated warning in start.php + +0.5 (2010-12-20): + +- added: disable a language +- added: user will have no language selector (settings) option if only english is installed +- added: add a custom language +- added: search for translations +- added: add custom translation keys +- added: current site language in language list + +0.4: + +- added: jQuery save onChange textarea +- added: security tokens (for Elgg 1.7) +- added: admin option to delete translation +- fixed: bug with unsupported data type when having the translator role +- fixed: tools menu item not working (credit to Zacke) + +0.3 (2010-01-25): + +- added: allowedprotocols jaavscript +- added: allowedtags attribute onclick for a +- added: allowedtags attribute id for span + +0.2 (2010-01-19): + +- added: option to merge translations to a PHP/Elgg language file +- added: column to see how many keys are translated +- added: filter for custom translations + +0.1: + +- initial release \ No newline at end of file diff --git a/README.txt b/README.txt new file mode 100644 index 000000000..26f2e0eda --- /dev/null +++ b/README.txt @@ -0,0 +1,21 @@ += Translation Editor = + +Manage translations + +== Contents == + +1. Features +2. Special thanks + +== 1. Features == +- Edit translations +- Assign multiple translators +- Add custom languages +- Add custom keys +- Caching of language files + +== 2. Special thanks == +Special thanks goes out to to following people: + +Jean-Baptiste Duclos (http://community.elgg.org/pg/profile/Duclos) +For providing a French translation of version 1.1 \ No newline at end of file diff --git a/_graphics/flags/ar.png b/_graphics/flags/ar.png new file mode 100644 index 000000000..3d048ef71 Binary files /dev/null and b/_graphics/flags/ar.png differ diff --git a/_graphics/flags/bg.png b/_graphics/flags/bg.png new file mode 100644 index 000000000..d7ad5438d Binary files /dev/null and b/_graphics/flags/bg.png differ diff --git a/_graphics/flags/ca.png b/_graphics/flags/ca.png new file mode 100644 index 000000000..772361d98 Binary files /dev/null and b/_graphics/flags/ca.png differ diff --git a/_graphics/flags/cs.png b/_graphics/flags/cs.png new file mode 100644 index 000000000..15bc88d79 Binary files /dev/null and b/_graphics/flags/cs.png differ diff --git a/_graphics/flags/da.png b/_graphics/flags/da.png new file mode 100644 index 000000000..1504e2131 Binary files /dev/null and b/_graphics/flags/da.png differ diff --git a/_graphics/flags/de.png b/_graphics/flags/de.png new file mode 100644 index 000000000..41fea2599 Binary files /dev/null and b/_graphics/flags/de.png differ diff --git a/_graphics/flags/el.png b/_graphics/flags/el.png new file mode 100644 index 000000000..64e2ebe78 Binary files /dev/null and b/_graphics/flags/el.png differ diff --git a/_graphics/flags/en.png b/_graphics/flags/en.png new file mode 100644 index 000000000..84b934ab7 Binary files /dev/null and b/_graphics/flags/en.png differ diff --git a/_graphics/flags/eo.png b/_graphics/flags/eo.png new file mode 100644 index 000000000..fde29543a Binary files /dev/null and b/_graphics/flags/eo.png differ diff --git a/_graphics/flags/es.png b/_graphics/flags/es.png new file mode 100644 index 000000000..bf2b5b834 Binary files /dev/null and b/_graphics/flags/es.png differ diff --git a/_graphics/flags/et.png b/_graphics/flags/et.png new file mode 100644 index 000000000..6f01c6a1d Binary files /dev/null and b/_graphics/flags/et.png differ diff --git a/_graphics/flags/eu.png b/_graphics/flags/eu.png new file mode 100644 index 000000000..a58d68295 Binary files /dev/null and b/_graphics/flags/eu.png differ diff --git a/_graphics/flags/fa.png b/_graphics/flags/fa.png new file mode 100644 index 000000000..69cebb7f2 Binary files /dev/null and b/_graphics/flags/fa.png differ diff --git a/_graphics/flags/fi.png b/_graphics/flags/fi.png new file mode 100644 index 000000000..253fd4779 Binary files /dev/null and b/_graphics/flags/fi.png differ diff --git a/_graphics/flags/fo.png b/_graphics/flags/fo.png new file mode 100644 index 000000000..cc8439c33 Binary files /dev/null and b/_graphics/flags/fo.png differ diff --git a/_graphics/flags/fr.png b/_graphics/flags/fr.png new file mode 100644 index 000000000..58be00ac2 Binary files /dev/null and b/_graphics/flags/fr.png differ diff --git a/_graphics/flags/ga.png b/_graphics/flags/ga.png new file mode 100644 index 000000000..ab14e96cf Binary files /dev/null and b/_graphics/flags/ga.png differ diff --git a/_graphics/flags/gl.png b/_graphics/flags/gl.png new file mode 100644 index 000000000..84a1802dd Binary files /dev/null and b/_graphics/flags/gl.png differ diff --git a/_graphics/flags/he.png b/_graphics/flags/he.png new file mode 100644 index 000000000..e32439c4f Binary files /dev/null and b/_graphics/flags/he.png differ diff --git a/_graphics/flags/hi.png b/_graphics/flags/hi.png new file mode 100644 index 000000000..d75f5597c Binary files /dev/null and b/_graphics/flags/hi.png differ diff --git a/_graphics/flags/hr.png b/_graphics/flags/hr.png new file mode 100644 index 000000000..24fa77a23 Binary files /dev/null and b/_graphics/flags/hr.png differ diff --git a/_graphics/flags/hu.png b/_graphics/flags/hu.png new file mode 100644 index 000000000..d967480de Binary files /dev/null and b/_graphics/flags/hu.png differ diff --git a/_graphics/flags/id.png b/_graphics/flags/id.png new file mode 100644 index 000000000..6bf9bfec9 Binary files /dev/null and b/_graphics/flags/id.png differ diff --git a/_graphics/flags/is.png b/_graphics/flags/is.png new file mode 100644 index 000000000..398745745 Binary files /dev/null and b/_graphics/flags/is.png differ diff --git a/_graphics/flags/it.png b/_graphics/flags/it.png new file mode 100644 index 000000000..7131202d2 Binary files /dev/null and b/_graphics/flags/it.png differ diff --git a/_graphics/flags/ja.png b/_graphics/flags/ja.png new file mode 100644 index 000000000..8eabe66e6 Binary files /dev/null and b/_graphics/flags/ja.png differ diff --git a/_graphics/flags/km.png b/_graphics/flags/km.png new file mode 100644 index 000000000..af103289c Binary files /dev/null and b/_graphics/flags/km.png differ diff --git a/_graphics/flags/ko.png b/_graphics/flags/ko.png new file mode 100644 index 000000000..10a73bd36 Binary files /dev/null and b/_graphics/flags/ko.png differ diff --git a/_graphics/flags/lb.png b/_graphics/flags/lb.png new file mode 100644 index 000000000..6e596bbaf Binary files /dev/null and b/_graphics/flags/lb.png differ diff --git a/_graphics/flags/lt.png b/_graphics/flags/lt.png new file mode 100644 index 000000000..a1bdc47d7 Binary files /dev/null and b/_graphics/flags/lt.png differ diff --git a/_graphics/flags/lv.png b/_graphics/flags/lv.png new file mode 100644 index 000000000..f8adb5d9e Binary files /dev/null and b/_graphics/flags/lv.png differ diff --git a/_graphics/flags/mn.png b/_graphics/flags/mn.png new file mode 100644 index 000000000..355b43dae Binary files /dev/null and b/_graphics/flags/mn.png differ diff --git a/_graphics/flags/nb.png b/_graphics/flags/nb.png new file mode 100644 index 000000000..90335988c Binary files /dev/null and b/_graphics/flags/nb.png differ diff --git a/_graphics/flags/nl.png b/_graphics/flags/nl.png new file mode 100644 index 000000000..ad752ce06 Binary files /dev/null and b/_graphics/flags/nl.png differ diff --git a/_graphics/flags/nn.png b/_graphics/flags/nn.png new file mode 100644 index 000000000..90335988c Binary files /dev/null and b/_graphics/flags/nn.png differ diff --git a/_graphics/flags/pl.png b/_graphics/flags/pl.png new file mode 100644 index 000000000..1a0988b95 Binary files /dev/null and b/_graphics/flags/pl.png differ diff --git a/_graphics/flags/pt-br.png b/_graphics/flags/pt-br.png new file mode 100644 index 000000000..22a8df785 Binary files /dev/null and b/_graphics/flags/pt-br.png differ diff --git a/_graphics/flags/pt-pt.png b/_graphics/flags/pt-pt.png new file mode 100644 index 000000000..66d5bd706 Binary files /dev/null and b/_graphics/flags/pt-pt.png differ diff --git a/_graphics/flags/ro.png b/_graphics/flags/ro.png new file mode 100644 index 000000000..a5be3be42 Binary files /dev/null and b/_graphics/flags/ro.png differ diff --git a/_graphics/flags/ru.png b/_graphics/flags/ru.png new file mode 100644 index 000000000..97c436d0c Binary files /dev/null and b/_graphics/flags/ru.png differ diff --git a/_graphics/flags/sco.png b/_graphics/flags/sco.png new file mode 100644 index 000000000..d3bd37a2f Binary files /dev/null and b/_graphics/flags/sco.png differ diff --git a/_graphics/flags/se.png b/_graphics/flags/se.png new file mode 100644 index 000000000..0d73a7014 Binary files /dev/null and b/_graphics/flags/se.png differ diff --git a/_graphics/flags/sk.png b/_graphics/flags/sk.png new file mode 100644 index 000000000..5d303f762 Binary files /dev/null and b/_graphics/flags/sk.png differ diff --git a/_graphics/flags/sl.png b/_graphics/flags/sl.png new file mode 100644 index 000000000..356442f4b Binary files /dev/null and b/_graphics/flags/sl.png differ diff --git a/_graphics/flags/sq.png b/_graphics/flags/sq.png new file mode 100644 index 000000000..3244bbd14 Binary files /dev/null and b/_graphics/flags/sq.png differ diff --git a/_graphics/flags/sr.png b/_graphics/flags/sr.png new file mode 100644 index 000000000..bca54f1f7 Binary files /dev/null and b/_graphics/flags/sr.png differ diff --git a/_graphics/flags/sv.png b/_graphics/flags/sv.png new file mode 100644 index 000000000..bb27ed13d Binary files /dev/null and b/_graphics/flags/sv.png differ diff --git a/_graphics/flags/tg.png b/_graphics/flags/tg.png new file mode 100644 index 000000000..9a377f4ff Binary files /dev/null and b/_graphics/flags/tg.png differ diff --git a/_graphics/flags/th.png b/_graphics/flags/th.png new file mode 100644 index 000000000..9e9abd29a Binary files /dev/null and b/_graphics/flags/th.png differ diff --git a/_graphics/flags/tl.png b/_graphics/flags/tl.png new file mode 100644 index 000000000..ffd461ddf Binary files /dev/null and b/_graphics/flags/tl.png differ diff --git a/_graphics/flags/tr.png b/_graphics/flags/tr.png new file mode 100644 index 000000000..60287a43e Binary files /dev/null and b/_graphics/flags/tr.png differ diff --git a/_graphics/flags/uk.png b/_graphics/flags/uk.png new file mode 100644 index 000000000..485b5d0f2 Binary files /dev/null and b/_graphics/flags/uk.png differ diff --git a/_graphics/flags/vi.png b/_graphics/flags/vi.png new file mode 100644 index 000000000..2adcc2085 Binary files /dev/null and b/_graphics/flags/vi.png differ diff --git a/_graphics/flags/zh-hans.png b/_graphics/flags/zh-hans.png new file mode 100644 index 000000000..36650640f Binary files /dev/null and b/_graphics/flags/zh-hans.png differ diff --git a/_graphics/flags/zh-hant.png b/_graphics/flags/zh-hant.png new file mode 100644 index 000000000..9c75444a5 Binary files /dev/null and b/_graphics/flags/zh-hant.png differ diff --git a/_graphics/key.gif b/_graphics/key.gif new file mode 100644 index 000000000..30a1d4a27 Binary files /dev/null and b/_graphics/key.gif differ diff --git a/actions/add_custom_key.php b/actions/add_custom_key.php new file mode 100644 index 000000000..47269dfd2 --- /dev/null +++ b/actions/add_custom_key.php @@ -0,0 +1,64 @@ +translations["en"])){ + $exists = true; + } + + if(!$exists){ + // save + + $custom_translations = array(); + + if($custom_translations = translation_editor_get_plugin("en", "custom_keys")){ + $custom_translations = $custom_translations["en"]; + } + + $custom_translations[$key] = $translation; + + $base_dir = elgg_get_data_path() . "translation_editor" . DIRECTORY_SEPARATOR; + if(!file_exists($base_dir)){ + mkdir($base_dir); + } + + $location = $base_dir . "custom_keys" . DIRECTORY_SEPARATOR; + if(!file_exists($location)){ + mkdir($location); + } + + $file_contents = ""; + + if(file_put_contents($location . "en.php", $file_contents)){ + + system_message(elgg_echo("translation_editor:action:add_custom_key:success")); + } else { + register_error(elgg_echo("translation_editor:action:add_custom_key:file_error")); + } + } else { + register_error(elgg_echo("translation_editor:action:add_custom_key:exists")); + } + } else { + register_error(elgg_echo("translation_editor:action:add_custom_key:invalid_chars")); + } + } else { + register_error(elgg_echo("translation_editor:action:add_custom_key:key_numeric")); + } + } else { + register_error(elgg_echo("translation_editor:action:add_custom_key:missing_input")); + } + + forward(REFERER); \ No newline at end of file diff --git a/actions/add_language.php b/actions/add_language.php new file mode 100644 index 000000000..4b324bee6 --- /dev/null +++ b/actions/add_language.php @@ -0,0 +1,19 @@ +guid, $role, true, "integer", $user->guid, ACCESS_PUBLIC)){ + $result = true; + } + } + + if(!$result){ + register_error(elgg_echo("translation_editor:action:make_translation_editor:error")); + } else { + system_message(elgg_echo("translation_editor:action:make_translation_editor:success")); + } + + forward(REFERER); \ No newline at end of file diff --git a/actions/merge.php b/actions/merge.php new file mode 100644 index 000000000..db1e75276 --- /dev/null +++ b/actions/merge.php @@ -0,0 +1,29 @@ +allowedprotocols[] = "javascript"; + + // fix allowed tags + $CONFIG->allowedtags["a"]["onclick"] = array(); + $CONFIG->allowedtags["span"]["id"] = array(); + + // get inputs + $current_language = get_input("current_language"); + $translate_input = get_input("translation"); + $plugin = get_input("plugin"); + $jquery = get_input("jquery", false); + + // Preparing jQuery result + $json_result = array(); + $json_result["result"] = false; + + if(translation_editor_is_translation_editor()){ + if(!empty($current_language) && !empty($translate_input) && !empty($plugin)){ + $translated = translation_editor_compare_translations($current_language, $translate_input); + + if(!empty($translated)){ + if(translation_editor_write_translation($current_language, $plugin, $translated)){ + if(!$jquery){ + system_message(elgg_echo("translation_editor:action:translate:success")); + } else { + $json_result["result"] = true; + } + } else { + if(!$jquery){ + register_error(elgg_echo("translation_editor:action:translate:error:write")); + } + } + } else { + translation_editor_delete_translation($current_language, $plugin); + if(!$jquery){ + system_message(elgg_echo("translation_editor:action:translate:no_changed_values")); + } else { + $json_result["result"] = true; + } + } + + // merge translations + translation_editor_merge_translations($current_language, true); + } else { + if(!$jquery){ + register_error(elgg_echo("translation_editor:action:translate:error:input")); + } + } + } else { + if(!$jquery){ + register_error(elgg_echo("translation_editor:action:translate:error:not_authorized")); + } + } + + if(!$jquery){ + forward(REFERER); + } else { + // Send JSON data + $json_string = json_encode($json_result); + + header("Content-Type: application/json; charset=UTF-8"); + header("Content-Length: " . strlen($json_string)); + header("Cache-Control: no-cache"); + header("Pragma: no-cache"); + + echo $json_string; + exit(); + } diff --git a/actions/translate_search.php b/actions/translate_search.php new file mode 100644 index 000000000..623828b39 --- /dev/null +++ b/actions/translate_search.php @@ -0,0 +1,84 @@ +allowedprotocols[] = "javascript"; + + // fix allowed tags + $CONFIG->allowedtags["a"]["onclick"] = array(); + $CONFIG->allowedtags["span"]["id"] = array(); + + // get inputs + $current_language = get_input("current_language"); + $translation = get_input("translation"); + $jquery = get_input("jquery", false); + + // Preparing jQuery result + $json_result = array(); + $json_result["result"] = false; + + if(translation_editor_is_translation_editor()){ + $trans = get_installed_translations(); + + if(!empty($current_language) && !empty($translation) && array_key_exists($current_language, $trans)){ + foreach($translation as $plugin => $translate_input){ + // merge with existing custom translations + if($custom_translation = translation_editor_read_translation($current_language, $plugin)){ + $translate_input = array_merge($custom_translation, $translate_input); + } + + $translated = translation_editor_compare_translations($current_language, $translate_input); + + if(!empty($translated)){ + if(translation_editor_write_translation($current_language, $plugin, $translated)){ + if(!$jquery){ + system_message(elgg_echo("translation_editor:action:translate:success")); + } else { + $json_result["result"] = true; + } + } else { + if(!$jquery){ + register_error(elgg_echo("translation_editor:action:translate:error:write")); + } + } + } else { + translation_editor_delete_translation($current_language, $plugin); + if(!$jquery){ + system_message(elgg_echo("translation_editor:action:translate:no_changed_values")); + } else { + $json_result["result"] = true; + } + } + } + + // merge translations + translation_editor_merge_translations($current_language, true); + } else { + if(!$jquery){ + register_error(elgg_echo("translation_editor:action:translate:error:input")); + } + } + } else { + if(!$jquery){ + register_error(elgg_echo("translation_editor:action:translate:error:not_authorized")); + } + } + + if(!$jquery){ + forward(REFERER); + } else { + // Send JSON data + $json_string = json_encode($json_result); + + header("Content-Type: application/json; charset=UTF-8"); + header("Content-Length: " . strlen($json_string)); + header("Cache-Control: no-cache"); + header("Pragma: no-cache"); + + echo $json_string; + exit(); + } diff --git a/actions/unmake_translation_editor.php b/actions/unmake_translation_editor.php new file mode 100644 index 000000000..1872d7f6c --- /dev/null +++ b/actions/unmake_translation_editor.php @@ -0,0 +1,20 @@ +translation_editor); + $result = true; + } + + if(!$result){ + register_error(elgg_echo("translation_editor:action:unmake_translation_editor:error")); + } else { + system_message(elgg_echo("translation_editor:action:unmake_translation_editor:success")); + } + forward(REFERER); diff --git a/languages/ca.php b/languages/ca.php new file mode 100644 index 000000000..80ac88a17 --- /dev/null +++ b/languages/ca.php @@ -0,0 +1,57 @@ + 'Idioma', + 'translation_editor:disabled' => 'Desactivar', + 'translation_editor:menu:title' => 'Editor de traduccions', + 'translation_editor:language_selector:title' => 'Selecciona l\'idioma que vols editar', + 'translation_editor:language_selector:add_language' => 'Afegir un nou idioma', + 'translation_editor:language_selector:remove_language:confirm' => 'Estàs segur de voler esborrar aquest idioma? Pots afegir-lo de nou igualment!', + 'translation_editor:language_selector:site_language' => 'Idioma del lloc', + 'translation_editor:plugin_list:title' => 'Selecciona un component a traduïr', + 'translation_editor:plugin_list:plugin' => 'Nom de l\'extensió', + 'translation_editor:plugin_list:total' => 'Claus totals', + 'translation_editor:plugin_list:exists' => 'Traduïdes', + 'translation_editor:plugin_list:custom' => 'Pròpies', + 'translation_editor:plugin_list:percentage' => 'Percentatge completat', + 'translation_editor:plugin_list:merge' => 'Fusionar a l\'arxiu PHP d\'idiomes', + 'translation_editor:plugin_list:delete' => 'Esborrar traducció', + 'translation_editor:plugin_list:delete:confirm' => 'Estàs segur de voler esborrar la traducció? Això no es pot desfer!', + 'translation_editor:search' => 'Resultats de la cerca', + 'translation_editor:forms:search:default' => 'Cercar una traducció', + 'translation_editor:search_results:no_results' => 'No s\'ha trobat cap traducció', + 'translation_editor:custom_keys:title' => 'Afegir una clau d\'idioma pròpia', + 'translation_editor:custom_keys:key' => 'Clau', + 'translation_editor:custom_keys:translation' => 'Traducció', + 'translation_editor:custom_keys:translation_info' => 'Noves claus s\'han de crear sempre com a traducció anglesa. Després de crear-la pots traduïr-la a altres idiomes', + 'translation_editor:plugin_edit:title' => 'Editar les traduccions per a l\'extensió:', + 'translation_editor:plugin_edit:show' => 'mostra', + 'translation_editor:plugin_edit:show:missing' => 'falta', + 'translation_editor:plugin_edit:show:equal' => 'igual', + 'translation_editor:plugin_edit:show:all' => 'totes', + 'translation_editor:plugin_edit:show:custom' => 'pròpies', + 'translation_editor:plugin_edit:show:params' => 'falten params', + 'translation_editor:action:translate:error:input' => 'Entrada incorrecta a l\'intentar afegir una traducció', + 'translation_editor:action:translate:no_changed_values' => 'No es necessita afegir cap traducció', + 'translation_editor:action:translate:error:write' => 'Error escrivint les traduccions', + 'translation_editor:action:translate:error:not_authorized' => 'No estàs autoritzada a traduïr', + 'translation_editor:action:translate:success' => 'Traduccions desades correctament', + 'translation_editor:action:make_translation_editor' => 'Fer-se Traductora', + 'translation_editor:action:make_translation_editor:success' => 'Feta traductora correctament', + 'translation_editor:action:make_translation_editor:error' => 'Error en fer a la usuària traductora', + 'translation_editor:action:unmake_translation_editor' => 'Desfer-se Traductora', + 'translation_editor:action:unmake_translation_editor:success' => 'Traductora eliminada correctament', + 'translation_editor:action:unmake_translation_editor:error' => 'Error en desfer a la usuària traductora', + 'translation_editor:action:delete:error:input' => 'Entrada incorrecta per esborrar traducció', + 'translation_editor:action:delete:error:delete' => 'Error en esborrar traducció', + 'translation_editor:action:delete:success' => 'Traducció esborrada correctament', + 'translation_editor:action:add_language:success' => 'Idioma afegit correctament', + 'translation_editor:action:delete_language:success' => 'Idioma esborrat correctament', + 'translation_editor:action:add_custom_key:success' => 'Clau pròpia afegida correctament', + 'translation_editor:action:add_custom_key:file_error' => 'Error en desar la clau pròpia a l\'arxiu', + 'translation_editor:action:add_custom_key:exists' => 'No es pot afegir aquesta clau ja que ja existeix. Introdueix una clau única', + 'translation_editor:action:add_custom_key:invalid_chars' => 'La clau conté caràcters invàlids. Només a-z 0-9, dos punts o guions són permesos.', + 'translation_editor:action:add_custom_key:key_numeric' => 'La clau no pot contenir només números', + 'translation_editor:action:add_custom_key:missing_input' => 'Entrada invàlida. Si us plau entra una clau i un idioma per defecte (anglès)', + 'translation_editor:settings:everybody_translate' => 'Totes les traduccions', +); +add_translation("ca", $language); \ No newline at end of file diff --git a/languages/de.php b/languages/de.php new file mode 100644 index 000000000..d7d6b80f4 --- /dev/null +++ b/languages/de.php @@ -0,0 +1,56 @@ + 'Sprache', + 'translation_editor:disabled' => 'Ausschalten', + 'translation_editor:menu:title' => 'Übersetzungseditor', + 'translation_editor:language_selector:title' => 'Wähle die Sprache, die du bearbeiten möchtest', + 'translation_editor:language_selector:add_language' => 'Füge eine neue Sprache hinzu', + 'translation_editor:language_selector:remove_language:confirm' => 'Bist du sicher, dass du die Sprache löschen möchtest? Du kannst sie jederzeit wieder hinzufügen.', + 'translation_editor:language_selector:site_language' => 'Sprache der Community', + 'translation_editor:plugin_list:title' => 'Wähle eine Komponente für zur Übersetzung', + 'translation_editor:plugin_list:plugin' => 'Pluginname', + 'translation_editor:plugin_list:total' => 'Gesamteinträge', + 'translation_editor:plugin_list:exists' => 'Übersetzt', + 'translation_editor:plugin_list:custom' => 'Selbst erstellt', + 'translation_editor:plugin_list:percentage' => '% Komplett', + 'translation_editor:plugin_list:merge' => 'Kombiniere zu einer PHP-Datei', + 'translation_editor:plugin_list:delete' => 'Lösche Übersetzung', + 'translation_editor:plugin_list:delete:confirm' => 'Möchtest du wirklich diese Übersetzung löschen? Das kann nicht rückgängig gemacht werden!', + 'translation_editor:search' => 'Suchergebnis', + 'translation_editor:forms:search:default' => 'Finde eine Übersetzung', + 'translation_editor:search_results:no_results' => 'Kein Übersetzung gefunden', + 'translation_editor:custom_keys:title' => 'Füge neuen Sprachschlüssel hinzu', + 'translation_editor:custom_keys:key' => 'Schlüssel', + 'translation_editor:custom_keys:translation' => 'Übersetzung', + 'translation_editor:custom_keys:translation_info' => 'Neue Schlüssel werden immer als englische Übersetzung erstellt. Danach kannst du sie in andere Sprachen übersetzen.', + 'translation_editor:plugin_edit:title' => 'Bearbeite die Übersetzung für das Plugin:', + 'translation_editor:plugin_edit:show' => 'zeige', + 'translation_editor:plugin_edit:show:missing' => 'zu tun', + 'translation_editor:plugin_edit:show:equal' => 'identisch', + 'translation_editor:plugin_edit:show:all' => 'alle', + 'translation_editor:plugin_edit:show:custom' => 'übersetzt', + 'translation_editor:plugin_edit:show:params' => 'fehlender Parameter', + 'translation_editor:action:translate:error:input' => 'Falsche Eingabe, um eine neue Übersetzung hinzuzufügen', + 'translation_editor:action:translate:no_changed_values' => 'Keine Übersetzung erforderlich.', + 'translation_editor:action:translate:error:write' => 'Fehler beim Speichern der Übersetzung', + 'translation_editor:action:translate:error:not_authorized' => 'Du bist nicht zum Übersetzen authorisiert', + 'translation_editor:action:translate:success' => 'Übersetzung erfolgreich gespeichert', + 'translation_editor:action:make_translation_editor' => 'Zum Übersetzer machen', + 'translation_editor:action:make_translation_editor:success' => 'Erfolgreich zum Übersetzer gemacht', + 'translation_editor:action:make_translation_editor:error' => 'Fehler beim Hinzufügen der Übersetzerrolle.', + 'translation_editor:action:unmake_translation_editor' => 'Übersetzerrolle entfernen', + 'translation_editor:action:unmake_translation_editor:success' => 'Erfolgreich Übersetzerrolle entfernt.', + 'translation_editor:action:unmake_translation_editor:error' => 'Fehler beim Entfernen der Übersetzerrolle.', + 'translation_editor:action:delete:error:input' => 'Falsche Eingabe, um eine Übersetzung zu löschen', + 'translation_editor:action:delete:error:delete' => 'Fehler beim Löschen der Übersetzung.', + 'translation_editor:action:delete:success' => 'Übersetzung erfolgreich gelöscht', + 'translation_editor:action:add_language:success' => 'Sprache erfolgreich hinzugefügt', + 'translation_editor:action:delete_language:success' => 'Sprache erfolgreich gelöscht', + 'translation_editor:action:add_custom_key:success' => 'Neuer Schlüssel erfolgreich hinzugefügt.', + 'translation_editor:action:add_custom_key:file_error' => 'Fehler beim Speichern des selbst erstellten Schlüssels in die Datei.', + 'translation_editor:action:add_custom_key:exists' => 'Kann einen existierenden Schlüssel nicht erstellen. Bitte gib einen eindeutigen Schlüssel ein.', + 'translation_editor:action:add_custom_key:invalid_chars' => 'Schlüssel enthält ungültige Zeichen. Nur a-z, 0-9, Doppelpunkt und Unterstrich sind erlaubt.', + 'translation_editor:action:add_custom_key:key_numeric' => 'Schlüssel darf nur Zahlen enthalten.', + 'translation_editor:action:add_custom_key:missing_input' => 'Falsche Eingabe. Bitte gib einen Schlüssel und eine englische Übersetzung ein.', +); +add_translation("de", $language); \ No newline at end of file diff --git a/languages/en.php b/languages/en.php new file mode 100644 index 000000000..8b358411b --- /dev/null +++ b/languages/en.php @@ -0,0 +1,83 @@ + "Translation Editor", + + // global + 'translation_editor:language' => "Language", + 'translation_editor:disabled' => "Disable", + + // menu + 'translation_editor:menu:title' => "Translation Editor", + + // views + // language selector + 'translation_editor:language_selector:title' => "Select the language you wish to edit", + 'translation_editor:language_selector:add_language' => "Add a new language", + 'translation_editor:language_selector:remove_language:confirm' => "Are you sure you wish to remove this language? You can always add it again!", + 'translation_editor:language_selector:site_language' => "Site language", + + // plugins list + 'translation_editor:plugin_list:title' => "Select a component to translate", + 'translation_editor:plugin_list:plugin' => "Plugin name", + 'translation_editor:plugin_list:total' => "Total keys", + 'translation_editor:plugin_list:exists' => "Translated", + 'translation_editor:plugin_list:custom' => "Custom", + 'translation_editor:plugin_list:percentage' => "Percentage complete", + + 'translation_editor:plugin_list:merge' => "Merge to PHP language file", + 'translation_editor:plugin_list:delete' => "Delete translation", + 'translation_editor:plugin_list:delete:confirm' => "Are you sure you wish to delete the translation? This cannot be undone!", + + // search + 'translation_editor:search' => "Search results", + 'translation_editor:forms:search:default' => "Find a translation", + 'translation_editor:search_results:no_results' => "No translation found", + + // custom key + 'translation_editor:custom_keys:title' => "Add a custom language key", + 'translation_editor:custom_keys:key' => "Key", + 'translation_editor:custom_keys:translation' => "Translation", + 'translation_editor:custom_keys:translation_info' => "New keys will always be created as an English translation. After creation you can translate it to other languages.", + + 'translation_editor:plugin_edit:title' => "Edit the translations for plugin:", + 'translation_editor:plugin_edit:show' => "show", + 'translation_editor:plugin_edit:show:missing' => "missing", + 'translation_editor:plugin_edit:show:equal' => "equal", + 'translation_editor:plugin_edit:show:all' => "all", + 'translation_editor:plugin_edit:show:custom' => "custom", + 'translation_editor:plugin_edit:show:params' => "missing params", + + // actions + 'translation_editor:action:translate:error:input' => "Incorrect input provided to add a translation", + 'translation_editor:action:translate:no_changed_values' => "No translations needed to be added", + 'translation_editor:action:translate:error:write' => "Error while writing the translations", + 'translation_editor:action:translate:error:not_authorized' => "You are not authorized to translate", + 'translation_editor:action:translate:success' => "Translations saved successfully", + + 'translation_editor:action:make_translation_editor' => "Make Translator", + 'translation_editor:action:make_translation_editor:success' => "Succesfully made a translator", + 'translation_editor:action:make_translation_editor:error' => "Error while making the user a translator", + 'translation_editor:action:unmake_translation_editor' => "UnMake Translator", + 'translation_editor:action:unmake_translation_editor:success' => "Succesfully removed translator", + 'translation_editor:action:unmake_translation_editor:error' => "Error while removing the translator role", + + 'translation_editor:action:delete:error:input' => "Incorrect input to delete translation", + 'translation_editor:action:delete:error:delete' => "Error while deleting translation", + 'translation_editor:action:delete:success' => "Translation successfully deleted", + + 'translation_editor:action:add_language:success' => "Language successfully added", + 'translation_editor:action:delete_language:success' => "Language successfully removed", + + 'translation_editor:action:add_custom_key:success' => "Custom key successfully added", + 'translation_editor:action:add_custom_key:file_error' => "Error when saving the custom key to the file", + 'translation_editor:action:add_custom_key:exists' => "Can't add this key as it already exists. Enter a unique key.", + 'translation_editor:action:add_custom_key:invalid_chars' => "Key contains invalid characters. Only a-z, 0-9, colon or underscore are allowed.", + 'translation_editor:action:add_custom_key:key_numeric' => "Key can not contain only numbers", + 'translation_editor:action:add_custom_key:missing_input' => "Invalid input. Please enter a key and a default (English) translation.", + + // settings + 'translation_editor:settings:everybody_translate' => "Everybody translate", + ); + + add_translation("en", $english); diff --git a/languages/es.php b/languages/es.php new file mode 100644 index 000000000..8c942e470 --- /dev/null +++ b/languages/es.php @@ -0,0 +1,59 @@ + 'Idioma', + 'translation_editor:disabled' => 'Deshabilita', + 'translation_editor:menu:title' => 'Editor de traducción', + 'translation_editor:language_selector:title' => 'Selecciona el idioma que quieres editar', + 'translation_editor:language_selector:add_language' => 'Añade un nuevo idioma', + 'translation_editor:language_selector:remove_language:confirm' => '¿Estás seguro que quieres eliminar este idioma? ¡Puedes volver a añadirlo luego!', + 'translation_editor:language_selector:site_language' => 'Idioma del sitio', + 'translation_editor:plugin_list:title' => 'Selecciona un componente a traducir', + 'translation_editor:plugin_list:plugin' => 'Nombre de la extensión', + 'translation_editor:plugin_list:total' => 'Claves totales', + 'translation_editor:plugin_list:exists' => 'Traducido', + 'translation_editor:plugin_list:custom' => 'Personalizado', + 'translation_editor:plugin_list:percentage' => 'Porcentaje completado', + 'translation_editor:plugin_list:merge' => 'Mezcla en un fichero de idioma PHP', + 'translation_editor:plugin_list:delete' => 'Elimina traducción', + 'translation_editor:plugin_list:delete:confirm' => '¿Estás seguro de que quieres eliminar la traducción? ¡Esto no se puede deshacer!', + 'translation_editor:search' => 'Resultados de la búsqueda', + 'translation_editor:forms:search:default' => 'Encuentra una traducción', + 'translation_editor:search_results:no_results' => 'No se ha encontrado la traducción', + 'translation_editor:custom_keys:title' => 'Añade una clave de lenguage personalizada', + 'translation_editor:custom_keys:key' => 'Clave', + 'translation_editor:custom_keys:translation' => 'Traducción', + 'translation_editor:custom_keys:translation_info' => 'Se crearán nuevas claves con la traducción inglesa. Después de crearse puedes traducirlas a otros idiomas.', + 'translation_editor:plugin_edit:title' => 'Edita las traducciones para la extensión:', + 'translation_editor:plugin_edit:show' => 'muestra', + 'translation_editor:plugin_edit:show:missing' => 'falta', + 'translation_editor:plugin_edit:show:equal' => 'igual', + 'translation_editor:plugin_edit:show:all' => 'todo', + 'translation_editor:plugin_edit:show:custom' => 'personalizado', + 'translation_editor:plugin_edit:show:params' => 'faltan parámetros', + 'translation_editor:action:translate:error:input' => 'Entrada inválida para añadir una traducción', + 'translation_editor:action:translate:no_changed_values' => 'No es necesario añadir nuevas traducciones', + 'translation_editor:action:translate:error:write' => 'Error mientras se escribían las traducciones', + 'translation_editor:action:translate:error:not_authorized' => 'No estás autorizado a traducir', + 'translation_editor:action:translate:success' => 'Las traducciones se han guardado satisfactoriamente', + 'translation_editor:action:make_translation_editor' => 'Dar permisos de traducción', + 'translation_editor:action:make_translation_editor:success' => 'Ahora es traductor', + 'translation_editor:action:make_translation_editor:error' => 'Error mientras se daban permisos de traducción', + 'translation_editor:action:unmake_translation_editor' => 'Quitar permisos de traducción', + 'translation_editor:action:unmake_translation_editor:success' => 'Ya no es traductor', + 'translation_editor:action:unmake_translation_editor:error' => 'Error mientras se quitaban los permisos de traductor', + 'translation_editor:action:delete:error:input' => 'Entrada incorrecta al eliminar traducción', + 'translation_editor:action:delete:error:delete' => 'Error mientras se eliminaba la traducción', + 'translation_editor:action:delete:success' => 'Traducción eliminada correctamente', + 'translation_editor:action:add_language:success' => 'Idioma añadido satisfactoriamente', + 'translation_editor:action:delete_language:success' => 'Idioma eliminado satisfactoriamente', + 'translation_editor:action:add_custom_key:success' => 'Clave personalizada añadida satisfactoriamente', + 'translation_editor:action:add_custom_key:file_error' => 'Error mientras se guarda la clave personalizada en el fichero', + 'translation_editor:action:add_custom_key:exists' => 'No se puede añadir la clave porque ya existe. Entra una clave única.', + 'translation_editor:action:add_custom_key:invalid_chars' => 'La clave contiene caracteres inválidos. Sólo a-z, 0-9, dos puntos o barra baja son permitidos.', + 'translation_editor:action:add_custom_key:key_numeric' => 'La clave no puede contener sólo números', + 'translation_editor:action:add_custom_key:missing_input' => 'Entrada no válida. Por favor, entre una clave y una traducción por defecto (en inglés).', + 'translation_editor:settings:everybody_translate' => 'Todo el mundo traduce', +); + +add_translation("es", $es); + diff --git a/languages/fr.php b/languages/fr.php new file mode 100644 index 000000000..fda3c5237 --- /dev/null +++ b/languages/fr.php @@ -0,0 +1,80 @@ + "Translation Editor", + + // global + 'translation_editor:language' => 'Langage', + 'translation_editor:disabled' => 'Indisponible', + + // menu + 'translation_editor:menu:title' => 'Editeur de traduction', + + // views + // language selector + 'translation_editor:language_selector:title' => 'Sélectionner le langage que vous souhaitez édité', + 'translation_editor:language_selector:add_language' => 'Ajout d\'un nouveau langage', + 'translation_editor:language_selector:remove_language:confirm' => 'Etes-vous sûr de vouloir enlever ce langage ? Vous pouvez toujours l\'ajouter à nouveau !', + 'translation_editor:language_selector:site_language' => 'Langage du site', + + // plugins list + 'translation_editor:plugin_list:title' => 'Sélectionner un composant à traduire', + 'translation_editor:plugin_list:plugin' => 'Nom du plugin', + 'translation_editor:plugin_list:total' => 'Total des Clés', + 'translation_editor:plugin_list:exists' => 'Traduit', + 'translation_editor:plugin_list:custom' => 'Personnalisation', + 'translation_editor:plugin_list:percentage' => 'Pourcentage de complètement', + + 'translation_editor:plugin_list:merge' => 'Fusionner au fichier langage PHP', + 'translation_editor:plugin_list:delete' => 'Effacer une traduction', + 'translation_editor:plugin_list:delete:confirm' => 'Etes-vous sûr de vouloir effacer ce langage ? Vous ne pourrez pas revenir sur votre choix !', + + // search + 'translation_editor:search' => 'Cherche des résultats', + 'translation_editor:forms:search:default' => 'Trouver une traduction', + 'translation_editor:search_results:no_results' => 'Aucune traduction trouvé', + + // custom key + 'translation_editor:custom_keys:title' => 'Ajout d\'une clé langage personnalisé', + 'translation_editor:custom_keys:key' => 'Clé', + 'translation_editor:custom_keys:translation' => 'Traduction,', + 'translation_editor:custom_keys:translation_info' => 'Les nouvelles clés seront toujours créées tant que que traduction anglaise. Après la création vous pouvez les traduire dans un autre langage.', + + 'translation_editor:plugin_edit:title' => 'Editer la traduction pour le plugin', + 'translation_editor:plugin_edit:show' => 'Montrer', + 'translation_editor:plugin_edit:show:missing' => 'Manque', + 'translation_editor:plugin_edit:show:equal' => 'égal', + 'translation_editor:plugin_edit:show:all' => 'Tous', + 'translation_editor:plugin_edit:show:custom' => 'Personnalisé', + 'translation_editor:plugin_edit:show:params' => 'Paramètres manquant', + + // actions + 'translation_editor:action:translate:error:input' => 'Une entrée incorrecte revient à ajouter une traduction', + 'translation_editor:action:translate:no_changed_values' => 'Aucune traduction n\'a besoin d\'être ajouté', + 'translation_editor:action:translate:error:write' => 'Erreur pendant l\'écriture des traductions', + 'translation_editor:action:translate:error:not_authorized' => 'Vous n\'êtes pas autorisé à traduire', + 'translation_editor:action:translate:success' => 'Les traduction ont été sauvegardée avec succès', + + 'translation_editor:action:make_translation_editor' => 'Faire un fichier traduction', + 'translation_editor:action:make_translation_editor:success' => 'Fichier traduction fait avec succès', + 'translation_editor:action:make_translation_editor:error' => 'Erreur pendant la fabrication du fichier traduction de l\'utilisateur', + 'translation_editor:action:unmake_translation_editor' => 'Défaire le fichier traduction', + 'translation_editor:action:unmake_translation_editor:success' => 'Fichier traduction enlevé avec succès', + 'translation_editor:action:unmake_translation_editor:error' => 'Erreur pendant retirement du role du fichier de traduction', + + 'translation_editor:action:delete:error:input' => 'Entrée incorrecte pour effacer la traduction', + 'translation_editor:action:delete:error:delete' => 'Erreur durant l\'effacement de la traduction', + 'translation_editor:action:delete:success' => 'Traduction effacé avec succès', + + 'translation_editor:action:add_language:success' => 'Langage ajouté avec succès', + 'translation_editor:action:delete_language:success' => 'Langage enlevé avec succès', + + 'translation_editor:action:add_custom_key:success' => 'La clé personnalisé ajoutée avec succès', + 'translation_editor:action:add_custom_key:file_error' => 'Erreur lors de la sauvegarde de la clé personnalisé dans le fichier', + 'translation_editor:action:add_custom_key:exists' => 'Impossible d\'ajouter cet clé, car elle existe déjà. Entrer une clé unique.', + 'translation_editor:action:add_custom_key:invalid_chars' => 'Une clé contient des caractères invalides. Seuls les caractères a-z, 0-9 les virgules "," et souligné "_" sont admis.', + 'translation_editor:action:add_custom_key:key_numeric' => 'Une clé ne peut contenir que des chiffres', + 'translation_editor:action:add_custom_key:missing_input' => 'Entrée invalide. Merci d\'entrer une clé (anglaise) et une traduction par défault', +); +add_translation("fr", $language); +?> \ No newline at end of file diff --git a/languages/nl.php b/languages/nl.php new file mode 100644 index 000000000..114094dbe --- /dev/null +++ b/languages/nl.php @@ -0,0 +1,56 @@ + 'Taal', + 'translation_editor:disabled' => 'Uitschakelen', + 'translation_editor:search' => 'Zoekresultaten', + 'translation_editor:forms:search:default' => 'Zoek een vertaling', + 'translation_editor:search_results:no_results' => 'Geen vertalingen gevonden', + 'translation_editor:custom_keys:title' => 'Voeg een custom taal sleutel toe', + 'translation_editor:custom_keys:key' => 'Sleutel', + 'translation_editor:custom_keys:translation' => 'Vertaling', + 'translation_editor:custom_keys:translation_info' => 'Nieuwe sleutels zullen altijd aangemaakt worden als een Engelse taalsleutel. Nadat deze is aangemaakt kan het in andere talen worden vertaald.', + 'translation_editor:action:translate:error:input' => 'Onjuiste invoer voor het toevoegen van een vertaling', + 'translation_editor:action:translate:error:write' => 'Fout tijdens wegschrijven van vertalingen', + 'translation_editor:action:translate:error:not_authorized' => 'Je bent niet geautoriseerd als vertaler', + 'translation_editor:action:translate:success' => 'Vertalingen opgeslagen', + 'translation_editor:action:make_translation_editor:success' => 'Vertaler toegevoegd', + 'translation_editor:action:unmake_translation_editor' => 'Verwijder vertaler', + 'translation_editor:action:unmake_translation_editor:success' => 'Vertaler rol verwijderd', + 'translation_editor:action:add_custom_key:success' => 'Custom sleutel toegevoegd', + 'translation_editor:action:add_custom_key:file_error' => 'Fout tijdens wegschrijven van de custom sleutel', + 'translation_editor:action:add_custom_key:exists' => 'Deze sleutel bestaat al. Voer een unieke sleutel in.', + 'translation_editor:action:add_custom_key:invalid_chars' => 'De sleutel bevat ongeldige karakters. Alleen a-z, 0-9, dubbele punt of underscore zijn toegestaan.', + 'translation_editor:action:add_custom_key:key_numeric' => 'Sleutel mag niet uit enkel getallen bestaan', + 'translation_editor:action:add_custom_key:missing_input' => 'Ongeldige invoer. Voer een sleutel en een standaard (Engelse) vertaling in.', + 'translation_editor:plugin_list:delete' => 'Verwijder vertaling', + 'translation_editor:plugin_list:delete:confirm' => 'Weet je zeker dat je de vertaling wilt verwijderen? Dit kan niet ongedaan gemaakt worden!', + 'translation_editor:action:delete:error:input' => 'Onjuiste invoer om de vertaling te verwijderen', + 'translation_editor:action:delete:error:delete' => 'Fout tijden het verwijderen van de vertaling', + 'translation_editor:action:delete:success' => 'Vertaling succesvol verwijderd', + 'translation_editor:menu:title' => 'Vertaalmodule', + 'translation_editor:language_selector:title' => 'Selecteer de taal die je wilt bewerken', + 'translation_editor:language_selector:add_language' => 'Nieuwe taal toevoegen', + 'translation_editor:language_selector:remove_language:confirm' => 'Weet u zeker dat u deze taal wilt verwijderen? U kunt deze altijd later weer toevoegen!', + 'translation_editor:plugin_list:title' => 'Selecteer een component om te vertalen', + 'translation_editor:plugin_list:plugin' => 'Plugin naam', + 'translation_editor:plugin_list:total' => 'Totaal sleutels', + 'translation_editor:plugin_list:exists' => 'Vertaald', + 'translation_editor:plugin_list:custom' => 'Aangepast', + 'translation_editor:plugin_list:percentage' => 'Percentage compleet', + 'translation_editor:plugin_list:merge' => 'Samenvoegen in een PHP taal bestand', + 'translation_editor:plugin_edit:title' => 'Bewerkt de vertalingen voor de plugin:', + 'translation_editor:plugin_edit:show' => 'toon', + 'translation_editor:plugin_edit:show:missing' => 'ontbrekend', + 'translation_editor:plugin_edit:show:equal' => 'gelijk', + 'translation_editor:plugin_edit:show:all' => 'alle', + 'translation_editor:plugin_edit:show:custom' => 'aangepast', + 'translation_editor:plugin_edit:show:params' => 'ontbrekende variabele', + 'translation_editor:action:translate:no_changed_values' => 'het was niet nodig vertalingen toe te voegen', + 'translation_editor:action:make_translation_editor' => 'Maak vertaler', + 'translation_editor:action:make_translation_editor:error' => 'Fout tijdens het toewijzen van de vertaler', + 'translation_editor:action:unmake_translation_editor:error' => 'Fout tijdens het verwijderen van de vertaler rol', + 'translation_editor:action:add_language:success' => 'Taal succesvol toegevoegd', + 'translation_editor:action:delete_language:success' => 'Taal succesvol verwijderd', + 'translation_editor:language_selector:site_language' => 'Site taal', +); +add_translation("nl", $language); diff --git a/lib/events.php b/lib/events.php new file mode 100644 index 000000000..21492088c --- /dev/null +++ b/lib/events.php @@ -0,0 +1,9 @@ +translations; + $plugins = elgg_get_plugins(); + + // Core translation + $CONFIG->translations = array(); + $plugin_language = $CONFIG->path . "languages" . DIRECTORY_SEPARATOR . "en.php"; + + if(file_exists($plugin_language)){ + include($plugin_language); + + unset($CONFIG->translations["en"][""]); + + $plugin_keys = $CONFIG->translations["en"]; + + $key_count = count($plugin_keys); + + if(array_key_exists($current_language, $backup_full)){ + $exists_count = $key_count - count(array_diff_key($plugin_keys, $backup_full[$current_language])); + } else { + $exists_count = 0; + } + + if($custom_content = translation_editor_read_translation($current_language, "core")){ + $custom_count = count($custom_content); + } else { + $custom_count = 0; + } + + $core["core"]["total"] = $key_count; + $core["core"]["exists"] = $exists_count; + $core["core"]["custom"] = $custom_count; + } + + // Custom Keys + $CONFIG->translations = array(); + $custom_keys_original = $CONFIG->dataroot . "translation_editor" . DIRECTORY_SEPARATOR . "custom_keys" . DIRECTORY_SEPARATOR . "en.php"; + + if(file_exists($custom_keys_original)){ + include($custom_keys_original); + + unset($CONFIG->translations["en"][""]); + + $plugin_keys = $CONFIG->translations["en"]; + + $key_count = count($plugin_keys); + + if(array_key_exists($current_language, $backup_full)){ + $exists_count = $key_count - count(array_diff_key($plugin_keys, $backup_full[$current_language])); + } else { + $exists_count = 0; + } + + if($custom_content = translation_editor_read_translation($current_language, "custom_keys")){ + $custom_count = count($custom_content); + } else { + $custom_count = 0; + } + + $custom_keys["custom_keys"]["total"] = $key_count; + $custom_keys["custom_keys"]["exists"] = $exists_count; + $custom_keys["custom_keys"]["custom"] = $custom_count; + } else { + $custom_keys["custom_keys"]["total"] = 0; + $custom_keys["custom_keys"]["exists"] = 0; + $custom_keys["custom_keys"]["custom"] = 0; + } + + // Plugin translations + foreach($plugins as $plugin){ + + $title = $plugin->title; + + $CONFIG->translations = array(); + $plugin_language = $plugin->getPath() . DIRECTORY_SEPARATOR. "languages" . DIRECTORY_SEPARATOR . "en.php"; + + if(file_exists($plugin_language)){ + + include($plugin_language); + + unset($CONFIG->translations["en"][""]); + + $plugin_keys = $CONFIG->translations["en"]; + + $key_count = count($plugin_keys); + + if(array_key_exists($current_language, $backup_full)){ + $exists_count = $key_count - count(array_diff_key($plugin_keys, $backup_full[$current_language])); + } else { + $exists_count = 0; + } + + if($custom_content = translation_editor_read_translation($current_language, $title)){ + $custom_count = count($custom_content); + } else { + $custom_count = 0; + } + + $plugins_result[$title]["total"] = $key_count; + $plugins_result[$title]["exists"] = $exists_count; + $plugins_result[$title]["custom"] = $custom_count; + } + } + + ksort($plugins_result); + + $result = $core + $custom_keys + $plugins_result; + + $CONFIG->translations = $backup_full; + } + + return $result; + } + + /** + * Returns translation data for a specific plugin + * + * @param string $current_language + * @param string $plugin + * + * @return array || false + */ + function translation_editor_get_plugin($current_language, $plugin){ + global $CONFIG; + + $result = false; + + if(!empty($current_language) && !empty($plugin)){ + + translation_editor_reload_all_translations(); + translation_editor_load_translations($current_language); + + $result = array(); + $result["total"] = 0; + + $backup_full = $CONFIG->translations; + + $CONFIG->translations = array(); + $base_path = $CONFIG->path; + + if($plugin == "core"){ + // Core translation + $plugin_language = $base_path . "languages" . DIRECTORY_SEPARATOR . "en.php"; + } elseif($plugin == "custom_keys"){ + $plugin_language = $CONFIG->dataroot . "translation_editor" . DIRECTORY_SEPARATOR . "custom_keys" . DIRECTORY_SEPARATOR . "en.php"; + } else { + // Plugin translations + $plugin_language = $base_path . "mod" . DIRECTORY_SEPARATOR . $plugin . DIRECTORY_SEPARATOR. "languages" . DIRECTORY_SEPARATOR . "en.php"; + } + + // Fetch translations + if(file_exists($plugin_language)){ + include($plugin_language); + + unset($CONFIG->translations["en"][""]); + + $plugin_keys = $CONFIG->translations["en"]; + + $key_count = count($plugin_keys); + + if(array_key_exists($current_language, $backup_full)){ + $exists_count = $key_count - count(array_diff_key($plugin_keys, $backup_full[$current_language])); + } else { + $exists_count = 0; + } + + if($custom_content = translation_editor_read_translation($current_language, $plugin)){ + $custom = $custom_content; + } else { + $custom = array(); + } + + $result["total"] = $key_count; + $result["exists"] = $exists_count; + $result["en"] = $plugin_keys; + $result["current_language"] = array_intersect_key($backup_full[$current_language], $plugin_keys); + $result["custom"] = $custom; + } + + $CONFIG->translations = $backup_full; + } + + return $result; + } + + function translation_editor_compare_translations($current_language, $translated){ + global $CONFIG; + + $result = false; + + if(!empty($current_language) && !empty($translated)){ + $result = array(); + + $backup_full = $CONFIG->translations; + + $CONFIG->translations = array(); + translation_editor_reload_all_translations(); + + foreach($translated as $key => $value){ + $original = clean_line_breaks(trim(html_entity_decode($CONFIG->translations[$current_language][$key], ENT_NOQUOTES, "UTF-8"))); + $new = clean_line_breaks(trim(html_entity_decode($value, ENT_NOQUOTES, "UTF-8"))); + + if($original != $new && strlen($new) > 0){ + $result[$key] = $new; + } + } + + $CONFIG->translations = $backup_full; + } + + return $result; + } + + function clean_line_breaks($string){ + return preg_replace("/(\r\n)|(\n|\r)/", PHP_EOL, $string); + } + + + function translation_editor_write_translation($current_language, $plugin, $translation){ + global $CONFIG; + + $result = false; + + if(!empty($current_language) && !empty($plugin) && !empty($translation)){ + translation_editor_check_file_structure($current_language); + + $base_dir = $CONFIG->dataroot . "translation_editor" . DIRECTORY_SEPARATOR; + $contents = json_encode($translation); + + if($bytes = file_put_contents($base_dir . $current_language . DIRECTORY_SEPARATOR . $plugin . ".json", $contents)){ + $result = $bytes; + } + } + + return $result; + } + + function translation_editor_read_translation($current_language, $plugin){ + $result = false; + + if(!empty($current_language) && !empty($plugin)){ + $base_dir = elgg_get_data_path() . "translation_editor" . DIRECTORY_SEPARATOR; + + if(file_exists($base_dir . $current_language . DIRECTORY_SEPARATOR . $plugin . ".json")){ + if($contents = file_get_contents($base_dir . $current_language . DIRECTORY_SEPARATOR . $plugin . ".json")){ + $result = json_decode($contents, true); + } + + } + } + + return $result; + } + + function translation_editor_load_translations($current_language = ""){ + global $CONFIG; + + if(empty($current_language)){ + $current_language = get_current_language(); + } + + // check if update is needed + $main_ts = datalist_get("te_last_update_" . $current_language); + $site_ts = get_private_setting($CONFIG->site_guid, "te_last_update_" . $current_language); + + if(!empty($main_ts)){ + if(empty($site_ts) || ($main_ts > $site_ts)){ + if(translation_editor_merge_translations($current_language)){ + set_private_setting($CONFIG->site_guid, "te_last_update_" . $current_language, time()); + } + } + } else { + translation_editor_merge_translations($current_language, true); + } + + // load translations + if($translations = translation_editor_read_translation($current_language, "translation_editor_merged_" . $CONFIG->site_guid)){ + add_translation($current_language, $translations); + } + } + + function translation_editor_load_custom_languages(){ + if($custom_languages = elgg_get_plugin_setting("custom_languages", "translation_editor")){ + $custom_languages = explode(",", $custom_languages); + + foreach($custom_languages as $lang){ + add_translation($lang, array("" => "")); + } + } + } + + function translation_editor_reload_all_translations(){ + global $CONFIG; + + static $run_once; + + if(isset($run_once)){ + $CONFIG->translations = $run_once; + } else { + + foreach($CONFIG->language_paths as $path => $dummy){ + if($handle = opendir($path)){ + while($language = readdir($handle)){ + if(is_file($path . $language)){ + include($path . $language); + } + } + + closedir($handle); + } + } + + $run_once = $CONFIG->translations; + } + } + + function translation_editor_check_file_structure($current_language){ + $result = false; + + if(!empty($current_language)){ + $base_dir = elgg_get_data_path() . "translation_editor" . DIRECTORY_SEPARATOR; + if(!file_exists($base_dir)){ + mkdir($base_dir); + } + + if(!file_exists($base_dir . $current_language . DIRECTORY_SEPARATOR)){ + mkdir($base_dir . $current_language . DIRECTORY_SEPARATOR); + } + + $result = true; + } + + return $result; + } + + function translation_editor_delete_translation($current_language, $plugin){ + $result = false; + + if(!empty($current_language) && !empty($plugin)){ + $filename = elgg_get_data_path() . "translation_editor" . DIRECTORY_SEPARATOR . $current_language . DIRECTORY_SEPARATOR . $plugin . ".json"; + + if(file_exists($filename)){ + $result = unlink($filename); + } + } + + return $result; + } + + function translation_editor_get_language_completeness($current_language){ + $result = false; + + if(!empty($current_language) && $current_language != "en"){ + $plugins = translation_editor_get_plugins($current_language); + + $english_count = 0; + $current_count = 0; + + foreach($plugins as $plugin){ + $english_count += $plugin["total"]; + $current_count += $plugin["exists"]; + } + + $result = round(($current_count / $english_count) * 100, 2); + } + + return $result; + } + + function translation_editor_is_translation_editor($user_guid = 0){ + static $editors_cache; + + $result = false; + + if(empty($user_guid)){ + $user_guid = elgg_get_logged_in_user_guid(); + } + + if(!empty($user_guid)){ + // preload all editors + if(!isset($editors_cache)){ + $editors_cache = array(); + + $options = array( + "type" => "user", + "limit" => false, + "metadata_name_value_pairs" => array( + "name" => "translation_editor", + "value" => true + ), + "callback" => "translation_editor_guid_only" + ); + + if($guids = elgg_get_entities_from_metadata($options)){ + $editors_cache = $guids; + } + } + + // is the user an editor or an admin + if(in_array($user_guid, $editors_cache)){ + $result = true; + } elseif(($user = get_user($user_guid)) && $user->isAdmin()){ + $result = true; + } elseif (elgg_get_plugin_setting('everybody_translate', 'translation_editor') == 'yes') { + $result = true; + } + } + + return $result; + } + + function translation_editor_unregister_translations(){ + global $CONFIG; + + $result = false; + + if($disabled_languages = translation_editor_get_disabled_languages()){ + foreach($CONFIG->translations as $key => $dummy){ + if(in_array($key, $disabled_languages)){ + unset($CONFIG->translations[$key]); + } + } + + $result = true; + } + + return $result; + } + + function translation_editor_search_translation($query, $language = "en"){ + $result = false; + + $plugins = translation_editor_get_plugins($language); + $found = array(); + + foreach($plugins as $plugin => $data){ + if($translations = translation_editor_get_plugin($language, $plugin)){ + foreach($translations["en"] as $key => $value){ + if(stristr($key, $query) || stristr($value, $query) || (array_key_exists($key, $translations["current_language"]) && stristr($translations["current_language"][$key], $query))){ + if(!array_key_exists($plugin, $found)){ + $found[$plugin] = array( + "en" => array(), + "current_language" => array() + ); + } + + $found[$plugin]["en"][$key] = $value; + if(array_key_exists($key, $translations["current_language"])){ + $found[$plugin]["current_language"][$key] = $translations["current_language"][$key]; + } + } + } + + if(!empty($found)){ + $result = $found; + } + } + } + + return $result; + } + + function translation_editor_merge_translations($language = "", $update = false){ + global $CONFIG; + + $result = false; + + if(empty($language)){ + $language = get_current_language(); + } + + if(!empty($language)){ + $translations = array(); + + if($core = translation_editor_read_translation($language, "core")){ + $translations = $core; + } + + if($custom_keys = translation_editor_read_translation($language, "custom_keys")){ + $translations += $custom_keys; + } + + if($plugins = elgg_get_plugins()){ + foreach($plugins as $plugin){ + if($plugin_translation = translation_editor_read_translation($language, $plugin->title)){ + $translations += $plugin_translation; + } + } + } + + if(!empty($translations)){ + if(translation_editor_write_translation($language, "translation_editor_merged_" . $CONFIG->site_guid, $translations)){ + $result = true; + } + } else { + if(translation_editor_delete_translation($language, "translation_editor_merged_" . $CONFIG->site_guid)){ + $result = true; + } + } + } + + if($result){ + elgg_trigger_event("language:merge", "translation_editor", $language); + } + + // reset language cache on all sites + if($update){ + $ts = time(); + + datalist_set("te_last_update_" . $language, $ts); + set_private_setting($CONFIG->site_guid, "te_last_update_" . $language, $ts); + } + + return $result; + } + + /** + * parses a string meant for printf and returns an array of found parameters + * + * @param string $string + * @return array + */ + function translation_editor_get_string_parameters($string, $count = true) { + $valid = '/%[-+]?(?:[ 0]|\'.)?a?\d*(?:\.\d*)?[%bcdeEufFgGosxX]/'; + + $result = array(); + + if(!empty($string)){ + if(!$string = preg_replace('/^[^%]*/', '', $string)){ + // no results + } elseif(preg_match_all($valid, $string, $matches)) { + $result = $matches[0]; + } + } + + if($count){ + $result = count($result); + } + + return $result; + } + + function translation_editor_get_disabled_languages(){ + static $result; + + if(!isset($result)){ + $result = false; + + if($disabled_languages = elgg_get_plugin_setting(TRANSLATION_EDITOR_DISABLED_LANGUAGE, "translation_editor")){ + $result = string_to_tag_array($disabled_languages); + } + } + + return $result; + } + + function translation_editor_guid_only($row){ + return (int) $row->guid; + } diff --git a/lib/hooks.php b/lib/hooks.php new file mode 100644 index 000000000..486fb0b7a --- /dev/null +++ b/lib/hooks.php @@ -0,0 +1,45 @@ +isAdmin())){ + // TODO: replace with a single toggle editor action? + if(translation_editor_is_translation_editor($user->getGUID())){ + $url = "action/translation_editor/unmake_translation_editor?user=" . $user->getGUID(); + $title = elgg_echo("translation_editor:action:unmake_translation_editor"); + } else { + $url = "action/translation_editor/make_translation_editor?user=" . $user->getGUID(); + $title = elgg_echo("translation_editor:action:make_translation_editor"); + } + + $item = new ElggMenuItem('translation_editor', $title, $url); + $item->setSection('admin'); + $item->setConfirmText(elgg_echo("question:areyousure")); + $return[] = $item; + + return $return; + } + } + + function translation_editor_actions_hook($hook, $type, $return, $params){ + $allowed_actions = array( + "admin/plugins/activate", + "admin/plugins/deactivate", + "admin/plugins/activate_all", + "admin/plugins/deactivate_all", + "admin/plugins/set_priority", + "upgrading" // not actualy an action but comes from events.php + ); + + if(!empty($type) && in_array($type, $allowed_actions)){ + // make sure we have all translations + translation_editor_reload_all_translations(); + + if($languages = get_installed_translations()){ + foreach($languages as $key => $desc){ + remove_private_setting(elgg_get_site_entity()->getGUID(), "te_last_update_" . $key); + } + } + } + } \ No newline at end of file diff --git a/manifest.xml b/manifest.xml new file mode 100644 index 000000000..7e1952d8c --- /dev/null +++ b/manifest.xml @@ -0,0 +1,17 @@ + + + Translation Editor + ColdTrick IT Solutions + 1.2.1 + Translation Editor provides an easy way to edit translations. + http://www.coldtrick.com/ + (C) ColdTrick IT Solutions 2009 - 2011 + GNU Public License version 2 + + + elgg_version + 2011061200 + + + ColdTrick + \ No newline at end of file diff --git a/pages/index.php b/pages/index.php new file mode 100644 index 000000000..92280460a --- /dev/null +++ b/pages/index.php @@ -0,0 +1,64 @@ +translations); + + if(!($disabled_languages = translation_editor_get_disabled_languages())){ + $disabled_languages = array(); + } + + if(!empty($CONFIG->language)){ + $site_language = $CONFIG->language; + } else { + $site_language = "en"; + } + + $body .= elgg_view("translation_editor/language_selector", array("current_language" => $current_language, "plugin" => $plugin, "languages" => $languages, "disabled_languages" => $disabled_languages, "site_language" => $site_language)); + + if(empty($plugin)){ + // show plugin list + elgg_push_breadcrumb(elgg_echo($current_language)); + + $plugins = translation_editor_get_plugins($current_language); + + $body .= elgg_view("translation_editor/search", array("current_language" => $current_language, "query" => get_input("q"))); + $body .= elgg_view("translation_editor/plugin_list", array("plugins" => $plugins, "current_language" => $current_language)); + } else { + // show plugin keys + elgg_push_breadcrumb(elgg_echo($current_language), "translation_editor/" . $current_language); + elgg_push_breadcrumb($plugin); + + $translation = translation_editor_get_plugin($current_language, $plugin); + if($plugin == "custom_keys" && elgg_is_admin_logged_in()){ + $body .= elgg_view("translation_editor/add_custom_key"); + } + $body .= elgg_view("translation_editor/plugin_edit", array("plugin" => $plugin, "current_language" => $current_language, "translation" => $translation)); + } + + // Build page + $page_data = elgg_view_layout('one_column', array( + 'title' => $title_text, + 'content' => $body + )); + + echo elgg_view_page($title_text, $page_data); + \ No newline at end of file diff --git a/pages/search.php b/pages/search.php new file mode 100644 index 000000000..978b55704 --- /dev/null +++ b/pages/search.php @@ -0,0 +1,32 @@ + $language, "query" => $q)); + $body .= elgg_view("translation_editor/search_results", array("results" => $found, "current_language" => $language)); + + // Build page + $page_data = elgg_view_layout('one_column', array( + 'content' => "
" . $title . "
" . $body + )); + + echo elgg_view_page($title_text, $page_data); diff --git a/start.php b/start.php new file mode 100644 index 000000000..a85a214c8 --- /dev/null +++ b/start.php @@ -0,0 +1,139 @@ + "translation_editor", + 'href' => "translation_editor", + 'text' => elgg_echo("translation_editor:menu:title"), + 'context' => "admin", + 'parent_name' => "appearance", + 'section' => "configure" + )); + } + + elgg_register_plugin_hook_handler('register', 'menu:user_hover', 'translation_editor_user_hover_menu'); + + } + + function translation_editor_page_handler($page){ + + switch($page[0]){ + case "search": + $q = get_input("translation_editor_search"); + if(!empty($q)){ + include(dirname(__FILE__) . "/pages/search.php"); + break; + } + default: + if(!empty($page[0])){ + set_input("current_language", $page[0]); + if(!empty($page[1])){ + set_input("plugin", $page[1]); + } + + include(dirname(__FILE__) . "/pages/index.php"); + } else { + $current_language = get_current_language(); + forward("translation_editor/" . $current_language); + } + break; + } + + return true; + } + + function translation_editor_plugins_boot_event(){ + global $CONFIG; + + run_function_once("translation_editor_version_053"); + + // add the custom_keys_locations to language paths + $custom_keys_path = $CONFIG->dataroot . "translation_editor" . DIRECTORY_SEPARATOR . "custom_keys" . DIRECTORY_SEPARATOR; + if(is_dir($custom_keys_path)){ + $CONFIG->language_paths[$custom_keys_path] = true; + } + + // force creation of static to prevent reload of unwanted translations + reload_all_translations(); + + translation_editor_load_custom_languages(); + + if(elgg_get_context() != "translation_editor"){ + // remove disabled languages + translation_editor_unregister_translations(); + } + + // load custom translations + $user_language = get_current_language(); + $elgg_default_language = "en"; + + $load_languages = array($user_language, $elgg_default_language); + $load_languages = array_unique($load_languages); + + $disabled_languages = translation_editor_get_disabled_languages(); + + foreach($load_languages as $language){ + if(empty($disabled_languages) || !in_array($language, $disabled_languages)){ + // add custom translations + translation_editor_load_translations($language); + } + } + } + + function translation_editor_version_053(){ + if($languages = get_installed_translations()){ + foreach($languages as $lang => $name){ + translation_editor_merge_translations($lang); + } + } + } + + // Plugin init + elgg_register_event_handler('plugins_boot', 'system', 'translation_editor_plugins_boot_event', 50); // before normal execution to prevent conflicts with plugins like language_selector + elgg_register_event_handler('init', 'system', 'translation_editor_init'); + + // register hooks + elgg_register_plugin_hook_handler("action", "admin/plugins/activate", "translation_editor_actions_hook"); + elgg_register_plugin_hook_handler("action", "admin/plugins/deactivate", "translation_editor_actions_hook"); + elgg_register_plugin_hook_handler("action", "admin/plugins/activate_all", "translation_editor_actions_hook"); + elgg_register_plugin_hook_handler("action", "admin/plugins/deactivate_all", "translation_editor_actions_hook"); + elgg_register_plugin_hook_handler("action", "admin/plugins/set_priority", "translation_editor_actions_hook"); + + // register events + elgg_register_event_handler("upgrade", "system", "translation_editor_upgrade_event"); + + // Register actions + elgg_register_action("translation_editor/translate", dirname(__FILE__) . "/actions/translate.php"); + elgg_register_action("translation_editor/translate_search", dirname(__FILE__) . "/actions/translate_search.php"); + elgg_register_action("translation_editor/merge", dirname(__FILE__) . "/actions/merge.php"); + + // Admin only actions + elgg_register_action("translation_editor/make_translation_editor", dirname(__FILE__) . "/actions/make_translation_editor.php", "admin"); + elgg_register_action("translation_editor/unmake_translation_editor", dirname(__FILE__) . "/actions/unmake_translation_editor.php", "admin"); + elgg_register_action("translation_editor/delete", dirname(__FILE__) . "/actions/delete.php", "admin"); + elgg_register_action("translation_editor/disable_languages", dirname(__FILE__) . "/actions/disable_languages.php", "admin"); + elgg_register_action("translation_editor/add_language", dirname(__FILE__) . "/actions/add_language.php", "admin"); + elgg_register_action("translation_editor/add_custom_key", dirname(__FILE__) . "/actions/add_custom_key.php", "admin"); + elgg_register_action("translation_editor/delete_language", dirname(__FILE__) . "/actions/delete_language.php", "admin"); + \ No newline at end of file diff --git a/views/default/core/settings/account/language.php b/views/default/core/settings/account/language.php new file mode 100644 index 000000000..225bccc97 --- /dev/null +++ b/views/default/core/settings/account/language.php @@ -0,0 +1,42 @@ +language; + if (!empty($user->language)) { + $value = $user->language; + } + + if(count($translations ) > 1){ + ?> +
+
+

+
+
+

+ : + 'language', + 'value' => $value, + 'options_values' => $translations + )); + ?> +

+
+
+ "language", "value" => $value)); + } +} \ No newline at end of file diff --git a/views/default/plugins/translation_editor/settings.php b/views/default/plugins/translation_editor/settings.php new file mode 100644 index 000000000..4dfe4b7c9 --- /dev/null +++ b/views/default/plugins/translation_editor/settings.php @@ -0,0 +1,20 @@ + 'params[everybody_translate]', + 'options_values' => array( + 'yes' => elgg_echo('option:yes'), + 'no' => elgg_echo('option:no'), + ), + 'value' => $vars['entity']->everybody_translate ? $vars['entity']->everybody_translate : 'no', +)); + +$settings = <<<__HTML +
$everybody_translate_string $everybody_translate_view
+__HTML; + +echo $settings; diff --git a/views/default/translation_editor/add_custom_key.php b/views/default/translation_editor/add_custom_key.php new file mode 100644 index 000000000..4726479cc --- /dev/null +++ b/views/default/translation_editor/add_custom_key.php @@ -0,0 +1,21 @@ +"; + $form_body .= ""; + $form_body .= elgg_view("input/text", array("name" => "key")); + + $form_body .= ""; + $form_body .= ""; + $form_body .= "" . elgg_echo("translation_editor:custom_keys:translation_info") . ""; + $form_body .= ""; + + $form_body .= elgg_view("input/submit", array("value" => elgg_echo("save"))); + + $form = elgg_view("input/form", array("body" => $form_body, "action" => $action, "id" => "translation_editor_custom_keys_form")); + +?> +

+ "Afar", + "ab" => "Abkhazian", + "af" => "Afrikaans", + "am" => "Amharic", + "ar" => "Arabic", + "as" => "Assamese", + "ay" => "Aymara", + "az" => "Azerbaijani", + "ba" => "Bashkir", + "be" => "Byelorussian", + "bg" => "Bulgarian", + "bh" => "Bihari", + "bi" => "Bislama", + "bn" => "Bengali; Bangla", + "bo" => "Tibetan", + "br" => "Breton", + "ca" => "Catalan", + "co" => "Corsican", + "cs" => "Czech", + "cy" => "Welsh", + "da" => "Danish", + "de" => "German", + "dz" => "Bhutani", + "el" => "Greek", + "en" => "English", + "eo" => "Esperanto", + "es" => "Spanish", + "et" => "Estonian", + "eu" => "Basque", + "fa" => "Persian", + "fi" => "Finnish", + "fj" => "Fiji", + "fo" => "Faeroese", + "fr" => "French", + "fy" => "Frisian", + "ga" => "Irish", + "gd" => "Scots / Gaelic", + "gl" => "Galician", + "gn" => "Guarani", + "gu" => "Gujarati", + "he" => "Hebrew", + "ha" => "Hausa", + "hi" => "Hindi", + "hr" => "Croatian", + "hu" => "Hungarian", + "hy" => "Armenian", + "ia" => "Interlingua", + "id" => "Indonesian", + "ie" => "Interlingue", + "ik" => "Inupiak", + "is" => "Icelandic", + "it" => "Italian", + "iu" => "Inuktitut", + "iw" => "Hebrew (obsolete)", + "ja" => "Japanese", + "ji" => "Yiddish (obsolete)", + "jw" => "Javanese", + "ka" => "Georgian", + "kk" => "Kazakh", + "kl" => "Greenlandic", + "km" => "Cambodian", + "kn" => "Kannada", + "ko" => "Korean", + "ks" => "Kashmiri", + "ku" => "Kurdish", + "ky" => "Kirghiz", + "la" => "Latin", + "ln" => "Lingala", + "lo" => "Laothian", + "lt" => "Lithuanian", + "lv" => "Latvian/Lettish", + "mg" => "Malagasy", + "mi" => "Maori", + "mk" => "Macedonian", + "ml" => "Malayalam", + "mn" => "Mongolian", + "mo" => "Moldavian", + "mr" => "Marathi", + "ms" => "Malay", + "mt" => "Maltese", + "my" => "Burmese", + "na" => "Nauru", + "ne" => "Nepali", + "nl" => "Dutch", + "no" => "Norwegian", + "oc" => "Occitan", + "om" => "(Afan) Oromo", + "or" => "Oriya", + "pa" => "Punjabi", + "pl" => "Polish", + "ps" => "Pashto / Pushto", + "pt" => "Portuguese", + "qu" => "Quechua", + "rm" => "Rhaeto-Romance", + "rn" => "Kirundi", + "ro" => "Romanian", + "ru" => "Russian", + "rw" => "Kinyarwanda", + "sa" => "Sanskrit", + "sd" => "Sindhi", + "sg" => "Sangro", + "sh" => "Serbo-Croatian", + "si" => "Singhalese", + "sk" => "Slovak", + "sl" => "Slovenian", + "sm" => "Samoan", + "sn" => "Shona", + "so" => "Somali", + "sq" => "Albanian", + "sr" => "Serbian", + "ss" => "Siswati", + "st" => "Sesotho", + "su" => "Sundanese", + "sv" => "Swedish", + "sw" => "Swahili", + "ta" => "Tamil", + "te" => "Tegulu", + "tg" => "Tajik", + "th" => "Thai", + "ti" => "Tigrinya", + "tk" => "Turkmen", + "tl" => "Tagalog", + "tn" => "Setswana", + "to" => "Tonga", + "tr" => "Turkish", + "ts" => "Tsonga", + "tt" => "Tatar", + "tw" => "Twi", + "ug" => "Uigur", + "uk" => "Ukrainian", + "ur" => "Urdu", + "uz" => "Uzbek", + "vi" => "Vietnamese", + "vo" => "Volapuk", + "wo" => "Wolof", + "xh" => "Xhosa", + "yi" => "Yiddish", + "yo" => "Yoruba", + "za" => "Zuang", + "zh" => "Chinese", + "zu" => "Zulu" + ); + + foreach(get_installed_translations() as $index => $lang){ + unset($options[$index]); + } + + asort($options); + + $form_body .= elgg_view("input/dropdown", array("options_values" => $options, "name" => "code")); + $form_body .= " "; + $form_body .= elgg_view("input/submit", array("value" => elgg_echo("save"))); + + $form = elgg_view("input/form", array("body" => $form_body, "action" => $vars["url"] . "action/translation_editor/add_language", "id" => "translation_editor_add_language_form", "class" => "hidden")); + + echo "
"; + echo "+ " . elgg_echo("translation_editor:language_selector:add_language") . ""; + echo $form; + echo "
"; diff --git a/views/default/translation_editor/css/site.php b/views/default/translation_editor/css/site.php new file mode 100644 index 000000000..941ccdb7a --- /dev/null +++ b/views/default/translation_editor/css/site.php @@ -0,0 +1,99 @@ + + +#translation_editor_language_table th, +#translation_editor_plugin_list th { + font-weight: bold; +} + +#translation_editor_language_table .translation_editor_flag, +#translation_editor_language_table .translation_editor_enable { + width: 1%; + text-align: center; +} + +#translation_editor_plugin_list th, +#translation_editor_plugin_list td { + text-align: center; + white-space: nowrap; +} + +#translation_editor_plugin_list .first_col { + text-align: left; + width: 100%; +} + +#translation_editor_site_language { + color: gray; + margin-left: 10px; +} + +#translation_editor_custom_keys_translation_info { + color: gray; +} + +.translation_editor_translation_complete { + color: green; +} + +.translation_editor_translation_needed { + color: red; +} + +.translation_editor_translation_table textarea { + height: 70px; +} + +.view_mode_active { + font-weight: bold; +} + +.translation_editor_translation_table tr{ + display: none; +} + +.translation_editor_translation_table tr.first_row th{ + font-weight: bold; +} + +.translation_editor_translation_table tr.first_row th span{ + font-weight: normal; +} + +.translation_editor_translation_table tr.first_row, +.translation_editor_translation_table tr[rel='missing']{ + display: table-row; + +} + +.translation_editor_plugin_key { + float: right; + width: 16px; + height: 16px; + background: url(key.gif) no-repeat; +} + +.translation_editor_translation_table { + margin-bottom: 20px; +} + +.translation_editor_translation_table pre { + white-space: normal; + margin-bottom: 5px; +} + +.translation_editor_translation_table td{ + white-space: nowrap; +} + +.translation_editor_translation_table .first_col { + width: 33px; +} + +#translation_editor_search_form td { + width: 100%; + white-space: nowrap; +} diff --git a/views/default/translation_editor/js/site.php b/views/default/translation_editor/js/site.php new file mode 100644 index 000000000..be4dc0266 --- /dev/null +++ b/views/default/translation_editor/js/site.php @@ -0,0 +1,41 @@ + +// + +
+
+ + + ' /> + elgg_echo("save"))); + ?> +
+
diff --git a/views/default/translation_editor/plugin_list.php b/views/default/translation_editor/plugin_list.php new file mode 100644 index 000000000..b48b94fbf --- /dev/null +++ b/views/default/translation_editor/plugin_list.php @@ -0,0 +1,84 @@ +"; + $list .= ""; + $list .= "" . elgg_echo("translation_editor:plugin_list:plugin") . ""; + $list .= "" . elgg_echo("translation_editor:plugin_list:total") . ""; + $list .= "" . elgg_echo("translation_editor:plugin_list:exists") . ""; + $list .= "" . elgg_echo("translation_editor:plugin_list:custom") . ""; + $list .= "" . elgg_echo("translation_editor:plugin_list:percentage") . ""; + $list .= " "; + $list .= ""; + + foreach($plugins as $plugin_name => $plugin_stats){ + + $url = $vars["url"] . "translation_editor/" . $current_language . "/" . $plugin_name; + + $total += $plugin_stats["total"]; + $exists += $plugin_stats["exists"]; + $custom += $plugin_stats["custom"]; + + if(!empty($plugin_stats["total"])){ + $percentage = round(($plugin_stats["exists"] / $plugin_stats["total"]) * 100); + } else { + $percentage = 100; + } + + $complete_class = ""; + + if($percentage == 100){ + $complete_class = " class='translation_editor_translation_complete'"; + } elseif($percentage == 0){ + $complete_class = " class='translation_editor_translation_needed'"; + } + + $list .= ""; + $list .= "" . $plugin_name . ""; + $list .= "" . $plugin_stats["total"] . ""; + $list .= "" . $plugin_stats["exists"] . ""; + + if($plugin_stats["custom"] > 0){ + $list .= "" . $plugin_stats["custom"] . ""; + } else { + $list .= " "; + } + + $list .= "" . $percentage . "%"; + + if($plugin_stats["custom"] > 0){ + $merge_url = $vars["url"] . "action/translation_editor/merge?current_language=" . $current_language . "&plugin=" . $plugin_name; + + $list .= ""; + $list .= elgg_view("output/url", array("href" => $merge_url, "is_action" => true, "title" => elgg_echo("translation_editor:plugin_list:merge"), "text" => elgg_view_icon("download"))); + if(elgg_is_admin_logged_in()){ + $delete_url = $vars["url"] . "action/translation_editor/delete?current_language=" . $current_language . "&plugin=" . $plugin_name; + + $list .= elgg_view("output/confirmlink", array("href" => $delete_url, "title" => elgg_echo("delete"), "text" => elgg_view_icon("delete-alt"))); + } + $list .= ""; + } else { + $list .= " "; + } + $list .= ""; + } + + $list .= ""; + $list .= " "; + $list .= "" . $total . ""; + $list .= "" . $exists . ""; + $list .= "" . $custom . ""; + $list .= "" . round(($exists / $total) * 100, 2) . "%"; + $list .= " "; + $list .= ""; + + $list .= ""; + + echo $list; + } diff --git a/views/default/translation_editor/search.php b/views/default/translation_editor/search.php new file mode 100644 index 000000000..541b33123 --- /dev/null +++ b/views/default/translation_editor/search.php @@ -0,0 +1,43 @@ +"; + + $form_data .= elgg_view("input/text", array("name" => "translation_editor_search", "value" => $q)); + + $form_data .= " "; + + $form_data .= elgg_view("input/hidden", array("name" => "language", "value" => $current_language)); + $form_data .= elgg_view("input/submit", array("value" => elgg_echo("search"))); + + $form_data .= ""; + $form = elgg_view("input/form", array("body" => $form_data, + "id" => "translation_editor_search_form", + "action" => $vars["url"] . "translation_editor/search", + "disable_security" => true)); + + echo $form; + echo "
"; + +?> + \ No newline at end of file diff --git a/views/default/translation_editor/search_results.php b/views/default/translation_editor/search_results.php new file mode 100644 index 000000000..bb771bd9f --- /dev/null +++ b/views/default/translation_editor/search_results.php @@ -0,0 +1,78 @@ +"; + } else { + $en_flag = "en"; + } + + $lang_flag_file = "mod/translation_editor/_graphics/flags/" . $current_language . ".png"; + + if(file_exists(elgg_get_root_path() . $lang_flag_file)){ + $lang_flag = "" . elgg_echo($current_language)  . ""; + } else { + $lang_flag = $current_language; + } + + foreach($search_results as $plugin => $data){ + $translated_language = $data["current_language"]; + + $list .= ""; + $list .= ""; + $list .= ""; + + foreach($data["en"] as $key => $value){ + + // English information + $list .= ""; + $list .= ""; + $list .= ""; + $list .= ""; + + // Custom language information + $list .= ""; + $list .= ""; + $list .= ""; + $list .= ""; + } + + $list .= "
"; + $list .= "" . $plugin . ""; + $list .= "
" . $en_flag . ""; + $list .= ""; + $list .= "
" . nl2br(htmlspecialchars($value)) . "
"; + $list .="
" . $lang_flag . ""; + $list .= ""; + $list .= "
"; + } + + $form_data = elgg_view("input/hidden", array("name" => "current_language", "value" => $current_language)); + $form_data .= $list; + + $form_data .= elgg_view("input/submit", array("value" => elgg_echo("save"))); + + $list = elgg_view("input/form", array("body" => $form_data, + "action" => $vars["url"] . "action/translation_editor/translate_search", + "id" => "translation_editor_search_result_form")); + } else { + $list .= elgg_echo("translation_editor:search_results:no_results"); + } + + echo $list; +?> + -- cgit v1.2.3