Skip to content

Commit e706d8e

Browse files
Merge pull request #52 from thethunderturner/feature/translations
Feature/translations
2 parents 9755601 + af8e3d9 commit e706d8e

File tree

13 files changed

+269
-69
lines changed

13 files changed

+269
-69
lines changed

config/filament-latex.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
<?php
22

33
return [
4-
/**
5-
* UI customizations
6-
*/
7-
'navigation-label' => 'Filament Latex',
8-
'navigation-icon' => null, // Override the navigation icon with a heroicon
9-
'navigation-group' => null,
10-
'list-page-title' => 'Latex Documents',
11-
'create-button-label' => 'Create Document',
12-
'create-page-title' => 'Create Latex Document',
13-
144
/**
155
* Parser Settings
166
*

resources/lang/el/filament-latex.php

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
3+
return [
4+
/*
5+
|--------------------------------------------------------------------------
6+
| Form Fields
7+
|--------------------------------------------------------------------------
8+
*/
9+
10+
'field' => [
11+
'name' => 'Τίτλος Εγγράφου',
12+
'deadline' => 'Προθεσμία',
13+
'author_id' => 'Συγγραφέας',
14+
'collaborators_id' => 'Συμμετέχοντες',
15+
],
16+
17+
/*
18+
|--------------------------------------------------------------------------
19+
| Table Columns
20+
|--------------------------------------------------------------------------
21+
*/
22+
'column' => [
23+
'id' => 'ID',
24+
'name' => 'Τίτλος Εγγράφου',
25+
'deadline' => 'Προθεσμία',
26+
'created_at' => 'Δημιουργήθηκε στις',
27+
'author_avatar' => 'Συγγραφέας',
28+
'collaborators_avatars' => 'Συμμετέχοντες',
29+
'author' => [
30+
'name' => 'Συγγραφέας',
31+
],
32+
'collaborators' => 'Συμμετέχοντες',
33+
'updated_at' => 'Τελευταία Ενημέρωση',
34+
],
35+
36+
/*
37+
|--------------------------------------------------------------------------
38+
| LaTeX Page Labels
39+
|--------------------------------------------------------------------------
40+
*/
41+
'page' => [
42+
'download.tooltip' => 'Λήψη PDF',
43+
'compile' => [
44+
'action' => 'Μεταγλώττιση LaTeX',
45+
'success-title' => 'Το έγγραφο μεταγλωττίστηκε με επιτυχία!',
46+
'success-body' => 'Το έγγραφο μεταγλωττίστηκε επιτυχώς.',
47+
'error-title' => 'Σφάλμα Μεταγλώττισης.',
48+
'error-body' => 'Παρουσιάστηκε σφάλμα κατά τη μεταγλώττιση του εγγράφου.',
49+
],
50+
'create' => [
51+
'title' => 'Δημιουργία Εγγράφου',
52+
'notification' => 'Το έγγραφο δημιουργήθηκε με επιτυχία!',
53+
'button' => 'Δημιουργία Εγγράφου',
54+
],
55+
56+
// Refers to the file upload action
57+
'file-upload' => [
58+
'title' => 'Μεταφόρτωση Αρχείων',
59+
'icon' => 'heroicon-o-document-arrow-up',
60+
'heading' => 'Μεταφόρτωση Αρχείων',
61+
'description' => 'Μεταφορτώστε αρχεία για επισύναψη στο έγγραφο.',
62+
'submit' => 'Μεταφόρτωση Αρχείου(ων)',
63+
],
64+
'list-page-title' => 'Έγγραφα LaTeX',
65+
'view-page-title' => 'Προβολή Εγγράφου',
66+
'edit-page-title' => 'Επεξεργασία Εγγράφου',
67+
],
68+
];

resources/lang/en/filament-latex.php

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
3+
return [
4+
/*
5+
|--------------------------------------------------------------------------
6+
| Form Fields
7+
|--------------------------------------------------------------------------
8+
*/
9+
10+
'field' => [
11+
'name' => 'Document Title',
12+
'deadline' => 'Deadline',
13+
'author_id' => 'Author',
14+
'collaborators_id' => 'Collaborators',
15+
],
16+
17+
/*
18+
|--------------------------------------------------------------------------
19+
| Table Columns
20+
|--------------------------------------------------------------------------
21+
*/
22+
'column' => [
23+
'id' => 'ID',
24+
'name' => 'Document Title',
25+
'deadline' => 'Deadline',
26+
'created_at' => 'Created At',
27+
'author_avatar' => 'Author',
28+
'collaborators_avatars' => 'Collaborators',
29+
'author' => [
30+
'name' => 'Author',
31+
],
32+
'collaborators' => 'Collaborators',
33+
'updated_at' => 'Last Updated',
34+
],
35+
36+
/*
37+
|--------------------------------------------------------------------------
38+
| LaTeX Page Labels
39+
|--------------------------------------------------------------------------
40+
*/
41+
'page' => [
42+
'download.tooltip' => 'Download PDF',
43+
'compile' => [
44+
'action' => 'Compile LaTeX',
45+
'success-title' => 'Document compiled successfully!',
46+
'success-body' => 'The document was compiled successfully.',
47+
'error-title' => 'Compilation Error.',
48+
'error-body' => 'There was an error compiling the document.',
49+
],
50+
'create' => [
51+
'title' => 'Create Document',
52+
'notification' => 'Document created successfully!',
53+
'button' => 'Create Document',
54+
],
55+
56+
// Refers to the file upload action
57+
'file-upload' => [
58+
'title' => 'Upload Files',
59+
'icon' => 'heroicon-o-document-arrow-up',
60+
'heading' => 'Upload Files',
61+
'description' => 'Upload files to attach to the document.',
62+
'submit' => 'Upload File(s)',
63+
],
64+
'list-page-title' => 'LaTeX Documents',
65+
'view-page-title' => 'View Document',
66+
'edit-page-title' => 'Edit Document',
67+
],
68+
];

resources/lang/en/latex.php

Lines changed: 0 additions & 6 deletions
This file was deleted.

resources/lang/nl/filament-latex.php

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
3+
return [
4+
/*
5+
|--------------------------------------------------------------------------
6+
| Form Fields
7+
|--------------------------------------------------------------------------
8+
*/
9+
10+
'field' => [
11+
'name' => 'Documenttitel',
12+
'deadline' => 'Deadline',
13+
'author_id' => 'Auteur',
14+
'collaborators_id' => 'Deelnemers',
15+
],
16+
17+
/*
18+
|--------------------------------------------------------------------------
19+
| Table Columns
20+
|--------------------------------------------------------------------------
21+
*/
22+
'column' => [
23+
'id' => 'ID',
24+
'name' => 'Documenttitel',
25+
'deadline' => 'Deadline',
26+
'created_at' => 'Aangemaakt op',
27+
'author_avatar' => 'Auteur',
28+
'collaborators_avatars' => 'Deelnemers',
29+
'author' => [
30+
'name' => 'Auteur',
31+
],
32+
'collaborators' => 'Medewerkers',
33+
'updated_at' => 'Laatst bijgewerkt',
34+
],
35+
36+
/*
37+
|--------------------------------------------------------------------------
38+
| LaTeX Page Labels
39+
|--------------------------------------------------------------------------
40+
*/
41+
'page' => [
42+
'download.tooltip' => 'PDF Downloaden',
43+
'compile' => [
44+
'action' => 'Compile LaTeX',
45+
'success-title' => 'Document succesvol gecompileerd!',
46+
'success-body' => 'Het document is succesvol gecompileerd.',
47+
'error-title' => 'Compilatiefout.',
48+
'error-body' => 'Er is een fout opgetreden bij het compileren van het document.',
49+
],
50+
'create' => [
51+
'title' => 'Document aanmaken',
52+
'notification' => 'Document succesvol aangemaakt!',
53+
'button' => 'Document aanmaken',
54+
],
55+
56+
// Refers to the file upload action
57+
'file-upload' => [
58+
'title' => 'Bestanden uploaden',
59+
'icon' => 'heroicon-o-document-arrow-up',
60+
'heading' => 'Bestanden uploaden',
61+
'description' => 'Upload bestanden om aan het document toe te voegen.',
62+
'submit' => 'Bestand(en) uploaden',
63+
],
64+
'list-page-title' => 'LaTeX-documenten',
65+
'view-page-title' => 'Document bekijken',
66+
'edit-page-title' => 'Document bewerken',
67+
],
68+
];

src/Concerns/CanUploadFiles.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@ trait CanUploadFiles
1515
public function uploadAction(): Action
1616
{
1717
return Action::make('upload')
18+
->requiresConfirmation()
19+
->label(__('filament-latex::filament-latex.page.file-upload.title'))
20+
->modalIcon(__('filament-latex::filament-latex.page.file-upload.icon'))
21+
->modalHeading(__('filament-latex::filament-latex.page.file-upload.heading'))
22+
->modalDescription(__('filament-latex::filament-latex.page.file-upload.description'))
23+
->modalSubmitActionLabel(__('filament-latex::filament-latex.page.file-upload.submit'))
1824
->color('success')
19-
->label('Upload Files')
2025
->icon('heroicon-o-document-arrow-up')
21-
->requiresConfirmation()
2226
->extraAttributes([
2327
'class' => 'w-full',
2428
])

src/Concerns/CanUseDocument.php

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -84,37 +84,25 @@ public function compileDocument(): void
8484
// Run the pdflatex command
8585
$result = Process::timeout(config('filament-latex.compilation-timeout'))->run($command);
8686

87-
if ($result->failed()) {
87+
// Mimic grep behavior to check for specific LaTeX errors
88+
$output = $result->output();
89+
$errorPattern = '/^!.*$/m'; // Match lines starting with '!'
90+
if (preg_match($errorPattern, $output) || $result->failed()) {
8891
Notification::make()
89-
->title('Compilation Error')
92+
->title(__('filament-latex::filament-latex.page.compile.error-title'))
9093
->color('danger')
91-
->body('There was an error compiling the document.')
94+
->body(__('filament-latex::filament-latex.page.compile.error-body'))
9295
->send();
9396

9497
Log::error('LaTeX compilation failed:', [
9598
'output' => $result->output(),
9699
'error' => $result->errorOutput(),
97100
]);
98-
99-
return;
100-
}
101-
102-
// Mimic grep behavior to check for specific LaTeX errors
103-
$output = $result->output();
104-
$errorPattern = '/^!.*$/m'; // Match lines starting with '!'
105-
if (preg_match($errorPattern, $output)) {
106-
Notification::make()
107-
->title('Compilation Error')
108-
->color('danger')
109-
->body('Errors were found in the LaTeX compilation output.')
110-
->send();
111-
112-
Log::info('Filtered LaTeX errors:', ['errors' => $output]);
113101
} else {
114102
Notification::make()
115-
->title('Compilation Success')
103+
->title(__('filament-latex::filament-latex.page.compile.success-title'))
116104
->color('success')
117-
->body('The document was compiled successfully.')
105+
->body(__('filament-latex::filament-latex.page.compile.success-body'))
118106
->send();
119107

120108
$this->dispatch('document-compiled');

src/Concerns/Utils.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,20 @@ public function getStorage(): Filesystem
4343
*/
4444
public function canDeleteFile(array $arguments): bool
4545
{
46-
$texFiles = collect($this->getFiles())->filter(fn ($file) => Str::endsWith($file, '.tex'));
47-
if ($texFiles->count() === 1) {
48-
Notification::make()
49-
->title('You cannot delete the only ".tex" file in the project.')
50-
->color('danger')
51-
->send();
52-
53-
return false;
54-
} else {
46+
if (! Str::endsWith($arguments['file'], '.tex')) {
5547
return $this->getStorage()->delete($this->filamentLatex->id . '/files/' . $arguments['file']);
48+
} else {
49+
$texFiles = collect($this->getFiles())->filter(fn ($file) => Str::endsWith($file, '.tex'));
50+
if ($texFiles->count() === 1) {
51+
Notification::make()
52+
->title('You cannot delete the only ".tex" file in the project.')
53+
->color('danger')
54+
->send();
55+
56+
return false;
57+
} else {
58+
return $this->getStorage()->delete($this->filamentLatex->id . '/files/' . $arguments['file']);
59+
}
5660
}
5761
}
5862

0 commit comments

Comments
 (0)