定制 andreazorzi/laravel-tolgee-translator 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

andreazorzi/laravel-tolgee-translator

最新稳定版本:1.0.6

Composer 安装命令:

composer require andreazorzi/laravel-tolgee-translator

包简介

Integrate Tolgee with your Laravel project

README 文档

README

logo

Laravel Tolgee Translator

Latest Version on Packagist Total Downloads

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

logo

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

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-21