定制 javidalpe/laravel-localization-automation 二次开发

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

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

javidalpe/laravel-localization-automation

Composer 安装命令:

composer require javidalpe/laravel-localization-automation

包简介

Translate your Laravel localization files using third party services

README 文档

README

This package translates your Laravel localization files automatically using a third party service. Currently only supports DeepL.

This package only works with 'Short Keys' approach

Installation

You can install the package via composer:

composer require --dev javidalpe/laravel-localization-automation

If you're on Laravel 5.4 or earlier, you'll need to add the following to your config/app.php:

'providers' => [
    ...
    Javidalpe\LaravelLocalizationAutomation\LaravelLocalizationAutomationServiceProvider::class,
];

Usage

This command translates all your files in /lang/{from}/ directory and create the new ones in /lang/{to}/ directory.

php artisan localization:translate {from} {to} {--provider=deepl}

Example using default provider:

php artisan localization:translate es fr

Example using custom provider:

php artisan localization:translate es fr --provider=deepl

Known issues

The command will fail on:

  1. Lemmas with HTML inside.
    \\Wrong
    'welcome.greetings' => '<strong>Hey!</strong>',
    \\Good
    'welcome.greetings' => 'Hey!',
  2. Lemmas with placeholders different from Laravel.
    \\Wrong
    'welcome.greetings' => 'Hey {{name}}!',
    \\Good
    'welcome.greetings' => 'Hey!',
  3. URLs. Fix these URLs manually.

Supported Languages

Deeply

DeepL(y) supports these languages:

Code Language
DE German
EN English
FR French
ES Spanish
IT Italian
NL Dutch
PL Polish

DeepL says they will add more languages in the future, such as Chinese and Russian.

How it works

  1. Foreach file in /lang/{from}/ directory.
  2. Foreach lemma in file.
  3. Split pluralization lemmas.
  4. Replace each Laravel place-holder with temp string.
  5. Translate the lemma using the provider.
  6. Undo replacement.
  7. Assembly all lemmas in new files at /lang/{to}/ directory.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-translation-service)
  3. Commit your changes (git commit -am 'Added translation service')
  4. Push to the branch (git push origin my-new-translation-service)
  5. Create new Pull Request

Add a new translation service

  1. Create a new class inside /src/TranslationServices. Implements TranslationServiceStrategy.
  2. Add this class to TranslationServiceStrategyFactory.
  3. Update this `README.md file.

Credits

License

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

统计信息

  • 总下载量: 55
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-11-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固