PHPackages                             medienbaecker/kirby-language-access - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Localization &amp; i18n](/categories/localization)
4. /
5. medienbaecker/kirby-language-access

ActiveKirby-plugin[Localization &amp; i18n](/categories/localization)

medienbaecker/kirby-language-access
===================================

Control public language visibility and restrict translators to assigned languages

1.1.1(3w ago)36MITPHPPHP ^8.2

Since Mar 2Pushed 3w ago1 watchersCompare

[ Source](https://github.com/medienbaecker/kirby-language-access)[ Packagist](https://packagist.org/packages/medienbaecker/kirby-language-access)[ RSS](/packages/medienbaecker-kirby-language-access/feed)WikiDiscussions main Synced today

READMEChangelog (3)Dependencies (6)Versions (4)Used By (0)

Kirby Language Access
=====================

[](#kirby-language-access)

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
------------

[](#installation)

```
composer require medienbaecker/kirby-language-access
```

Or download and place in `site/plugins/kirby-language-access`.

Setup
-----

[](#setup)

### 1. Enable languages

[](#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

[](#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

[](#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
---------------------------

[](#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` (default `false`) — turn on public-only detection.
- `fallback` (default: site default) — language shown when the browser's `Accept-Language` doesn'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
-----

[](#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
-------------

[](#language-menu)

`$site->enabledLanguages()` gives you the languages that are publicly available. Here's a simple example of a language menu:

```
