定制 kamal-abouzayed/quick-translate 二次开发

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

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

kamal-abouzayed/quick-translate

最新稳定版本:v1.0.0

Composer 安装命令:

composer require kamal-abouzayed/quick-translate

包简介

Easily integrate Google Translate API with Laravel to automate multilingual translations across your app.

README 文档

README

QuickTranslate is a Laravel package that enables easy translation of words into multiple languages using Google Translate. It simplifies the process of managing translations for your application.

Table of Contents

Installation

To install the package, run the following command in your Laravel project's root directory:

composer require kamalabouzayed/quicktranslate

Register the Service Provider

If you're using Laravel 5.4 or below, you need to register the service provider in your config/app.php file. Add the following line to the providers array:

'providers' => [
    // ...
    KamalAbouzayed\QuickTranslate\QuickTranslateServiceProvider::class,
],

Starting from Laravel 5.5, package auto-discovery is supported, so you can skip this step.

Publish the Configuration

To customize the package settings, publish the configuration file by running the following command:

php artisan vendor:publish --provider="KamalAbouzayed\QuickTranslate\QuickTranslateServiceProvider" --tag=config

This command will create a configuration file at config/quick-translate.php. You can set the supported locales and the path to the translations file in this config file.

Example Configuration

Here’s an example configuration you might use:

<?php

return [

    /**
     * Set array of supported locales.
     *
     * @var array
     */
    'locales' => [
        'en',
        'ar',
    ],

    /**
     * Set path to translations file.
     *
     * @var string
     */
    'translationsFile' => storage_path('app/translations.json'),
];

Usage

You can utilize the translation functionality by calling the translate function.

Example

Here’s how you can translate a word using the package:

<?php

$word = translate('Hello');

echo $word;

// Output: Depends on the current application locale
// ar => مرحبا
// en => Hello

License

This package is licensed under the MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-10-28