adampatterson/laravel-csv-translations 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

adampatterson/laravel-csv-translations

最新稳定版本:1.0.0

Composer 安装命令:

composer require adampatterson/laravel-csv-translations

包简介

Manage translations in CSV files and import them into Laravel.

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package allows you to export and import Laravel translations using CSV files. This makes it easy to share translations with non-technical team members or external translation services.

It supports both standard Laravel language files and vendor-published translations, and can handle both PHP array and JSON formats.

Installation

You can install the package via composer:

composer require adampatterson/laravel-csv-translations

You can publish the config file with:

php artisan vendor:publish --tag="laravel-csv-translations"

This is the contents of the published config file:

return [
    /*
    |--------------------------------------------------------------------------
    | Default Export Path
    |--------------------------------------------------------------------------
    |
    | This is the default path where the translations will be exported to.
    |
    */
    'export_path' => base_path('lang.csv'),
];

Usage

Publishing Translations

By default, the Laravel application skeleton does not include the lang directory. If you would like to customize Laravel's language files, you may publish them via the lang:publish Artisan command.

Further, you can also publish translations from any vendor package that has published its translations. To do this, use the --vendor (or -v) option with the package name:

php artisan lang:publish --vendor=vendor/package

For example, Filament's translations can be published with:

php artisan vendor:publish --tag=filament-translations

Exporting Translations

To export your translations to a CSV file, use the translation:export command:

php artisan translation:export

By default, this exports the base locale (defined in config('app.locale')) to the path specified in your config.

Options

  • Specify Path: Provide a path as an argument to change the output location.
    php artisan translation:export custom/path/translations.csv
  • Export All Locales: Use the --all (or -a) flag to export every locale found in your lang directory.
    php artisan translation:export --all
  • Specific Locales: Use the --locales (or -l) option with a comma-separated list.
    php artisan translation:export --locales=en,fr,es

The CSV will contain the following columns:

  1. Path: The relative path to the translation file (e.g., en/auth or vendor/package/en/messages).
  2. Key: The dot-notation key for the translation.
  3. Original: The current translation value.
  4. New: An empty column for you to provide new translations.

Importing Translations

To import translations from a CSV file, use the translation:import command:

php artisan translation:import

The command will read the CSV and update your language files. If a value is present in the New column, it will be used; otherwise, the Original value is preserved.

Options

  • Specify Path: Provide the path to the CSV file as an argument.
    php artisan translation:import custom/path/translations.csv
  • Filter by Locale: Import only a specific locale from the CSV.
    php artisan translation:import --locale=fr
  • Import as JSON: Convert the translations into JSON files instead of PHP arrays.
    php artisan translation:import --json

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固