Add support for localized options
This commit is contained in:
parent
12b32fce3d
commit
def8cc39b6
|
|
@ -317,13 +317,13 @@ class OptionForm
|
|||
protected function getValueById($id)
|
||||
{
|
||||
if (false === ($result = $this->parseIdWithOffset($id))) {
|
||||
return Arr::get($this->values, $id, option($id));
|
||||
return Arr::get($this->values, $id, option_localized($id));
|
||||
} else {
|
||||
$option = Arr::get(
|
||||
$this->values,
|
||||
$result['id'],
|
||||
// Fallback to load from options
|
||||
@unserialize(option($result['id']))
|
||||
@unserialize(option_localized($result['id']))
|
||||
);
|
||||
|
||||
return Arr::get($option, $result['offset']);
|
||||
|
|
@ -628,7 +628,7 @@ class OptionFormGroup extends OptionFormItem
|
|||
|
||||
foreach ($this->items as $item) {
|
||||
if ($item['id'] && is_null($item['value'])) {
|
||||
$item['value'] = option($item['id']);
|
||||
$item['value'] = option_localized($item['id']);
|
||||
}
|
||||
|
||||
$rendered[] = view('common.option-form.'.$item['type'])->with([
|
||||
|
|
|
|||
|
|
@ -257,9 +257,10 @@ if (! function_exists('bs_custom_copyright')) {
|
|||
|
||||
function bs_custom_copyright()
|
||||
{
|
||||
$localizedCopyrightText = option('copyright_text_'.config('app.locale'), option('copyright_text'));
|
||||
|
||||
return Utils::getStringReplaced($localizedCopyrightText, ['{site_name}' => Option::get('site_name'), '{site_url}' => Option::get('site_url')]);
|
||||
return Utils::getStringReplaced(option_localized('copyright_text'), [
|
||||
'{site_name}' => option_localized('site_name'),
|
||||
'{site_url}' => option('site_url')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -267,9 +268,7 @@ if (! function_exists('bs_announcement')) {
|
|||
|
||||
function bs_announcement()
|
||||
{
|
||||
$localizedAnnouncement = option('announcement_'.config('app.locale'), option('announcement'));
|
||||
|
||||
return app('parsedown')->text($localizedAnnouncement);
|
||||
return app('parsedown')->text(option_localized('announcement'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -332,6 +331,14 @@ if (! function_exists('option')) {
|
|||
}
|
||||
}
|
||||
|
||||
if (! function_exists('option_localized')) {
|
||||
|
||||
function option_localized($key = null, $default = null, $raw = false)
|
||||
{
|
||||
return option($key.'_'.config('app.locale'), option($key));
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('menv')) {
|
||||
/**
|
||||
* Gets the value of an environment variable by getenv() or $_ENV.
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user