Skip to content

Commit 7015d2a

Browse files
documentation updated to explain steps for changing drivers - solves 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]>
1 parent f5815bc commit 7015d2a

File tree

6 files changed

+31
-35
lines changed

6 files changed

+31
-35
lines changed

readme.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,28 @@ change any code in your application. It's a like for like swap.
128128
To utilise the database driver, make sure to update the database table names in
129129
the configuration file and run the migrations.
130130

131+
#### Changing Drivers from File (default) to Database
132+
133+
1. Update the driver to use database in `./config/translation.php`.
134+
135+
```php
136+
'driver' => 'database'
137+
```
138+
139+
2. Run the migration to add translations and languages tables.
140+
141+
```shell
142+
php artisan migrate
143+
```
144+
145+
3. Run the following command and folow the prompts to synchronise the translations between drivers.
146+
147+
```shell
148+
php artisan translation:sync-translations
149+
```
150+
151+
4. A few questions will be prompted which have to be answered. See the screenshot below:
152+
131153
### User interface
132154
Navigate to http://your-project.test/languages (update `languages` to match the
133155
`translation.ui_url` configuration setting) and use the interface to manage

resources/lang/de/translation.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,8 @@
3131
'single' => 'single',
3232
'value' => 'Wert',
3333
'namespace' => 'Namespace',
34-
'prompt_from_driver' => 'Von welchem Treiber möchten Sie Übersetzungen übernehmen?',
35-
'prompt_to_driver' => 'Zu welchem Treiber möchten Sie die Übersetzungen hinzufügen?',
36-
'prompt_language_if_any' => 'Welche Sprache? (leer lassen für alle) ',
3734
'synchronisieren' => 'Übersetzungen synchronisieren ⏳',
3835
'synced' => 'Übersetzungen wurden synchronisiert 😎',
39-
'invalid_driver' => 'Ungültiger Treiber',
40-
'invalid_language' => 'Ungültige Sprache',
4136
'add_translation' => 'Übersetzung hinzufügen',
4237
'translation_added' => 'Neue Übersetzung erfolgreich hinzugefügt 🙌',
4338
'namespace_label' => 'Namespace (optional)',

resources/lang/en/translation.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@
3131
'single' => 'Single',
3232
'value' => 'Value',
3333
'namespace' => 'Namespace',
34-
'prompt_from_driver' => 'Which driver would you like to take translations from?',
35-
'prompt_to_driver' => 'Which driver would you like to add the translations to?',
36-
'prompt_language_if_any' => 'Which language? (leave blank for all)',
37-
'syncing' => 'Syncing translations ⏳',
38-
'synced' => 'Translations have been synced 😎',
39-
'invalid_driver' => 'Invalid driver',
40-
'invalid_language' => 'Invalid language',
4134
'add_translation' => 'Add a translation',
4235
'translation_added' => 'New translation added successfull 🙌',
4336
'namespace_label' => 'Namespace (Optional)',

resources/lang/fr/translation.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
'group_label' => 'Groupe (Optionnel)',
1111
'group_placeholder' => 'Ex: validation',
1212
'group_single' => 'Groupe / Unique',
13-
'invalid_driver' => 'Driver invalide',
14-
'invalid_language' => 'Langue invalide',
1513
'key' => 'Clé',
1614
'key_label' => 'Clé',
1715
'key_placeholder' => 'Par exemple : invalid_key',
@@ -28,19 +26,14 @@
2826
'namespace_placeholder' => 'Par exemple : my_package',
2927
'no_missing_keys' => 'Il ne manque aucune clé de traduction dans l\'application 🎉',
3028
'prompt_file' => 'Dans quel fichier sera t\'elle stockée ?',
31-
'prompt_from_driver' => 'De quel driver voudriez-vous prendre les traductions ?',
3229
'prompt_key' => 'Quelle est la clé de cette traduction ?',
3330
'prompt_language' => 'Entrez le code langue que vous aimeriez ajouter (Ex: fr)',
3431
'prompt_language_for_key' => 'Entrez la langue pour la clé (Ex: fr)',
35-
'prompt_language_if_any' => 'Quelle langue ? (Laissez vide pour tous)',
36-
'prompt_to_driver' => 'À quel driver désirez-vous ajouter les traductions ?',
3732
'prompt_type' => 'Est-ce une clé Json ou Array ?',
3833
'prompt_value' => 'Quelle est la valeur de la traduction',
3934
'save' => 'Sauvegarder',
4035
'search' => 'Rechercher toutes les traductions',
4136
'single' => 'Unique',
42-
'synced' => 'Les traductions sont synchronisées 😎',
43-
'syncing' => 'Synchronisation des traductions ⏳',
4437
'translation_added' => 'Nouvelle traduction ajoutée avec succès 🙌',
4538
'translations' => 'Traduction',
4639
'type' => 'Type',

resources/lang/nl/translation.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@
3131
'single' => 'Enkelvoudig',
3232
'value' => 'Waarde',
3333
'namespace' => 'Namespace',
34-
'prompt_from_driver' => 'Van welke driver wilt u vertalingen meenemen?',
35-
'prompt_to_driver' => 'Aan welke driver wilt u de vertalingen toevoegen?',
36-
'prompt_language_if_any' => 'Welke taal? (laat leeg voor alle)',
37-
'syncing' => 'Vertaling synchroniseren ⏳',
38-
'synced' => 'Vertalingen zijn gesynchroniseerd 😎',
39-
'invalid_driver' => 'Ongeldige driver',
40-
'invalid_language' => 'Ongeldige taal',
4134
'add_translation' => 'Voeg een vertaling toe',
4235
'translation_added' => 'Nieuwe vertaling succesvol toegevoegd 🙌',
4336
'namespace_label' => 'Namespace (optioneel)',

src/Console/Commands/SynchroniseTranslationsCommand.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ public function handle()
8484

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

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

@@ -101,10 +101,10 @@ public function handle()
101101

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

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

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

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

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

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

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

149149
private function createDriver($driver)

0 commit comments

Comments
 (0)