andreazorzi/laravel-tolgee-translator
最新稳定版本:1.0.6
Composer 安装命令:
composer require andreazorzi/laravel-tolgee-translator
包简介
Integrate Tolgee with your Laravel project
README 文档
README
Laravel Tolgee Translator
This package simplifies the integration of Toglee on Laravel by adding commands and blade directives.
Installation
composer require andreazorzi/laravel-tolgee-translator
Getting started
Config
/* * Tolgee service host */ 'host' => env('TOLGEE_HOST', 'https://app.tolgee.io'), /** * Your tolgee api key */ 'api_key' => env('TOLGEE_API_KEY'), /** * Tolgee project id */ 'project_id' => env('TOLGEE_PROJECT_ID'), /** * Default project language */ 'locale' => env('TOLGEE_LOCALE', 'en'), /** * Overwrite base locale translations files. */ 'override' => env('TOLGEE_OVERRIDE', false), /** * Accepted translation states. Check Tolgee documentation for available states. * Ex: REVIEWED,DISABLED,UNTRANSLATED,TRANSLATED */ 'accepted_states' => explode(",", env('TOLGEE_ACCEPTED_STATES', 'REVIEWED')), /** * Files to ignore during sync. */ 'ignore_files' => explode(",", env('TOLGEE_IGNORE_FILES', '')), /* * Set a specific subfolder for language files * Ex: app/lang/{locale}/tolgee -> "tolgee" */ 'lang_subfolder' => env('TOLGEE_LANG_SUBFOLDER'), /* * Set a specific subfolder for language files * Ex: app/lang/{locale}/tolgee -> "tolgee" */ 'sync_on_production' => env('TOLGEE_SYNC_ON_PRODUCTION', false),
Commands
Export Keys
php artisan tolgee:export-keys
Export all project translations keys and save them into tolgee project, existing keys will not be overwritten.
Delete Keys
php artisan tolgee:delete-keys
Delete all keys from the tolgee project.
Sync Translations
php artisan tolgee:sync-translations
Sync the translations from Tolgee to your local project
Usage
To insert the translation into your project blade you can use the blade directive @tolgee($key)
@tolgee('pages.index.title')
If you want you can also get the translation by calling the the helper tolgee($key)
tolgee('pages.index.title');
Those methods return the string on production environment and a html string on local environment. The html string provide a direct link to the tolgee translation
Sync Button
It is possible to insert a button to update translations directly on the page under testing
<x-tolgee::sync-translations />
统计信息
- 总下载量: 880
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-03-21

