andreazorzi/laravel-tolgee-translator

Integrate Tolgee with your Laravel project

1.0.4 2025-03-28 09:22 UTC

This package is auto-updated.

Last update: 2025-04-28 09:33:04 UTC


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')),

/*
 * 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 />