rauwebieten/craft-translations-extractor 问题修复 & 功能扩展

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

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

rauwebieten/craft-translations-extractor

最新稳定版本:1.0.2

Composer 安装命令:

composer require rauwebieten/craft-translations-extractor

包简介

Craft CMS Translations Extractor

README 文档

README

WORK IN PROGRESS, USE AT OWN RISK

Requirements

This plugin requires Craft CMS 3.5 later.

Installation

composer require rauwebieten/craft-translations-extractor

Usage

php craft translations-extractor/index

This command will search for translations strings in your templates folder. This command uses a regular expression to find all translation strings, it will find following translation strings:

<p>
    {# translation with t filter #}
    {{ "Hello world"|t }}

    {# translation with translate filter #}
    {{ "Hello craft"|translate }}

    {# translation with single quotes #}
    {{ 'Hello template'|t }}

    {# translation with single/double quotes #}
    {{ 'This is a "quoted string"'|t }}
    {{ "This is another \"quoted string\""|t }}
    {{ 'This too is a \'quoted string\''|t|raw }}
</p>

Foreach defined language in your project it will create a translation file.

  • Translation string that are not in use anymore, are removed from the translation file
  • Existing translations strings are merge with the newly found translations strings
translations/en/site-extracted.php

Do whatever you like with this file. For example, include it in the main translation file. This way you can still use a site.php file with your custom translation strings.

// translations/en/site.php
<?php return array_merge(include __DIR__ .'site-extracted.php',[
  'other-translation-strings' => 'blah blah'
]);

Not supported.

This plugin is a work in progress. Use at own risk.

This plugin cannot:

  1. detect translation strings with parameters, like "{num} pages"(params={num:3})
  2. detect translation strings with other namespaces, like "hello"|t('plugin-handle')

Roadmap

  1. resolve issues as mentioned above
  2. use a translation API
  3. Craft 4 support

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-12-05