承接 symvaro/artisan-lang-utils 相关项目开发

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

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

symvaro/artisan-lang-utils

最新稳定版本:v0.1.0

Composer 安装命令:

composer require symvaro/artisan-lang-utils

包简介

README 文档

README

This package contains artisan commands to import/export and work with language resources.

Install

composer require --dev symvaro/artisan-lang-utils

Use

Warning: The artisan lang commands will alter the language files when used for editing or import. That means that:

  • every content except keys and values will be removed (e.g. comments),
  • variables will be replaced with their values and
  • nested array structures will be flattened.

Therefore it's recommended to use these tools only in combination with a VCS!

Export/Import

To export the languages strings in the supported formats use the command like:

php artisan lang:export --language=en --format=po filename.po

If the filename is omitted, stdout will be used and if no language parameter is specified, the default language will be used. The following formats are currently supported: tsv (default), json, po and resource, where resource is a laravel lang folder. The tsv format contains a tab separated key message pair for every row. The control characters \n, \t, \\, \r\n are escaped with \ .

The import command line api is similarly structured like the export.

php artisan lang:import --language=en --format=po filename

It will read from stdin, if no filename is specified. There is also the --replace-all option, which will remove language strings, if they are not present in the import file.

Edit

Available commands to ease editing of language strings:

  • Add or replace (lang:add {--l|language=} {?key})
  • Removing (lang:remove {?key})

Examples

The commands can be combined with common shell utils. The tsv format is especially supporting this. For example to list all non unique messages you can use this:

./artisan lang:export \
    | awk -F"\t" '{ print $2 }' \
    | sort | uniq -c | sort -rn \
    | grep -vE "^[ ]*1"

Contributing

This library will only consist of sound tools to import/export and help editing your language files in the command line. Feature requests or contributions out of this scope will not be accepted. Test cases for your special cases or bugs are very appreciated.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-11-17