承接 nikaia/translation-sheet 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

nikaia/translation-sheet

最新稳定版本:v1.7.1

Composer 安装命令:

composer require nikaia/translation-sheet

包简介

Laravel Translation via Google Spreadsheet

README 文档

README

Translating Laravel languages files using a Google Spreadsheet.

Latest Version on Packagist Build Status

Contents

Installation

  • Install package

    $ composer require nikaia/translation-sheet --dev
  • If Laravel version <= 5.4, Add service provider to your 'config/app.php'. For version >= 5.5, package will be auto-discoverd by Laravel.

    Nikaia\TranslationSheet\TranslationSheetServiceProvider::class,
  • Configuration can be done via environments variables, but if you prefer you can override the configuration by publishing the package config file using :

    $ php artisan translation_sheet:publish
        or
    $ php artisan vendor:publish --provider="Nikaia\TranslationSheet\TranslationSheetServiceProvider"

Requirements

Laravel >= 5.1

Configuration

Google Api credentials

  • Create a new project in https://console.developers.google.com/
  • Make sure to activate Sheet Api for the created project
    • Navigate to "Library"
    • Search "Google Sheets API" > Click on "Google Sheets API" and click enable
  • Create credentials
    • Navigate to "Credentials"
    • Click "Create credentials"
    • Choose "Service Account key"
    • Choose A "New Service Account" in the "Service account" select
      • Choose a name. (ie. This is the name that will show up in the Spreadsheet history operations),
      • Choose "Editor" as the role
      • Choose "JSON" for the key type.
    • Save the credentials to 'resources/google/service-account.json' folder. (You can choose another name/folder and update the package configuration)
    • Make sure to write down the service account email, you will need to share the spreadsheet with this email (see below).

Spreadsheet

Package configuration

In your .env file or in your published config file (config/translation_sheet.php), you need to add the following

# The service account email   
TS_SERVICE_ACCOUNT_EMAIL=***@***.iam.gserviceaccount.com

# The path to the downloaded service account credentials file
TS_SERVICE_ACCOUNT_CREDENTIALS_FILE=resources/google/service-account.json

# The ID of the spreadsheet that we will be using for translation (the last portion of the spreadsheet url)
TS_SPREADSHEET_ID=xxxx

# The locales of the application (separated by comma) 
TS_LOCALES=fr,en,es

Usage

1/ Setup the spreadsheet

This need to be done only once.

$ php artisan translation_sheet:setup

2/ Prepare the sheet

To avoid some conflicts, we will first run this command to rewrite the locale languages files.

$ php artisan translation_sheet:prepare

3/ Publish translation to sheet

$ php artisan translation_sheet:push

4/ Share the spreadsheet with clients or project managers for translations.

5/ Once done, You can lock the translations on the spreadsheet (to avoid conflicts)

$ php artisan translation_sheet:lock

6/ Pull the translations

This will pull the translations from the spreadsheet, and write it the language files in your applications. You can use git diff here to make sure eveything is ok (Conflicts, errors etc ...)

$ php artisan translation_sheet:pull

6/ Unlock the translations on the spreadsheet

$ php artisan translation_sheet:unlock

Open the spreadsheet in the browser

$ php artisan translation_sheet:open

Excluding translations

Sometimes you might need to instruct the package to exclude some translations. You can do so by specifying patterns in the exclude config option. It accepts multiple patterns that target the full translation keys and that the Str::is can understand.

[
    // ...
    
    'exclude' => [
        'validation*',  // This will exclude all the `validation.php` translations.
        'foo::*',       // This will exclude all the `foo` namespace translations.
        'foo::bar.*',   // this will exclude the `bar` translations from the `foo` namespace.
    ],
    
    // ...
]

Extra sheets

Extra sheets

Sometimes you may have other files that need translations. They are not related to the laravel application per se and are not stored in the resources\lang folder. Maybe you are building a web app (spa), or even a mobile app alongside the laravel app, and you need to handle their translations.

In this specific case, you can configure extra sheets to handle those translations files stored inside a specific path.

  • This feature handles only json files.
  • The files must live outside the resources\lang directory. For instance resources\web-app\lang.
[
    // ...

    'extra_sheets' => [
        [
            'name' => 'Web App',                        // Spreadsheet sheet (tab) name.
            'path' => resource_path('web-app/lang'),    // Path where json files are stored. Files can be organized inside sub folders.        
            'tabColor' => '#0000FF',                    // Color of the spreadsheet tab
        ],
        [
            'name' => 'Mobile App',
            'path' => resource_path('mobile-app/lang'),        
            'tabColor' => '#0000FF',
        ],    
    ],
]

You need to run translation_sheet:setup command, if you add this config later on.

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

N.B : You need a valid configuration service-account.json file to run tests.

Github action

To test your fork using github action, you need a valid service-account.json. The file is ignored in the repository to avoid exposing credentials. You need to encode your credentials file tests/fixtures/service-account.json using gpg`

# Save credential file to tests/fixtures/service-account.json
$ gpg -c tests/fixtures/service-account.json  tests/fixtures/service-account.json.gpg

Commit the .gpg encoded file.

PS. Github action will decrypt the file just before running the tests. See the run-tests.yml file.

Security

If you discover any security related issues, please email nbourguig@gmail.com instead of using the issue tracker.

Contributing

Please see CONTRIBUTING for details.

Credits

nikaia/translation-sheet 适用场景与选型建议

nikaia/translation-sheet 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 588.78k 次下载、GitHub Stars 达 292, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 nikaia/translation-sheet 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 nikaia/translation-sheet 我们能提供哪些服务?
定制开发 / 二次开发

基于 nikaia/translation-sheet 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 292
  • Watchers: 4
  • Forks: 62
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04