PHPackages                             beholdr/folio-translate - 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. beholdr/folio-translate

ActiveLibrary[Localization &amp; i18n](/categories/localization)

beholdr/folio-translate
=======================

Easy translation for Laravel Folio pages.

v0.0.5(3mo ago)02.8k↓27.7%MITPHPPHP ^8.3CI passing

Since Apr 15Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/beholdr/folio-translate)[ Packagist](https://packagist.org/packages/beholdr/folio-translate)[ Docs](https://github.com/beholdr/folio-translate)[ RSS](/packages/beholdr-folio-translate/feed)WikiDiscussions main Synced 3d ago

READMEChangelogDependencies (28)Versions (6)Used By (0)

Folio Translate
===============

[](#folio-translate)

Easy translation for Laravel Folio pages. This package based on [mcamara/laravel-localization](https://github.com/mcamara/laravel-localization).

This package extends `laravel-localization` with these features:

- translate Folio content via files in the same folder
- check and hide unsupported locales in a language switcher
- redirect to a default locale if a page does not support current locale

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require beholdr/folio-translate
```

Usage
-----

[](#usage)

Add middleware alias in your `bootstrap/app.php`:

```
return Application::configure(basePath: dirname(__DIR__))
    ->withMiddleware(function (Middleware $middleware) {
        $middleware->alias([
            // other middleware aliases...
            'setLocaleFromBrowser' => \Beholdr\FolioTranslate\Middleware\SetLocaleFromBrowser::class,
            'supportedLocales' => \Beholdr\FolioTranslate\Middleware\SupportedLocales::class,
        ]);
```

Add middlewares in your `app/Providers/FolioServiceProvider.php`:

```
namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Laravel\Folio\Folio;
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;

class FolioServiceProvider extends ServiceProvider
{
    public function boot(): void
    {
        $locale = LaravelLocalization::setLocale();

        Folio::path(resource_path('views/pages'))->middleware([
            '*' => [
                'localeSessionRedirect',
                'localizationRedirect',
                'supportedLocales',
            ],
        ])->uri($locale ?? '');
    }
}
```

### Content translation

[](#content-translation)

Given you have a page `views/pages/index.blade.php` and want to translate it to `english` and `russian` languages.

1. Call `translate` function in `views/pages/index.blade.php` file:

```

```

2. Create `views/pages/index-en.blade.php` and `views/pages/index-ru.blade.php` files in the same directory with original file. Translated files should have the same prefix as the original file, for example:

```
views
  pages
    some-path
      filename.blade.php
      filename-en.blade.php
      filename-ru.blade.php
    index.blade.php
    index-en.blade.php
    index-ru.blade.php

```

3. Put your translated content in these files. They will be rendered for each corresponding locale. For example `views/pages/index-en.blade.php`:

```

    English content...

```

### Fallback locale

[](#fallback-locale)

You can pass an optional argument to `translate` function to specify default (fallback) locale: `translate('en')`. This locale will be used to load content if there is no translation for a current locale.

If not specified, it equals to a system `APP_FALLBACK_LOCALE`.

### Define supported languages manually

[](#define-supported-languages-manually)

Sometimes you need to define supported languages for page manually. It even could be non-Folio page. In this case you can use middleware `supportedLocales` or a helper method `setSupportedLanguagesKeys`.

#### Middleware

[](#middleware)

You can add `supportedLocales` middleware with a list of supported languages to any route:

```
Route::get('/news', NewsController::class)
    ->middleware('supportedLocales:en,ru');
```

In this case a page will support passed languages.

#### Helper method

[](#helper-method)

Also you can programmatically set supported languages, using `FolioTranslate::setSupportedLanguagesKeys()` method:

```
if ($redirect = FolioTranslate::setSupportedLanguagesKeys(['ru', 'en'])) {
    return $redirect;
}
```

In case of absent translation for current language, `setSupportedLanguagesKeys` will return redirect to a default locale version.

`SetLocaleFromBrowser` middleware
---------------------------------

[](#setlocalefrombrowser-middleware)

This middleware sets application locale from a browser request (`Accept-Language` header).

```
Route::get('/endpoint', EndpointController::class)
    ->middleware('setLocaleFromBrowser');
```

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance82

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~88 days

Total

5

Last Release

94d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/741973?v=4)[Alexander Shabunevich](/maintainers/beholdr)[@beholdr](https://github.com/beholdr)

---

Top Contributors

[![beholdr](https://avatars.githubusercontent.com/u/741973?v=4)](https://github.com/beholdr "beholdr (13 commits)")

---

Tags

folioi18nlaraveltranslationlaraveltranslationfolio

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/beholdr-folio-translate/health.svg)

```
[![Health](https://phpackages.com/badges/beholdr-folio-translate/health.svg)](https://phpackages.com/packages/beholdr-folio-translate)
```

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k102.4M1.4k](/packages/spatie-laravel-permission)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M101](/packages/dedoc-scramble)[askdkc/breezejp

Laravel Starter Kit (Livewire+Breeze+Laravel UI+Jetstream)や標準のバリデーションメッセージを全て一瞬で日本語化し、言語切替機能も提供するパッケージです / This package provides all-in-one Japanese translation for Laravel StarterKit (Livewire StarterKit, Breeze, Laravel UI and Jetstream) packages and validation messages with language switching feature.

593277.6k1](/packages/askdkc-breezejp)[spatie/laravel-passkeys

Use passkeys in your Laravel app

471890.7k39](/packages/spatie-laravel-passkeys)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
