Translations
Unfold CMS includes built-in multi-language support with full RTL (right-to-left) compatibility. The translation system allows you to manage all user-facing strings from the admin panel and supports any language.
Overview
The translation system provides:
- Admin-managed translations — Edit translations through the admin panel
- RTL support — Full right-to-left layout for Arabic, Persian, Hebrew, and other RTL languages
- Language detection — Automatic locale selection based on configuration
- Template integration — Simple Blade directives for translatable strings
- JSON translation files — Standard Laravel translation format
Configuration
The default language is set in your .env file and config/site.php:
APP_LOCALE=en
'app' => [
'locale' => 'en',
],
Using Translations
In Blade Templates
Use Laravel's standard __() helper or @lang directive:
<h1>{{ __('Welcome to our site') }}</h1>
<p>@lang('Read our latest blog posts')</p>
Translation Files
Translations are stored in JSON files under lang/:
lang/
├── en.json # English
├── fa.json # Persian (Farsi)
├── ar.json # Arabic
└── ...
Example fa.json:
{
"Welcome to our site": "به سایت ما خوش آمدید",
"Read our latest blog posts": "آخرین مطالب وبلاگ ما را بخوانید",
"Search": "جستجو",
"Home": "خانه"
}
PHP Translation Files
For more structured translations, use PHP files in lang/{locale}/:
lang/
├── en/
│ ├── messages.php
│ └── validation.php
├── fa/
│ ├── messages.php
│ └── validation.php
Access with dot notation:
{{ __('messages.welcome') }}
RTL Support
Unfold CMS automatically detects RTL languages and applies the appropriate layout direction. RTL-aware languages include Persian, Arabic, Hebrew, Urdu, and others.
How RTL Works
When an RTL locale is active:
- The
<html>element receivesdir="rtl" - Tailwind CSS RTL utilities activate automatically
- Layout direction flips (sidebar, navigation, text alignment)
- Form elements align correctly
Template RTL Support
In your templates, use Tailwind's RTL modifier for direction-specific styles:
<div class="ml-4 rtl:mr-4 rtl:ml-0">
{{-- Margin switches sides in RTL --}}
</div>
Or use the @rtl / @ltr directives:
@if(app()->getLocale() === 'fa')
{{-- Persian-specific content --}}
@endif
Date Localization
Unfold CMS includes the MultiCarbon package for Jalali (Persian/Solar Hijri) calendar support. When the locale is set to Persian, dates are automatically displayed in Jalali format.
Jalali Calendar
The Jalali calendar is used in Iran, Afghanistan, and other Persian-speaking regions. The CMS handles:
- Date formatting — Jalali dates in admin and public views
- Date input — Jalali date pickers in the admin panel
- Relative dates — "2 روز پیش" (2 days ago) in Persian
Date Helpers
// Format date according to locale
format_date($post->created_at); // "15 فروردین 1404" (Jalali)
format_datetime($post->created_at); // "15 فروردین 1404 14:30" (Jalali)
Admin Panel Translations
The admin panel translation manager (accessible under Settings > Translations) allows you to:
- Browse all translatable strings
- Edit translations for any supported language
- Search for specific strings
- Export/Import translation files
Adding a New Language
- Create a new JSON file in
lang/(e.g.,lang/de.json) - Add translations for your strings
- Set
APP_LOCALE=dein.envto make it the default - Clear the config cache:
php artisan config:clear
Permissions
| Operation | Required Role |
|---|---|
| View translations | Admin or higher |
| Edit translations | Admin or higher |
| Add new languages | Super Admin |