Package Data | |
---|---|
Maintainer Username: | rozklad |
Maintainer Contact: | info@sanatorium.ninja (Sanatorium) |
Package Create Date: | 2016-04-14 |
Package Last Update: | 2016-10-23 |
Language: | PHP |
License: | Unknown |
Last Refreshed: | 2024-11-14 15:18:54 |
Package Statistics | |
---|---|
Total Downloads: | 0 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 3 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Localization
Add repository to your composer.json
"repositories": [
{
"type": "composer",
"url": "http://repo.sanatorium.ninja"
}
]
Download the package
composer require sanatorium/localization
Add following line to app/Http/Kernel.php
protected $middleware = [
...
\Sanatorium\Localization\Middleware\Locale::class
];
There are two terms used throughout this package - Localization and Translation, let's describe the difference:
We use localization for localized value of entity key. For example used like this:
{{-- Original value --}}
{{ $page->meta_title }}
{{-- Localized value --}}
@localize($page, 'meta_title')
Translation refers to original translation feature of Laravel and does not need any special markup. Special admin screen to manage translations is provided.
trans('platform/pages::common.title')
// Register new localized entity
$this->app['sanatorium.localization.localized']->localize(
'Platform\Menus\Models\Menu'
);
@localize($entity, 'field')
General app and package language strings can be changed from
/resources/langs/override/{LOCALE}
/resources/langs/override/{VENDOR}/{PACKAGE}/{LOCALE}
These language strings are managed from
/admin/localization/translations
Manage languages available for the users on the site.
Set GET param 'locale' to any supported locale, like this
http://example.com/?locale=en
Set GET param 'active_locale' to any supported locale, like this
http://example.com/?active_locale=en
Set active_language_locale
session to desired locale.
Manage string translation in localization files.
transattr($slug, $fallback = null, $locale = null)
transvalue($slug, $fallback = null, $locale = null)
Support not available.
'shop.header' => 'sanatorium/localization::hooks.languages', // @deprecated
'language.switch' => 'sanatorium/localization::hooks.languages',