百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
L

laravel-auto-translate

> 后端框架
开源

使用翻译服务自动翻译您的语言文件

178 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

使用翻译服务自动翻译您的语言文件

With this package you can translate your language files using a translator service. The package ships with a free Google Translate version, Google Translate API and Deepl.

Specify a source language and a target language and it will automatically translate your files. This is useful if you want to prototype something quickly or just a first idea of the translation for later editing. The package ships with two artisan commands. One for translating all the missing translations that are set in the source language but not in the target language. The other one for translating all source language files and overwriting everything in the target language.

Installation

This package can be used in Laravel 5.6 or higher and needs PHP 7.2 or higher.

You can install the package via composer:

bash
composer require ben182/laravel-auto-translate

Config

After installation publish the config file:

bash
php artisan vendor:publish --provider="Ben182\AutoTranslate\AutoTranslateServiceProvider"

You can specify your source language, the target language(s), the translator and the path to your language files in there.

Translators

Name Free File Documentation Available languages
Google Translate HTTP Yes Ben182\AutoTranslate\Translators\SimpleGoogleTranslator / Over 100
Google Cloud Translate No Ben182\AutoTranslate\Translators\GoogleCloudTranslator Documentation Over 100
Deepl API v2 No Ben182\AutoTranslate\Translators\DeeplTranslator Documentation EN, DE, FR, ES, PT, IT, NL, PL, RU

If you have lots of translations to make I recommend Google Cloud Translate or Deepl. They are fast, reliable and you will not encounter any rate limiting.

Usage

Missing translations

Simply call the artisan missing command for translating all the translations that are set in your source language, but not in your target language:

bash
php artisan autotrans:missing

E.g. you have English set as your source language. The source language has translations in auth.php:

php
 'These credentials do not match our records.',
    'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
];

Your target language is German. The auth.php file has the following translations:

php
 'Diese Kombination aus Zugangsdaten wurde nicht in unserer Datenbank gefunden.',
];

The artisan missing command will then translate the missing auth.throttle key.

All translations

To overwrite all your existing target language keys with the translation of the source language simply call:

bash
php artisan autotrans:all

This will overwrite every single key with a translation of the equivalent source language key.

Parameters

Sometimes you have translations like these:

php
'welcome' => 'Welcome, :name',

They can be replaced with variables. When we pass these placeholders to a translator service, weird things can happen. Sometimes the placeholder comes back in upper-case letters or it has been translated. Thankfully the package will respect your variable placeholders, so they will be the same after the translation.

Extending

You can create your own translator by creating a class that implements \Ben182\AutoTranslate\Translators\TranslatorInterface. Simply reference it in your config file.

Testing

bash
composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

  • Benjamin Bortels
  • All Contributors

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

PHPlaravellaravel-5-packagelaravel-packagephp

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类后端框架
定价开源

> 相关工具

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架