Skip to content

Commit 65ab4a9

Browse files
Nico4devvBoy132
andauthored
[Minecraft Modrinth] Add translations (#72)
* Add localization support for Modrinth project types and notifications * Add German localization for Modrinth plugin * Remove unnecessary whitespace in localization files for Modrinth plugin * Fix missing newline at end of file in main.php * Update English localization strings in main.php * Remove trailing whitespace in German localization file * Fix missing newline at end of file in localization files * Fix missing newline at end of file in English and German localization files * Set default values for CPU, memory, and disk inputs in ServerResourcePage * Refactor localization calls to use trans() instead of __() in ModrinthProjectType and MinecraftModrinthPlugin * Revert "Set default values for CPU, memory, and disk inputs in ServerResourcePage" This reverts commit ecfc55f. * rename file --------- Co-authored-by: Boy132 <mail@boy132.de>
1 parent 39f9c1f commit 65ab4a9

5 files changed

Lines changed: 104 additions & 12 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
return [
4+
'plugin_name' => 'Modrinth',
5+
'minecraft_mods' => 'Minecraft Mods',
6+
'minecraft_plugins' => 'Minecraft Plugins',
7+
8+
'settings' => [
9+
'latest_minecraft_version' => 'Neueste Minecraft-Version',
10+
'settings_saved' => 'Einstellungen gespeichert',
11+
],
12+
13+
'page' => [
14+
'open_folder' => ':folder-Ordner öffnen',
15+
'minecraft_version' => 'Minecraft-Version',
16+
'loader' => 'Loader',
17+
'installed' => 'Installiert :type',
18+
'unknown' => 'Unbekannt',
19+
],
20+
21+
'table' => [
22+
'columns' => [
23+
'title' => 'Titel',
24+
'author' => 'Autor',
25+
'downloads' => 'Downloads',
26+
'date_modified' => 'Geändert',
27+
],
28+
],
29+
30+
'version' => [
31+
'type' => 'Typ',
32+
'downloads' => 'Downloads',
33+
'published' => 'Veröffentlicht',
34+
'changelog' => 'Änderungsprotokoll',
35+
'no_file_found' => 'Keine Datei gefunden',
36+
],
37+
38+
'actions' => [
39+
'download' => 'Herunterladen',
40+
],
41+
42+
'notifications' => [
43+
'download_started' => 'Download gestartet',
44+
'download_failed' => 'Download konnte nicht gestartet werden',
45+
],
46+
];
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
return [
4+
'plugin_name' => 'Modrinth',
5+
'minecraft_mods' => 'Minecraft Mods',
6+
'minecraft_plugins' => 'Minecraft Plugins',
7+
8+
'settings' => [
9+
'latest_minecraft_version' => 'Latest Minecraft Version',
10+
'settings_saved' => 'Settings saved',
11+
],
12+
13+
'page' => [
14+
'open_folder' => 'Open :folder folder',
15+
'minecraft_version' => 'Minecraft Version',
16+
'loader' => 'Loader',
17+
'installed' => 'Installed :type',
18+
'unknown' => 'Unknown',
19+
],
20+
21+
'table' => [
22+
'columns' => [
23+
'title' => 'Title',
24+
'author' => 'Author',
25+
'downloads' => 'Downloads',
26+
'date_modified' => 'Modified',
27+
],
28+
],
29+
30+
'version' => [
31+
'type' => 'Type',
32+
'downloads' => 'Downloads',
33+
'published' => 'Published',
34+
'changelog' => 'Changelog',
35+
'no_file_found' => 'No file found',
36+
],
37+
38+
'actions' => [
39+
'download' => 'Download',
40+
],
41+
42+
'notifications' => [
43+
'download_started' => 'Download started',
44+
'download_failed' => 'Download could not be started',
45+
],
46+
];

minecraft-modrinth/src/Enums/ModrinthProjectType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ enum ModrinthProjectType: string implements HasLabel
1313
public function getLabel(): string
1414
{
1515
return match ($this) {
16-
self::Mod => 'Minecraft Mods',
17-
self::Plugin => 'Minecraft Plugins',
16+
self::Mod => trans('minecraft-modrinth::strings.minecraft_mods'),
17+
self::Plugin => trans('minecraft-modrinth::strings.minecraft_plugins'),
1818
};
1919
}
2020

minecraft-modrinth/src/Filament/Server/Pages/MinecraftModrinthProjectPage.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function table(Table $table): Table
125125
}
126126

127127
$schema[] = Section::make($versionData['name'])
128-
->description($versionData['version_number'] . ($primaryFile ? ' (' . convert_bytes_to_readable($primaryFile['size']) . ')' : ' (No file found)'))
128+
->description($versionData['version_number'] . ($primaryFile ? ' (' . convert_bytes_to_readable($primaryFile['size']) . ')' : ' (' . trans('minecraft-modrinth::strings.version.no_file_found') . ')'))
129129
->collapsed(!$versionData['featured'])
130130
->collapsible()
131131
->icon($versionData['version_type'] === 'alpha' ? 'tabler-circle-letter-a' : ($versionData['version_type'] === 'beta' ? 'tabler-circle-letter-b' : 'tabler-circle-letter-r'))
@@ -156,15 +156,15 @@ public function table(Table $table): Table
156156
$fileRepository->setServer($server)->pull($primaryFile['url'], ModrinthProjectType::fromServer($server)->getFolder());
157157

158158
Notification::make()
159-
->title('Download started')
159+
->title(trans('minecraft-modrinth::strings.notifications.download_started'))
160160
->body($versionData['name'])
161161
->success()
162162
->send();
163163
} catch (Exception $exception) {
164164
report($exception);
165165

166166
Notification::make()
167-
->title('Download could not be started')
167+
->title(trans('minecraft-modrinth::strings.notifications.download_failed'))
168168
->body($exception->getMessage())
169169
->danger()
170170
->send();
@@ -187,7 +187,7 @@ protected function getHeaderActions(): array
187187

188188
return [
189189
Action::make('open_folder')
190-
->label(fn () => 'Open ' . $folder . ' folder')
190+
->label(fn () => trans('minecraft-modrinth::strings.page.open_folder', ['folder' => $folder]))
191191
->url(fn () => ListFiles::getUrl(['path' => $folder]), true),
192192
];
193193
}
@@ -202,13 +202,13 @@ public function content(Schema $schema): Schema
202202
Grid::make(3)
203203
->schema([
204204
TextEntry::make('Minecraft Version')
205-
->state(fn () => MinecraftModrinth::getMinecraftVersion($server) ?? 'Unknown')
205+
->state(fn () => MinecraftModrinth::getMinecraftVersion($server) ?? trans('minecraft-modrinth::strings.page.unknown'))
206206
->badge(),
207207
TextEntry::make('Loader')
208-
->state(fn () => MinecraftLoader::fromServer($server)?->getLabel() ?? 'Unknown')
208+
->state(fn () => MinecraftLoader::fromServer($server)?->getLabel() ?? trans('minecraft-modrinth::strings.page.unknown'))
209209
->badge(),
210210
TextEntry::make('installed')
211-
->label(fn () => 'Installed ' . ModrinthProjectType::fromServer($server)->getLabel())
211+
->label(fn () => trans('minecraft-modrinth::strings.page.installed', ['type' => ModrinthProjectType::fromServer($server)->getLabel()]))
212212
->state(function (DaemonFileRepository $fileRepository) use ($server) {
213213
try {
214214
$files = $fileRepository->setServer($server)->getDirectory(ModrinthProjectType::fromServer($server)->getFolder());
@@ -223,7 +223,7 @@ public function content(Schema $schema): Schema
223223
} catch (Exception $exception) {
224224
report($exception);
225225

226-
return 'Unknown';
226+
return trans('minecraft-modrinth::strings.page.unknown');
227227
}
228228
})
229229
->badge(),

minecraft-modrinth/src/MinecraftModrinthPlugin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function getSettingsForm(): array
3131
{
3232
return [
3333
TextInput::make('latest_minecraft_version')
34-
->label('Latest Minecraft Version')
34+
->label(trans('minecraft-modrinth::strings.settings.latest_minecraft_version'))
3535
->required()
3636
->default(fn () => config('minecraft-modrinth.latest_minecraft_version', '1.21.11')),
3737
];
@@ -44,7 +44,7 @@ public function saveSettings(array $data): void
4444
]);
4545

4646
Notification::make()
47-
->title('Settings saved')
47+
->title(trans('minecraft-modrinth::strings.settings.settings_saved'))
4848
->success()
4949
->send();
5050
}

0 commit comments

Comments
 (0)