在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):barryvdh/laravel-translation-manager开源软件地址(OpenSource Url):https://github.com/barryvdh/laravel-translation-manager开源编程语言(OpenSource Language):PHP 100.0%开源软件介绍(OpenSource Introduction):Laravel Translation ManagerThis is a package to manage Laravel translation files. It does not replace the Translation system, only import/export the php files to a database and make them editable through a webinterface. The workflow would be:
This way, translations can be saved in git history and no overhead is introduced in production. InstallationRequire this package in your composer.json and run composer update (or run
You need to run the migrations for this package.
You need to publish the config file for this package. This will add the file
In order to edit the default template, the views must be published as well. The views will then be placed in
Routes are added in the ServiceProvider. You can set the group parameters for the routes in the configuration.
You can change the prefix or filter/middleware for the routes. If you want full customisation, you can extend the ServiceProvider and override the This example will make the translation manager available at If you would like to use auto translation using Google Translate API, install https://github.com/tanmuhittin/laravel-google-translate
Middleware / AuthThe configuration file by default only includes the
to
NOTE: This is only needed in Laravel 5.2 (and up!) UsageWeb interfaceWhen you have imported your translation (via buttons or command), you can view them in the webinterface (on the url you defined with the controller). You can click on a translation and an edit field will popup. Just click save and it is saved :) When a translation is not yet created in a different locale, you can also just edit it to create it. Using the buttons on the webinterface, you can import/export the translations. For publishing translations, make sure your application can write to the language directory. You can also use the commands below. Import commandThe import command will search through app/lang and load all strings in the database, so you can easily manage them.
Translation strings from app/lang/locale.json files will be imported to the _json group. Note: By default, only new strings are added. Translations already in the DB are kept the same. If you want to replace all values with the ones from the files,
add the Find translations in sourceThe Find command/button will look search for all php/twig files in the app directory, to see if they contain translation functions, and will try to extract the group/item names. The found keys will be added to the database, so they can be easily translated. This can be done through the webinterface, or via an Artisan command.
If your project uses translation strings as keys, these will be stored into then _json group. Export commandThe export command will write the contents of the database back to app/lang php files. This will overwrite existing translations and remove all comments, so make sure to backup your data before using. Supply the group name to define which groups you want to publish.
For example, To export translation strings as keys to JSON files , use the Clean commandThe clean command will search for all translation that are NULL and delete them, so your interface is a bit cleaner. Note: empty translations are never exported.
Reset commandThe reset command simply clears all translation in the database, so you can start fresh (by a new import). Make sure to export your work if needed before doing this.
Detect missing translationsMost translations can be found by using the Find command (see above), but in case you have dynamic keys (variables/automatic forms etc), it can be helpful to 'listen' to the missing translations.
To detect missing translations, we can swap the Laravel TranslationServiceProvider with a custom provider.
In your
This will extend the Translator and will create a new database entry, whenever a key is not found, so you have to visit the pages that use them. This way it shows up in the webinterface and can be edited and later exported. You shouldn't use this in production, just in development to translate your views, then just switch back. TODOThis package is still very alpha. Few things that are on the todo-list:
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论