Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/Option/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Kirby\Option;

use Kirby\Cms\ModelWithContent;
use Kirby\Toolkit\I18n;
use Kirby\Toolkit\HasI18n;

/**
* Option for select fields, radio fields, etc.
Expand All @@ -16,6 +16,8 @@
*/
class Option
{
use HasI18n;

public string|array $text;

public function __construct(
Expand Down Expand Up @@ -69,8 +71,8 @@ public function render(
ModelWithContent $model,
bool $safeMode = true
): array {
$info = I18n::translate($this->info, $this->info);
$text = I18n::translate($this->text, $this->text);
$info = $this->i18n($this->info);
$text = $this->i18n($this->text);
$method = $safeMode === true ? 'toSafeString' : 'toString';

return [
Expand Down
10 changes: 6 additions & 4 deletions src/Panel/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Kirby\Panel\Ui\Button;
use Kirby\Panel\Ui\Component;
use Kirby\Toolkit\A;
use Kirby\Toolkit\I18n;
use Kirby\Toolkit\HasI18n;

/**
* The Menu class takes care of gathering
Expand All @@ -23,6 +23,8 @@
*/
class Menu
{
use HasI18n;

public Areas $areas;
public array $config;
protected array $items;
Expand Down Expand Up @@ -211,14 +213,14 @@ public function items(): array
$items[] = new Button(
id: 'changes',
icon: 'edit-line',
text: I18n::translate('changes'),
text: $this->i18n('changes'),
dialog: 'changes'
);

$items[] = new Button(
id: 'account',
icon: 'account',
text: I18n::translate('view.account'),
text: $this->i18n('view.account'),
link: 'account',
current: $this->current === 'account',
disabled: $this->hasPermission('account') === false
Expand All @@ -227,7 +229,7 @@ public function items(): array
$items[] = new Button(
id: 'logout',
icon: 'logout',
text: I18n::translate('logout'),
text: $this->i18n('logout'),
link: 'logout'
);

Expand Down
3 changes: 1 addition & 2 deletions src/Panel/Ui/Button/LanguageCreateButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Kirby\Panel\Ui\Button;

use Kirby\Cms\App;
use Kirby\Toolkit\I18n;

/**
* View button to create a new language
Expand All @@ -27,7 +26,7 @@ public function __construct()
dialog: 'languages/create',
disabled: $permission !== true,
icon: 'add',
text: I18n::translate('language.create'),
text: $this->i18n('language.create'),
);
}
}
3 changes: 1 addition & 2 deletions src/Panel/Ui/Button/LanguageDeleteButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Kirby\Cms\App;
use Kirby\Cms\Language;
use Kirby\Toolkit\I18n;

/**
* View button to delete a language
Expand All @@ -28,7 +27,7 @@ public function __construct(Language $language)
dialog: 'languages/' . $language->id() . '/delete',
disabled: $permission !== true,
icon: 'trash',
title: I18n::translate('delete'),
title: $this->i18n('delete'),
);
}
}
3 changes: 1 addition & 2 deletions src/Panel/Ui/Button/LanguageSettingsButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Kirby\Cms\App;
use Kirby\Cms\Language;
use Kirby\Toolkit\I18n;

/**
* View button to update settings of a language
Expand All @@ -28,7 +27,7 @@ public function __construct(Language $language)
dialog: 'languages/' . $language->id() . '/update',
disabled: $permission !== true,
icon: 'cog',
title: I18n::translate('settings'),
title: $this->i18n('settings'),
);
}
}
4 changes: 1 addition & 3 deletions src/Panel/Ui/Button/OpenButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Kirby\Panel\Ui\Button;

use Kirby\Toolkit\I18n;

/**
* Open view button
*
Expand All @@ -26,7 +24,7 @@ class: 'k-open-view-button',
icon: 'open',
link: $link,
target: $target,
title: I18n::translate('open')
title: $this->i18n('open')
);
}
}
7 changes: 3 additions & 4 deletions src/Panel/Ui/Button/PageStatusButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Kirby\Panel\Ui\Button;

use Kirby\Cms\Page;
use Kirby\Toolkit\I18n;

/**
* Status view button for pages
Expand All @@ -26,11 +25,11 @@ public function __construct(
$disabled = $page->permissions()->cannot('changeStatus') || $page->lock()->isLocked();

$text = $blueprint['label'] ?? null;
$text ??= I18n::translate('page.status.' . $status);
$title = I18n::translate('page.status') . ': ' . $text;
$text ??= $this->i18n('page.status.' . $status);
$title = $this->i18n('page.status') . ': ' . $text;

if ($disabled === true) {
$title .= ' (' . I18n::translate('disabled') . ')';
$title .= ' (' . $this->i18n('disabled') . ')';
}

parent::__construct(
Expand Down
3 changes: 1 addition & 2 deletions src/Panel/Ui/Button/SettingsButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Kirby\Panel\Ui\Button;

use Kirby\Cms\ModelWithContent;
use Kirby\Toolkit\I18n;

/**
* Settings view button for models
Expand All @@ -27,7 +26,7 @@ class: 'k-settings-view-button',
disabled: $model->lock()->isLocked(),
icon: 'cog',
options: $model->panel()->url(true),
title: I18n::translate('settings'),
title: $this->i18n('settings'),
);
}
}
5 changes: 2 additions & 3 deletions src/Panel/Ui/Button/VersionsButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Kirby\Cms\ModelWithContent;
use Kirby\Content\VersionId;
use Kirby\Toolkit\I18n;

/**
* Versions view button for models
Expand Down Expand Up @@ -89,13 +88,13 @@ public function options(): array
],
'-',
[
'label' => I18n::translate('version.latest'),
'label' => $this->i18n('version.latest'),
'icon' => 'git-branch',
'link' => $this->url('latest'),
'current' => $this->isCurrent('latest')
],
[
'label' => I18n::translate('version.changes'),
'label' => $this->i18n('version.changes'),
'icon' => 'git-branch',
'link' => $this->url('changes'),
'current' => $this->isCurrent('changes')
Expand Down
9 changes: 4 additions & 5 deletions src/Panel/Ui/FilePreview.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Kirby\Cms\File;
use Kirby\Exception\InvalidArgumentException;
use Kirby\Panel\Ui\FilePreview\DefaultFilePreview;
use Kirby\Toolkit\I18n;

/**
* Defines a component that implements a file preview
Expand Down Expand Up @@ -39,20 +38,20 @@ public function details(): array
{
return [
[
'title' => I18n::translate('template'),
'title' => $this->i18n('template'),
'text' => $this->file->template() ?? '—'
],
[
'title' => I18n::translate('mime'),
'title' => $this->i18n('mime'),
'text' => $this->file->mime()
],
[
'title' => I18n::translate('url'),
'title' => $this->i18n('url'),
'link' => $link = $this->file->previewUrl(),
'text' => $link,
],
[
'title' => I18n::translate('size'),
'title' => $this->i18n('size'),
'text' => $this->file->niceSize()
],
];
Expand Down
9 changes: 4 additions & 5 deletions src/Panel/Ui/FilePreview/ImageFilePreview.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Kirby\Cms\File;
use Kirby\Panel\Ui\FilePreview;
use Kirby\Toolkit\I18n;

/**
* @package Kirby Panel
Expand Down Expand Up @@ -35,12 +34,12 @@ public function details(): array
return [
...parent::details(),
[
'title' => I18n::translate('dimensions'),
'text' => $dimensions . ' ' . I18n::translate('pixel')
'title' => $this->i18n('dimensions'),
'text' => $dimensions . ' ' . $this->i18n('pixel')
],
[
'title' => I18n::translate('orientation'),
'text' => I18n::translate('orientation.' . $dimensions->orientation())
'title' => $this->i18n('orientation'),
'text' => $this->i18n('orientation.' . $dimensions->orientation())
]
];
}
Expand Down
1 change: 0 additions & 1 deletion src/Toolkit/HasI18n.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ protected function i18n(
Closure|string|array|null $key,
array|null $data = null
): string|null {

if ($key instanceof Closure) {
$key = $key();
}
Expand Down
Loading