samehdoush/laravel-translations-api
Composer 安装命令:
composer require samehdoush/laravel-translations-api
包简介
Manage translations in laravel without ui and via api links
关键字:
README 文档
README
Simple and developer friendly for easy translation management and higher capabilities
Support us
We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.
Installation
You can install the package via composer:
composer require samehdoush/laravel-translations-api
Auto install
php artisan translations-api:install
OR
You can publish and run the migrations with:
php artisan vendor:publish --tag="translations-api-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="translations-api-config"
This is the contents of the published config file:
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), ];
Usage
To import your translations, run the following command:
php artisan translations:import
To import and overwrite all previous translations, use the following command:
php artisan translations:import --fresh
Exporting Translations
To export your translations, run the following command:
php artisan translations:export
Get translations
/api/translations GET METHOD return [ [ 'installed' => boolean, 'translations' => Object, ] ]
delete translation
/api/translations/delete/{translation} DELETE METHOD
get progress translation
/api/translations/{translation}/progress GET METHOD
return [
[
'percentage' => float,
]
create new Source key
/api/translations/createSourceKey POST METHOD Body : [ 'key' => 'required', 'file' => 'required', 'key_translation' => 'required', ]
create new Translation
/api/translations/createTranslation POST METHOD Body : [ 'language' => 'required|exists:ltu_languages,id', ]
GET phrases
/api/translations/phrases/{translation} GET METHOD
RETURN : [
'phrases' => Object,
]
show phrase
/api/translations/phrases/{translation}/edit/{phrase:uuid} GET METHOD
RETURN : [
'phrase' => Object,
'translation' => Object,
]
update phrase
/api/translations/phrases/{translation}/edit/{phrase:uuid} put METHOD
BODY : [
'value' => 'required',
]
DELETE phrase
/api/translations/phrases/{translation}/delete/{phrase:uuid} delete METHOD
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
samehdoush/laravel-translations-api 适用场景与选型建议
samehdoush/laravel-translations-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 151 次下载、GitHub Stars 达 3, 最近一次更新时间为 2023 年 07 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「translations」 「laravel」 「localization」 「translation-manager」 「samehdoush」 「laravel-translations-api」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 samehdoush/laravel-translations-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 samehdoush/laravel-translations-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 samehdoush/laravel-translations-api 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Package for convenient work with Laravel's localization features
Field for number with restricted count of digits and decimal places
Deepl Automated translations for Laravel lang files
Adds support for dynamic translations from Google Spreadsheets.
A Laravel package for multilingual models
Adds localization support to laravel applications in an easy way using Poedit and GNU gettext.
统计信息
- 总下载量: 151
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-07-15