From 2c3c26f0afb5b09e18467cc6c88c91bcc94bdd47 Mon Sep 17 00:00:00 2001 From: Jordan Doyle Date: Sat, 14 Apr 2018 23:01:49 +0100 Subject: [PATCH] Override __ to attempt to pull a translation from both WP & Laravel --- src/helpers.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/helpers.php b/src/helpers.php index 1fc35e8..2999d7a 100644 --- a/src/helpers.php +++ a/src/helpers.php @@ -1,9 +1,37 @@ getFromJson($key, $replace, $locale); + } catch (\Exception $e) { + // failed to get translation from Laravel + if ((!empty($replace) && !is_string($replace)) || !empty($locale)) { + // this doesn't look like something we can pass to WordPress, lets + // rethrow the exception + throw $e; + } + } + } + + return translate($key, empty($replace) ? 'default' : $replace); + } +} + if (!function_exists('query')) { /** * Get the main query or convert a {@link WP_Query} to a {@link \Koselig\Proxy\Query} proxy instance. -- rgit 0.1.5