samehdoush / laravel-translations-api
无需 UI 且通过 API 链接管理 Laravel 中的翻译
v0.0.3
2023-07-20 19:28 UTC
Requires
- php: ^8.1
- illuminate/contracts: ^10.0
- spatie/laravel-package-tools: ^1.14.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.9
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.0
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
This package is auto-updated.
Last update: 2024-09-20 12:16:48 UTC
README
简单且开发者友好,易于翻译管理和提高能力
支持我们
我们投入了大量资源创建 一流的开放源代码包。您可以通过 购买我们的付费产品之一 来支持我们。
我们非常感谢您从家乡给我们寄明信片,并说明您正在使用我们的哪个包。您可以在 我们的联系页面 上找到我们的地址。我们将所有收到的明信片发布在 我们的虚拟明信片墙上。
安装
您可以通过 composer 安装此包
composer require samehdoush/laravel-translations-api
自动安装
php artisan translations-api:install
或者
您可以使用以下命令发布和运行迁移
php artisan vendor:publish --tag="translations-api-migrations"
php artisan migrate
您可以使用以下命令发布配置文件
php artisan vendor:publish --tag="translations-api-config"
这是已发布配置文件的内容
return [ /* |-------------------------------------------------------------------------- | Source Language |-------------------------------------------------------------------------- | | This is the language that will be used as the source language for | the translations. This language will be used to import the | translations from the files. | */ 'source_language' => env('TRANSLATIONS_SOURCE_LANGUAGE', 'en'), /* * Language lines will be fetched by these loaders. You can put any class here that implements * the Samehdoush\LaravelTranslationsApi\TranslationLoaders\TranslationLoader-interface. */ 'translation_loaders' => [ Samehdoush\LaravelTranslationsApi\TranslationLoaders\Db::class, ], /* * This is the model used by the Db Translation loader. You can put any model here * that extends Samehdoush\LaravelTranslationsApi\Models\Phrase. */ 'model' => Samehdoush\LaravelTranslationsApi\Models\Phrase::class, /* * This is the translation manager which overrides the default Laravel `translation.loader` */ 'translation_manager' => Samehdoush\LaravelTranslationsApi\TranslationLoaderManager::class, /* |-------------------------------------------------------------------------- | Exclude Files |-------------------------------------------------------------------------- | | The following files will be ignored during the import process. | and those files will be ignored in every language. | */ 'exclude_files' => [ //'validation.php', // Exclude default validation for example. ], /* |-------------------------------------------------------------------------- | Laravel Translations Path |-------------------------------------------------------------------------- | | The default is `translations` but you can change it to whatever works best and | doesn't conflict with the routing in your application. | */ 'route_prefix' => env('TRANSLATIONS_PATH', 'translations'), /* |-------------------------------------------------------------------------- | Laravel Translations route middleware |-------------------------------------------------------------------------- | | These middleware will be assigned to every Laravel Translations route, giving you | the chance to add your own middleware to this list or change any of | the existing middleware. Or, you can simply stick with this list. | */ 'middleware' => ['api', 'auth:sanctum'], /* |-------------------------------------------------------------------------- | Database Connection |-------------------------------------------------------------------------- | | The database connection that should be used to store the imported | translations You may specify the connection as a string | which is the name of the connection in the database.php file | */ 'database_connection' => env('TRANSLATIONS_DB_CONNECTION', null), ];
用法
要导入您的翻译,请运行以下命令
php artisan translations:import
要导入并覆盖所有之前的翻译,请使用以下命令
php artisan translations:import --fresh
导出翻译
要导出您的翻译,请运行以下命令
php artisan translations:export
获取翻译
/api/translations GET METHOD return [ [ 'installed' => boolean, 'translations' => Object, ] ]
删除翻译
/api/translations/delete/{translation} DELETE METHOD
获取进度翻译
/api/translations/{translation}/progress GET METHOD return [ [ 'percentage' => float, ]
创建新的源键
/api/translations/createSourceKey POST METHOD Body : [ 'key' => 'required', 'file' => 'required', 'key_translation' => 'required', ]
创建新的翻译
/api/translations/createTranslation POST METHOD Body : [ 'language' => 'required|exists:ltu_languages,id', ]
获取短语
/api/translations/phrases/{translation} GET METHOD RETURN : [ 'phrases' => Object, ]
显示短语
/api/translations/phrases/{translation}/edit/{phrase:uuid} GET METHOD RETURN : [ 'phrase' => Object, 'translation' => Object, ]
更新短语
/api/translations/phrases/{translation}/edit/{phrase:uuid} put METHOD BODY : [ 'value' => 'required', ]
删除短语
/api/translations/phrases/{translation}/delete/{phrase:uuid} delete METHOD
变更日志
请参阅 变更日志 了解最近更改的详细信息。
贡献
请参阅 贡献指南 了解详细信息。
安全漏洞
请参阅 我们的安全策略 了解如何报告安全漏洞。
致谢
许可
MIT 许可证 (MIT)。有关更多信息,请参阅 许可文件。