Skip to content

Commit

Permalink
small translation tweaks added
Browse files Browse the repository at this point in the history
  • Loading branch information
Martijn Wagena committed Aug 6, 2024
1 parent a6d41aa commit 9369c68
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions resources/lang/en/filament-deepl-translations.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
'modal_title' => 'Translate with DeepL',
'source' => 'Source Language',
'active_locale' => 'Current language',
'original_field' => 'Original field: :field',
'translated_field' => 'Translated field: :field',
'success_title' => 'Success!',
'success_message' => 'Content has been translated successfully.',
'error_title' => 'Error!',
Expand Down
3 changes: 3 additions & 0 deletions resources/lang/nl/filament-deepl-translations.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
'translate' => 'Vertalen',
'modal_title' => 'Vertalen met DeepL',
'source' => 'Originele taal',
'active_locale' => 'Huidige taal',
'original_field' => 'Originele veld: :field',
'translated_field' => 'Vertaalde veld: :field',
'success_title' => 'Success!',
'success_message' => 'Content is vertaald.',
'error_title' => 'Error!',
Expand Down
10 changes: 8 additions & 2 deletions src/Actions/DeeplTranslatableAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,21 @@ function (Field $component, $livewire) use ($langs) {
$result = $translator->translateText(
$sourceText,
$get('source'),
$activeLocale === 'en' ? 'en-US' : $activeLocale
$activeLocale === 'en' ? 'en-US' : $activeLocale,
[
'tag_handling' => 'html',
]
);

$set($fieldName.'_translated', $result->text);
}),

($component::class)::make($fieldName.'_original')
->label(__('filament-deepl-translations::filament-deepl-translations.original_field', ['field' => __($fieldName)]))
->disabled()
->live(),
($component::class)::make($fieldName.'_translated'),
($component::class)::make($fieldName.'_translated')
->label(__('filament-deepl-translations::filament-deepl-translations.translated_field', ['field' => __($fieldName)])),
])
->action(function (array $data) use ($component, $fieldName): void {
$component->state($data[$fieldName.'_translated']);
Expand Down

0 comments on commit 9369c68

Please sign in to comment.