umpirsky/twig-gettext-extractor 问题修复 & 功能扩展

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

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

umpirsky/twig-gettext-extractor

Composer 安装命令:

composer require umpirsky/twig-gettext-extractor

包简介

The Twig Gettext Extractor is Poedit friendly tool which extracts translations from twig templates.

README 文档

README

symfony upgrade fixertwig gettext extractorwisdomcentipedepermissions handlerextraloadgravatarlocurrocountry listtransliterator

Twig Gettext Extractor Build Status

The Twig Gettext Extractor is Poedit friendly tool which extracts translations from twig templates.

Installation

Manual

Local

Download the twig-gettext-extractor.phar file and store it somewhere on your computer.

Global

You can run these commands to easily access twig-gettext-extractor from anywhere on your system:

$ sudo wget https://github.com/umpirsky/Twig-Gettext-Extractor/releases/download/1.2.0/twig-gettext-extractor.phar -O /usr/local/bin/twig-gettext-extractor
$ sudo chmod a+x /usr/local/bin/twig-gettext-extractor

Then, just run twig-gettext-extractor.

Composer

Local

$ composer require umpirsky/twig-gettext-extractor

Global

$ composer global require umpirsky/twig-gettext-extractor

Make sure you have ~/.composer/vendor/bin in your PATH and you're good to go:

$ export PATH="$PATH:$HOME/.composer/vendor/bin"

Don't forget to add this line in your .bashrc file if you want to keep this change after reboot.

Setup

By default, Poedit does not have the ability to parse Twig templates. This can be resolved by adding an additional parser (Edit > Preferences > Parsers) with the following options:

  • Language: Twig
  • List of extensions: *.twig
  • Invocation:
    • Parser command: <project>/vendor/bin/twig-gettext-extractor --sort-output --force-po -o %o %C %K -L PHP --files %F (replace <project> with absolute path to your project)
    • An item in keyword list: -k%k
    • An item in input file list: %f
    • Source code charset: --from-code=%c

Now you can update your catalog and Poedit will synchronize it with your twig templates.

Custom extensions

Twig-Gettext-Extractor registers some default twig extensions. However, if you are using custom extensions, you need to register them first before you can extract the data. In order to achieve that, copy the binfile into some custom place. A common practice would be: cp vendor/bin/twig-gettext-extractor bin/twig-gettext-extractor

Now you may add your custom extensions here:

$twig->addFunction(new \Twig_SimpleFunction('myCustomExtension', true));
$twig->addFunction(new \Twig_SimpleFunction('myCustomExtension2', true));

Command Line Arguments

You can also specify custom extensions and filters via command line, by adding the --functions and --filters arguments, e.g.:

--functions formRow,formElement --filters localizedCurrency

You can specify an unlimited amount of comma-separated function and filter names.

Similarly, you can specify the location of the gettext executable you want to use with --exec

--exec /usr/local/bin/xgettext

umpirsky/twig-gettext-extractor 适用场景与选型建议

umpirsky/twig-gettext-extractor 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 381.31k 次下载、GitHub Stars 达 112, 最近一次更新时间为 2012 年 08 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 umpirsky/twig-gettext-extractor 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 112
  • Watchers: 7
  • Forks: 29
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2012-08-29