medienbaecker/kirby-language-access
Composer 安装命令:
composer require medienbaecker/kirby-language-access
包简介
Control public language visibility and restrict translators to assigned languages
README 文档
README
Controls which languages are visible on the frontend and who can edit them in the Panel. Frontend visitors only see the languages you've enabled. Restricted users can only edit content in the languages assigned to them.
Installation
composer require medienbaecker/kirby-language-access
Or download and place in site/plugins/kirby-language-access.
Setup
1. Enable languages
In site/config/config.php, specify which languages visitors can see. The default language is always available, but it also doesn't hurt including it in the array:
return [ 'medienbaecker.language-access.languages' => ['de', 'en'], ];
2. Disable fields for restricted languages
For pages, the plugin registers a custom page model that makes fields read-only automatically. If your project has its own site/models/default.php, extend the plugin's model rather than Page:
use Medienbaecker\LanguageAccess\LanguageAccessPage; class DefaultPage extends LanguageAccessPage { // your methods }
Unfortunately there's no equivalent for site and files in Kirby, so your blueprints need to extend the plugin:
# site/blueprints/site.yml extends: language-access/site
# site/blueprints/files/default.yml extends: language-access/file
3. Restrict users
The plugin includes a Translator role blueprint. Create it in your project and tweak the permissions as needed:
# site/blueprints/users/translator.yml extends: language-access/users/translator
Create a user with that role in the Panel and pick the languages they're allowed to edit.
Auto-detect public language
Opt-in: the plugin can take over Kirby's built-in language detection and restrict it to the public language set. Anything Kirby's languages.detect does — detecting on / and on language-less deep URLs like /faq — the plugin does, but only picks among the languages listed in medienbaecker.language-access.languages.
return [ 'languages' => [ 'detect' => false, // let the plugin handle this ], 'medienbaecker.language-access.languages' => ['de', 'en'], 'medienbaecker.language-access.detect' => true, 'medienbaecker.language-access.fallback' => 'en', ];
detect(defaultfalse) — turn on public-only detection.fallback(default: site default) — language shown when the browser'sAccept-Languagedoesn't match any public language. Useful when the site default isn't the best landing for international visitors.
Matching follows Kirby's own three-tier logic (5-char locale, 2-char code, broad locale prefix), then falls back to fallback. Responses include Vary: Accept-Language so well-behaved caches key on the header — if you're behind an edge cache (nginx, Varnish, CDN), check that the cache honors Vary: Accept-Language on the / redirect, otherwise visitors may be served another language's cached response.
Guard
Anonymous visitors trying to reach a non-public language URL (e.g. /sv/faq when only de and en are public) receive a 404. Logged-in users pass through, so translators can still preview their assigned languages.
Language menu
$site->enabledLanguages() gives you the languages that are publicly available. Here's a simple example of a language menu:
<?php $languages = $kirby->user() ? $kirby->languages() : $site->enabledLanguages() ?> <nav> <?php foreach ($languages as $lang): ?> <a href="<?= $page->url($lang->code()) ?>"><?= $lang->name() ?></a> <?php endforeach ?> </nav>
Licence
MIT
medienbaecker/kirby-language-access 适用场景与选型建议
medienbaecker/kirby-language-access 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11 次下载、GitHub Stars 达 3, 最近一次更新时间为 2026 年 03 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 medienbaecker/kirby-language-access 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 medienbaecker/kirby-language-access 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 30
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-02