From bc80d2c6e0f45a65ced679e8c916b44521410cf6 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Mon, 27 Jun 2022 13:49:16 +0300 Subject: [PATCH] Display the language key if no translation is available --- application/helpers/language_helper.php | 42 +++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 application/helpers/language_helper.php diff --git a/application/helpers/language_helper.php b/application/helpers/language_helper.php new file mode 100644 index 00000000..c79fa811 --- /dev/null +++ b/application/helpers/language_helper.php @@ -0,0 +1,42 @@ + + * @copyright Copyright (c) Alex Tselegidis + * @license https://opensource.org/licenses/GPL-3.0 - GPLv3 + * @link https://easyappointments.org + * @since v1.1.0 + * ---------------------------------------------------------------------------- */ + + +if ( ! function_exists('lang')) +{ + /** + * Lang + * + * Fetches a language variable and optionally outputs a form label + * + * @param string $line The language line. + * @param string $for The "for" value (id of the form element). + * @param array $attributes Any additional HTML attributes. + * + * @return string + */ + function lang(string $line, string $for = '', array $attributes = []): string + { + /** @var EA_Controller $CI */ + $CI = get_instance(); + + $result = $CI->lang->line($line); + + if ($for !== '') + { + $result = ''; + } + + return $result ?: $line; + } +}