From fa5bf90195ba490c774ec822a78d49117380448a Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Fri, 20 Jun 2014 09:25:30 +0000 Subject: [PATCH] Remove canned messafes from localization constants --- src/mibew/install/index.php | 18 ++++++++++++++---- src/mibew/locales/en/canned_messages.yml | 2 ++ src/mibew/locales/en/translation.po | 2 -- 3 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 src/mibew/locales/en/canned_messages.yml diff --git a/src/mibew/install/index.php b/src/mibew/install/index.php index 00237a45..4ff3b475 100644 --- a/src/mibew/install/index.php +++ b/src/mibew/install/index.php @@ -309,10 +309,20 @@ function add_canned_messages($link){ } $result = array(); foreach (get_available_locales() as $locale) { - if (! in_array($locale, $existlocales)) { - foreach (explode("\n", getlocal('chat.predefined_answers', null, $locale)) as $answer) { - $result[] = array('locale' => $locale, 'vctitle' => cut_string($answer, 97, '...'), 'vcvalue' => $answer); - } + if (in_array($locale, $existlocales)) { + // Do not export canned messages for existing locales + continue; + } + + $file_path = MIBEW_FS_ROOT . '/locales/' . $locale . '/canned_messages.yml'; + if (!is_readable($file_path)) { + // Export canned messages only for locales which have canned messages + continue; + } + + $canned_messages = get_yml_file_content($file_path); + foreach ($canned_messages as $answer) { + $result[] = array('locale' => $locale, 'vctitle' => cut_string($answer, 97, '...'), 'vcvalue' => $answer); } } if (count($result) > 0) { diff --git a/src/mibew/locales/en/canned_messages.yml b/src/mibew/locales/en/canned_messages.yml new file mode 100644 index 00000000..f453a60c --- /dev/null +++ b/src/mibew/locales/en/canned_messages.yml @@ -0,0 +1,2 @@ +- 'Hello. How may I help you?' +- 'Hello! Welcome to our support. How may I help you?' diff --git a/src/mibew/locales/en/translation.po b/src/mibew/locales/en/translation.po index 2588756b..f9f08ceb 100644 --- a/src/mibew/locales/en/translation.po +++ b/src/mibew/locales/en/translation.po @@ -98,8 +98,6 @@ msgid "chat.mailthread.sent.content" msgstr "A history of your chat was sent to address {0}" msgid "chat.mailthread.sent.title" msgstr "Sent" -msgid "chat.predefined_answers" -msgstr "Hello. How may I help you?\nHello! Welcome to our support. How may I help you?" msgid "chat.redirect.back" msgstr "Back..." msgid "chat.redirect.cannot"