Download the PHP package darvis/laravel-google-translate without Composer
On this page you can find all versions of the php package darvis/laravel-google-translate. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download darvis/laravel-google-translate
More information about darvis/laravel-google-translate
Files in darvis/laravel-google-translate
Download darvis/laravel-google-translate
More information about darvis/laravel-google-translate
Files in darvis/laravel-google-translate
Vendor darvis
Package laravel-google-translate
Short Description Google Translate integration for Laravel with support for translatable models
License MIT
Homepage https://github.com/darvis/laravel-google-translate
Package laravel-google-translate
Short Description Google Translate integration for Laravel with support for translatable models
License MIT
Homepage https://github.com/darvis/laravel-google-translate
Please rate this library. Is it a good library?
Informations about the package laravel-google-translate
Laravel Google Translate
Google Translate integration for Laravel with support for translatable Eloquent models.
Features
- 🌍 Simple Translation API - Translate text and HTML content
- 📦 Model Trait - Easy integration with Eloquent models
- 🔄 Batch Translation - Translate multiple texts at once
- 📝 HTML Support - Preserve HTML tags during translation
- ⚙️ Configurable - Customize source and target locales
Requirements
- PHP 8.2+
- Laravel 11.x, 12.x, or 13.x
- Google Cloud Translation API key
Installation
Install the package via Composer:
Publish the configuration file:
Add your Google Translate API key to your .env file:
Usage
Basic Translation
Model Integration
Add the HasGoogleTranslate trait to your Eloquent model:
Creating Translations
Filling Missing Translations
Finding Missing Translations
Scopes
Configuration
Database Structure
Your translatable models should have:
localecolumn (string) - The language code (e.g., 'nl', 'en')pidcolumn (nullable integer) - Parent ID pointing to the source item
Example migration:
API Reference
GoogleTranslateService
| Method | Description |
|---|---|
isAvailable() |
Check if API key is configured |
translate($text, $targetLocale, $sourceLocale) |
Translate plain text |
translateHtml($html, $targetLocale, $sourceLocale) |
Translate HTML content |
translateBatch($texts, $targetLocale, $sourceLocale) |
Translate multiple texts |
translateFields($fields, $targetLocale, $sourceLocale, $htmlFields) |
Translate array of fields |
getSourceLocale() |
Get configured source locale |
getTargetLocales() |
Get configured target locales |
HasGoogleTranslate Trait
| Method | Description |
|---|---|
hasTranslation($locale) |
Check if translation exists |
getTranslation($locale) |
Get translation for locale |
getAllTranslations() |
Get all translations including self |
createTranslation($locale, $attributes) |
Create new translation |
fillMissingTranslations($sourceLocale) |
Fill empty fields from source |
getTranslatableFields() |
Get list of translatable fields |
getHtmlFields() |
Get list of HTML fields |
Scopes
| Scope | Description |
|---|---|
sourceItems() |
Only items without pid (originals) |
localized($locale) |
Items in specific locale |
Static Methods
| Method | Description |
|---|---|
getMissingTranslations($targetLocale, $sourceLocale) |
Get items missing translation |
CMS Integration
For a complete guide on building a Translation Check Dashboard for your CMS, see the CMS Integration Guide.
Key features:
- Overview of missing translations per module
- Bulk translation with one click
- Individual item translation
- API status monitoring
- Progress tracking per locale
Testing
License
The MIT License (MIT). Please see License File for more information.
Author
- Arvid de Jong - [email protected]
All versions of laravel-google-translate with dependencies
PHP Build Version
Package Version
Requires
php Version
^8.2
illuminate/database Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0
illuminate/database Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0
The package darvis/laravel-google-translate contains the following files
Loading the files please wait ...