定制 medienbaecker/kirby-translation-progress 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

medienbaecker/kirby-translation-progress

Composer 安装命令:

composer require medienbaecker/kirby-translation-progress

包简介

Translation status overview for the Kirby Panel

README 文档

README

Extends the Panel's Languages view with a translation overview: a completion percentage per language and a collapsible page tree showing per-page progress.

The Languages view with a Translation Progress section showing per-language percentages and a page tree with translation progress per page and language

Installation

Composer

composer require medienbaecker/kirby-translation-progress

Manual

Download and extract to site/plugins/kirby-translation-progress.

Requirements

  • Kirby 5+
  • PHP 8.2+
  • Multi-language setup

How it works

The plugin reads Kirby's content files, compares them field by field against the default language, and reports a percentage.

Pages without a content file for a language are marked as missing. A field is considered translated when its content differs from the default language. A field that's empty in the translation counts as untranslated. A field that's identical to the default language is where it gets tricky:

Identical content

When a field has the same value in both languages, is it translated or not? "API" in English is "API" in German and that's fine. But a full paragraph that's identical in both languages probably hasn't been translated yet.

The plugin uses a length heuristic: identical values shorter than minValueLength (default: 50 characters) are assumed to be loan words or proper nouns. Longer identical values are flagged as untranslated.

Field types

The plugin reads the blueprint to find translatable fields. Fields with translate: false are excluded, and so are non-text types (files, pages, users, link, color, date, time) that don't contain translatable content.

For complex fields, the plugin extracts text before comparing:

Field type What gets compared
text, textarea The raw value
writer, list HTML with tags stripped
blocks Text from each block's content fields
layout Text from blocks inside each column
structure Each sub-field per row, individually
object Each sub-field individually
tiptap Text nodes from ProseMirror JSON

Object and structure fields are expanded recursively, nested compounds (e.g. a structure inside an object) should work too.

Language variables

The translations array from your language files is also compared, shown as a separate row. Disable it with languageVariables: false.

Options

'medienbaecker.translation-progress' => [
    'minValueLength'    => 50,
    'languageVariables' => true,
    'ignoreFieldTypes'  => ['files', 'pages', 'users', 'link', 'color', 'date', 'time'],
    'ignoreVariable'    => null,
    'ignoreField'       => null,
    'ignorePage'        => null,
    'adapters'          => [],
],

Tip

Use Kirby's built-in translate: false option in your blueprints to exclude specific fields from secondary languages:

fields:
  category:
    type: select
    translate: false

Ignoring content

Some content keeps a language from ever reaching 100% even when nothing's wrong: a language variable that happens to read the same as the default in most languages (a unit or shared term like {{time}} min), a field that doesn't need translating, or an entire page type. Three callbacks exclude it from the calculation, each returning true to exclude:

'medienbaecker.translation-progress' => [
    // Language variables, by translation key
    'ignoreVariable' => function (string $key, string $value): bool {
        return $key === 'recipe.time';
    },

    // Content fields, by name and template
    'ignoreField' => function (string $name, string $template): bool {
        return $template === 'recipe' && $name === 'duration';
    },

    // Whole pages, by template or anything on the Page object
    'ignorePage' => function (\Kirby\Cms\Page $page): bool {
        return $page->intendedTemplate()->name() === 'recipe';
    },
],

ignoreField runs once per template and only sees top-level fields, so sub-fields of object and structure fields follow ignoreFieldTypes instead. It also receives the field's blueprint type as an optional third argument, which scopes a type to one template (ignoreFieldTypes drops it everywhere). ignorePage skips a page's own progress but still descends into its children, so a parent kept only to hold translatable children stays in the tree.

Custom adapters

For third-party field types that store text in a custom format, register an adapter that returns plain text:

'medienbaecker.translation-progress' => [
    'adapters' => [
        'my-field' => function (string $value): string {
            $data = json_decode($value, true);
            return strip_tags($data['html'] ?? '');
        },
    ],
],

Built-in adapters cover writer, list, blocks, layout, structure, object, and my tiptap plugin. A custom adapter with the same name overrides the built-in one.

Limitations

  • The plugin can't know if identical content was intentional. The minValueLength threshold is a best guess.
  • Blocks and layouts count as one field. The plugin doesn't track individual blocks across languages since they can be reordered, added, or removed independently.

License

MIT

medienbaecker/kirby-translation-progress 适用场景与选型建议

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

它主要适用于以下技术方向: 「i18n」 「translation」 「multilanguage」 「panel」 「kirby」 「kirby-plugin」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 17
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

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