PHP code example of nicolae-soitu / filament-translations
1. Go to this page and download the library: Download nicolae-soitu/filament-translations library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nicolae-soitu / filament-translations example snippets
/*
|--------------------------------------------------------------------------
|
| Translate only empty words.
|
*/
'only_empty_words' => true,
/*
|--------------------------------------------------------------------------
|
| Default locale for translation.
|
*/
'default_locale_for_translation' => 'en',
/*
|--------------------------------------------------------------------------
|
| Translators.
|
*/
'translators' => [
'google' => [
'allowed' => true,
'handler' => TomatoPhp\FilamentTranslations\Translators\Google\GoogleTranslator::class,
'chunk_size' => 100,
],
'openai' => [
'allowed' => true,
'handler' => \TomatoPhp\FilamentTranslations\Translators\Openai\OpenaiTranslator::class,
'chunk_size' => 50,
'model' => 'gpt-3.5-turbo',
'system_prompt' => 'You are a translator. Your job is to translate the following json object to the language specified in the prompt.',
'user_prompt' => 'Translate the following json object from :from to :language, ensuring you return only the translated content in JSON format without added quotes or any other extraneous details and dont change the keys. Importantly, any word prefixed with the symbol ":" should remain unchanged and should not be translated the key "context" should be used to understand the meaning of the phrase',
],
],
use TomatoPhp\FilamentTranslations\Filament\Resources\TranslationResource\Table\TranslationTable;
public function boot()
{
TranslationTable::register([
\Filament\Tables\Columns\TextColumn::make('something')
]);
}
use TomatoPhp\FilamentTranslations\Filament\Resources\TranslationResource\Table\TranslationActions;
public function boot()
{
TranslationActions::register([
\Filament\Tables\Actions\ReplicateAction::make()
]);
}
use TomatoPhp\FilamentTranslations\Filament\Resources\TranslationResource\Table\TranslationFilters;
public function boot()
{
TranslationFilters::register([
\Filament\Tables\Filters\SelectFilter::make('something')
]);
}
use TomatoPhp\FilamentTranslations\Filament\Resources\TranslationResource\Table\TranslationBulkActions;
public function boot()
{
TranslationBulkActions::register([
\Filament\Tables\BulkActions\DeleteAction::make()
]);
}
use TomatoPhp\FilamentTranslations\Filament\Resources\TranslationResource\Form\TranslationForm;
public function boot()
{
TranslationForm::register([
\Filament\Forms\Components\TextInput::make('something')
]);
}
use TomatoPhp\FilamentTranslations\Filament\Resources\TranslationResource\Actions\ManagePageActions;
use TomatoPhp\FilamentTranslations\Filament\Resources\TranslationResource\Actions\EditPageActions;
use TomatoPhp\FilamentTranslations\Filament\Resources\TranslationResource\Actions\ViewPageActions;
use TomatoPhp\FilamentTranslations\Filament\Resources\TranslationResource\Actions\CreatePageActions;
public function boot()
{
ManagePageActions::register([
Filament\Actions\Action::make('action')
]);
EditPageActions::register([
Filament\Actions\Action::make('action')
]);
ViewPageActions::register([
Filament\Actions\Action::make('action')
]);
CreatePageActions::register([
Filament\Actions\Action::make('action')
]);
}