Display the language key if no translation is available
This commit is contained in:
parent
b79a17f25e
commit
bc80d2c6e0
1 changed files with 42 additions and 0 deletions
42
application/helpers/language_helper.php
Normal file
42
application/helpers/language_helper.php
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------------
|
||||||
|
* Easy!Appointments - Online Appointment Scheduler
|
||||||
|
*
|
||||||
|
* @package EasyAppointments
|
||||||
|
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||||
|
* @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 = '<label for="' . $for . '"' . _stringify_attributes($attributes) . '>' . $result . '</label>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result ?: $line;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue