Skip to content

Commit b4f1b24

Browse files
authored
Merge pull request #31 from ReubenSiama/customizable-icon
2 parents 5614dd8 + 342b0fb commit b4f1b24

File tree

3 files changed

+36
-10
lines changed

3 files changed

+36
-10
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,13 @@ You can choose to exclude specific groups of translations from appearing in Fila
128128
],
129129
```
130130

131+
### Navigation Icon
132+
133+
You can customize the navigation icon by configuring the `navigation-icon` variable
134+
```
135+
'navigation_icon' => 'heroicon-o-language',
136+
```
137+
131138
## Usage
132139

133140
The library creates a new directory for the new translations, see [Laravel Chained Translator](https://github.com/statikbe/laravel-chained-translator).

config/filament-translation-manager.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,18 @@
7272
'gate' => null,
7373
'sort' => null,
7474
],
75+
76+
/*
77+
|--------------------------------------------------------------------------
78+
| Navigation Icon
79+
|--------------------------------------------------------------------------
80+
|
81+
| You can specify the navigation icon.
82+
| (visit: https://blade-ui-kit.com/blade-icons?set=1#search)
83+
| Default: 'heroicon-o-language'
84+
| For null value, the icon will be hidden.
85+
|
86+
*/
87+
88+
'navigation_icon' => 'heroicon-o-language',
7589
];

src/Pages/TranslationManagerPage.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ class TranslationManagerPage extends Page
2121
*/
2222
const PAGE_LIMIT = 20;
2323

24-
protected static ?string $navigationIcon = 'heroicon-o-language';
25-
2624
private ChainedTranslationManager $chainedTranslationManager;
2725

2826
public array $groups;
@@ -89,6 +87,13 @@ public static function getNavigationLabel(): string
8987
return trans('filament-translation-manager::messages.title');
9088
}
9189

90+
public static function getNavigationIcon(): ?string
91+
{
92+
return config()->has('filament-translation-manager.navigation_icon')
93+
? config('filament-translation-manager.navigation_icon')
94+
: 'heroicon-o-language';
95+
}
96+
9297
public function getTitle(): string
9398
{
9499
return trans('filament-translation-manager::messages.title');
@@ -138,10 +143,10 @@ private function addTranslationsToData(array &$data, string $locale, string $gro
138143

139144
//transform to data structure necessary for frontend
140145
foreach ($translations as $key => $translation) {
141-
$dataKey = $group.'.'.$key;
142-
if (! array_key_exists($dataKey, $data)) {
146+
$dataKey = $group . '.' . $key;
147+
if (!array_key_exists($dataKey, $data)) {
143148
$data[$dataKey] = [
144-
'title' => $group.' - '.$key,
149+
'title' => $group . ' - ' . $key,
145150
'type' => 'group',
146151
'group' => $group,
147152
'translation_key' => $key,
@@ -222,7 +227,7 @@ public function filterTranslations(): void
222227
});
223228
}
224229

225-
if (! empty($this->selectedGroups)) {
230+
if (!empty($this->selectedGroups)) {
226231
$filteredTranslations = $filteredTranslations->filter(function ($translationItem, $key) {
227232
return in_array($translationItem['group'], $this->selectedGroups, true);
228233
});
@@ -255,7 +260,7 @@ private function paginateTranslations(Collection $translations): Collection
255260

256261
private function getChainedTranslationManager(): ChainedTranslationManager
257262
{
258-
if (! isset($this->chainedTranslationManager)) {
263+
if (!isset($this->chainedTranslationManager)) {
259264
$this->chainedTranslationManager = app(ChainedTranslationManager::class);
260265
}
261266

@@ -304,9 +309,9 @@ public function translationsSaved(string $group, string $translationKey, array $
304309
$oldMissing = $this->checkIfTranslationMissing($initialTranslations, $this->getFilteredLocales());
305310
$newMissing = $this->checkIfTranslationMissing($newTranslation, $this->getFilteredLocales());
306311

307-
if ($oldMissing && ! $newMissing) {
312+
if ($oldMissing && !$newMissing) {
308313
$this->totalMissingFilteredTranslations--;
309-
} elseif (! $oldMissing && $newMissing) {
314+
} elseif (!$oldMissing && $newMissing) {
310315
$this->totalMissingFilteredTranslations++;
311316
}
312317
}
@@ -332,7 +337,7 @@ private function checkIfTranslationMissing(array $translations, array $filteredL
332337

333338
private function getFilteredLocales(): array
334339
{
335-
return ! empty($this->selectedLocales) ? $this->selectedLocales : $this->locales;
340+
return !empty($this->selectedLocales) ? $this->selectedLocales : $this->locales;
336341
}
337342

338343
public static function getNavigationSort(): ?int

0 commit comments

Comments
 (0)