Skip to content

Commit

Permalink
documentation updated to explain steps for changing drivers - solves …
Browse files Browse the repository at this point in the history
…issue #228 (#234)

* documentation updated to explain steps for changing drivers

* Update prompts on sync command

* Update readme

* Update readme

Co-authored-by: Joe Dixon <[email protected]>
  • Loading branch information
Atif-Bashir-1998 and joedixon authored Aug 30, 2022
1 parent f5815bc commit 7015d2a
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 35 deletions.
22 changes: 22 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,28 @@ change any code in your application. It's a like for like swap.
To utilise the database driver, make sure to update the database table names in
the configuration file and run the migrations.

#### Changing Drivers from File (default) to Database

1. Update the driver to use database in `./config/translation.php`.

```php
'driver' => 'database'
```

2. Run the migration to add translations and languages tables.

```shell
php artisan migrate
```

3. Run the following command and folow the prompts to synchronise the translations between drivers.

```shell
php artisan translation:sync-translations
```

4. A few questions will be prompted which have to be answered. See the screenshot below:

### User interface
Navigate to http://your-project.test/languages (update `languages` to match the
`translation.ui_url` configuration setting) and use the interface to manage
Expand Down
5 changes: 0 additions & 5 deletions resources/lang/de/translation.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,8 @@
'single' => 'single',
'value' => 'Wert',
'namespace' => 'Namespace',
'prompt_from_driver' => 'Von welchem Treiber möchten Sie Übersetzungen übernehmen?',
'prompt_to_driver' => 'Zu welchem Treiber möchten Sie die Übersetzungen hinzufügen?',
'prompt_language_if_any' => 'Welche Sprache? (leer lassen für alle) ',
'synchronisieren' => 'Übersetzungen synchronisieren ⏳',
'synced' => 'Übersetzungen wurden synchronisiert 😎',
'invalid_driver' => 'Ungültiger Treiber',
'invalid_language' => 'Ungültige Sprache',
'add_translation' => 'Übersetzung hinzufügen',
'translation_added' => 'Neue Übersetzung erfolgreich hinzugefügt 🙌',
'namespace_label' => 'Namespace (optional)',
Expand Down
7 changes: 0 additions & 7 deletions resources/lang/en/translation.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,6 @@
'single' => 'Single',
'value' => 'Value',
'namespace' => 'Namespace',
'prompt_from_driver' => 'Which driver would you like to take translations from?',
'prompt_to_driver' => 'Which driver would you like to add the translations to?',
'prompt_language_if_any' => 'Which language? (leave blank for all)',
'syncing' => 'Syncing translations ⏳',
'synced' => 'Translations have been synced 😎',
'invalid_driver' => 'Invalid driver',
'invalid_language' => 'Invalid language',
'add_translation' => 'Add a translation',
'translation_added' => 'New translation added successfull 🙌',
'namespace_label' => 'Namespace (Optional)',
Expand Down
7 changes: 0 additions & 7 deletions resources/lang/fr/translation.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
'group_label' => 'Groupe (Optionnel)',
'group_placeholder' => 'Ex: validation',
'group_single' => 'Groupe / Unique',
'invalid_driver' => 'Driver invalide',
'invalid_language' => 'Langue invalide',
'key' => 'Clé',
'key_label' => 'Clé',
'key_placeholder' => 'Par exemple : invalid_key',
Expand All @@ -28,19 +26,14 @@
'namespace_placeholder' => 'Par exemple : my_package',
'no_missing_keys' => 'Il ne manque aucune clé de traduction dans l\'application 🎉',
'prompt_file' => 'Dans quel fichier sera t\'elle stockée ?',
'prompt_from_driver' => 'De quel driver voudriez-vous prendre les traductions ?',
'prompt_key' => 'Quelle est la clé de cette traduction ?',
'prompt_language' => 'Entrez le code langue que vous aimeriez ajouter (Ex: fr)',
'prompt_language_for_key' => 'Entrez la langue pour la clé (Ex: fr)',
'prompt_language_if_any' => 'Quelle langue ? (Laissez vide pour tous)',
'prompt_to_driver' => 'À quel driver désirez-vous ajouter les traductions ?',
'prompt_type' => 'Est-ce une clé Json ou Array ?',
'prompt_value' => 'Quelle est la valeur de la traduction',
'save' => 'Sauvegarder',
'search' => 'Rechercher toutes les traductions',
'single' => 'Unique',
'synced' => 'Les traductions sont synchronisées 😎',
'syncing' => 'Synchronisation des traductions ⏳',
'translation_added' => 'Nouvelle traduction ajoutée avec succès 🙌',
'translations' => 'Traduction',
'type' => 'Type',
Expand Down
7 changes: 0 additions & 7 deletions resources/lang/nl/translation.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,6 @@
'single' => 'Enkelvoudig',
'value' => 'Waarde',
'namespace' => 'Namespace',
'prompt_from_driver' => 'Van welke driver wilt u vertalingen meenemen?',
'prompt_to_driver' => 'Aan welke driver wilt u de vertalingen toevoegen?',
'prompt_language_if_any' => 'Welke taal? (laat leeg voor alle)',
'syncing' => 'Vertaling synchroniseren ⏳',
'synced' => 'Vertalingen zijn gesynchroniseerd 😎',
'invalid_driver' => 'Ongeldige driver',
'invalid_language' => 'Ongeldige taal',
'add_translation' => 'Voeg een vertaling toe',
'translation_added' => 'Nieuwe vertaling succesvol toegevoegd 🙌',
'namespace_label' => 'Namespace (optioneel)',
Expand Down
18 changes: 9 additions & 9 deletions src/Console/Commands/SynchroniseTranslationsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ public function handle()

// When the from driver will be entered manually or if the argument is invalid.
else {
$this->fromDriver = $this->anticipate(__('translation::translation.prompt_from_driver'), $this->drivers);
$this->fromDriver = $this->anticipate('Which driver would you like to take translations from?', $this->drivers);

if (! in_array($this->fromDriver, $this->drivers)) {
return $this->error(__('translation::translation.invalid_driver'));
return $this->error('Invalid driver');
}
}

Expand All @@ -101,10 +101,10 @@ public function handle()

// When the to driver will be entered manually.
else {
$this->toDriver = $this->anticipate(__('translation::translation.prompt_to_driver'), $this->drivers);
$this->toDriver = $this->anticipate('Which driver would you like to add the translations to?', $this->drivers);

if (! in_array($this->toDriver, $this->drivers)) {
return $this->error(__('translation::translation.invalid_driver'));
return $this->error('Invalid driver');
}
}

Expand All @@ -122,18 +122,18 @@ public function handle()
elseif (in_array($this->argument('language'), $languages)) {
$language = $this->argument('language');
} else {
return $this->error(__('translation::translation.invalid_language'));
return $this->error('Invalid language');
}
} // When the language will be entered manually or if the argument is invalid.
else {
$language = $this->anticipate(__('translation::translation.prompt_language_if_any'), $languages);
$language = $this->anticipate('Which language? (leave blank for all)', $languages);

if ($language && ! in_array($language, $languages)) {
return $this->error(__('translation::translation.invalid_language'));
return $this->error('Invalid language');
}
}

$this->line(__('translation::translation.syncing'));
$this->line('Syncing translations');

// If a specific language is set.
if ($language) {
Expand All @@ -143,7 +143,7 @@ public function handle()
$translations = $this->mergeLanguages($this->toDriver, $this->fromDriver->allTranslations());
}

$this->info(__('translation::translation.synced'));
$this->info('Translations have been synced');
}

private function createDriver($driver)
Expand Down

0 comments on commit 7015d2a

Please sign in to comment.