diff --git a/readme.md b/readme.md index 7aa68aae..18500457 100644 --- a/readme.md +++ b/readme.md @@ -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 diff --git a/resources/lang/de/translation.php b/resources/lang/de/translation.php index 9fe7a8af..02ea8368 100644 --- a/resources/lang/de/translation.php +++ b/resources/lang/de/translation.php @@ -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)', diff --git a/resources/lang/en/translation.php b/resources/lang/en/translation.php index f37eff9f..d933a573 100644 --- a/resources/lang/en/translation.php +++ b/resources/lang/en/translation.php @@ -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)', diff --git a/resources/lang/fr/translation.php b/resources/lang/fr/translation.php index 462a1deb..efb8a2de 100644 --- a/resources/lang/fr/translation.php +++ b/resources/lang/fr/translation.php @@ -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', @@ -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', diff --git a/resources/lang/nl/translation.php b/resources/lang/nl/translation.php index d839b044..d4ed8290 100644 --- a/resources/lang/nl/translation.php +++ b/resources/lang/nl/translation.php @@ -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)', diff --git a/src/Console/Commands/SynchroniseTranslationsCommand.php b/src/Console/Commands/SynchroniseTranslationsCommand.php index baf2b9e2..7e6d0ab4 100644 --- a/src/Console/Commands/SynchroniseTranslationsCommand.php +++ b/src/Console/Commands/SynchroniseTranslationsCommand.php @@ -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'); } } @@ -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'); } } @@ -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) { @@ -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)