laravel-langman
laravel-langman copied to clipboard
Command to synchronize languages (not from views, just between languages)
Say we have for instance the following language files and keys:
lang/en/users.php [ 'name' => 'Name' ]
lang/en/address.php [ 'city' => 'City', 'zip' => 'Zip code' ]
lang/fr/users.php [ 'name' => 'Nom' ]
lang/fr/address.php [ 'city' => 'Ville' ]
lang/de/users.php [ 'name' => 'Name' ]
We need a command which would synchronize all languages with the same keys.
A translator will not have access to php artisan, so the command missing
will not really help in this case.
That command in that example would:
- create the file
lang/de/address.php
with all keys, - add the key
zip
to the filelang/fr/address.php
Of course, that command needs to know which language is our reference (in this example, en
is the reference language), that could be a setting in config for instance and/or could be overridden in the command line.
I think the sync command can include the search for keys that exist in a language bas not in another, currently the missing command does this job.
So you run langman:sync
and it looks into your application files to check for keys that doesn't exist in your language files, and also look into you language files and make sure all keys that exist in a language exists in the other. What do you think?
I think that should be independent. For example, some dynamic keys are not grabbed by the sync command (like my example with enums in another issue). So those keys are not synchronized accross languages.
Additionally, the missing command will prompt me for each message. What if I have 200 messages? I just want to create all files for that new language and send them to the translators who will use a text editor.
Better than empty strings, it would be more useful to have the default language for new keys.
Actually I'm saying that I can move the functionality of syncing keys across language files to the sync command, the sync command won't prompt for translations, that way The translation files will have all the needed keys after the langman:sync
command so that you don't have to run langman:missing
if you don't want.
That would be useful yes.
That new step should include:
- Creating missing keys in all language files
- Make sure the vendor lang folders get synced too
- Creating missing files (even if that file does not contain any message from the views, see example with enums)
That extra step is not connected at all to finding keys in views/app. So I guess you could take my example above as a test case.
Any update about this?
This is now implemented on the master branch, if someone can test and confirm before making a new release I'll be very grateful.