From ad26a04b03dde34efba55cdd859f4000c14e61e7 Mon Sep 17 00:00:00 2001 From: Vytenis Date: Sat, 12 Mar 2016 23:43:35 +0200 Subject: [PATCH] Update TranslationsController.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Do not allow the google to translate special tags like `:atribute` in strings. Ex.: en ``` The :attribute must have between :min and :max items. ``` Will be translated to: ru ``` :attribute Должны иметь между :min и :max пунктов. ``` --- src/Controllers/TranslationsController.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Controllers/TranslationsController.php b/src/Controllers/TranslationsController.php index 999db6f..d66fcdd 100644 --- a/src/Controllers/TranslationsController.php +++ b/src/Controllers/TranslationsController.php @@ -93,7 +93,9 @@ public function postStore(Request $request) { } public function postTranslate(Request $request) { - $text = TranslateClient::translate($request->input('origin'), $request->input('target'), $request->input('text')); + $text = preg_replace('/(:)(\w+)/', '--$2', $request->input('text')); + $text = TranslateClient::translate($request->input('origin'), $request->input('target'), $text); + $text = preg_replace('/(--)(\w+)/', ':$2', $text); $key = $request->input('key'); return compact('key', 'text'); } @@ -104,4 +106,4 @@ public function postDelete(Request $request) ->where('name', strtolower($request->get('name')))->delete(); return 'OK'; } -} \ No newline at end of file +}