sanatorium / localization
Localization
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Type:platform-extension
Requires
- php: >=5.4.0
- cartalyst/composer-installers: 1.2.*
- platform/foundation: >=2.0 <5.0
- sepia/po-parser: >=4.2.1
- dev-master
- 3.2.6
- 3.2.5
- 3.2.4
- 3.2.3
- 3.2.2
- 3.2.1
- 3.2.0
- 3.1.9
- 3.1.8
- 3.1.7
- 3.1.6
- 3.1.5
- 3.1.4
- 3.1.3
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.9
- 3.0.8
- 3.0.7
- 3.0.6
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0
- 0.5.1
- 0.5.0
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.8
- 0.3.7
- 0.3.6
- 0.3.5
- 0.3.4
- 0.3.3
- 0.3.2
- 0.3.1
- 0.3.0
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.6
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
This package is not auto-updated.
Last update: 2024-09-28 19:52:46 UTC
README
Localization
Contents
Installation
Composer
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
];
Documentation
There are two terms used throughout this package - Localization and Translation, let's describe the difference:
Localization
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
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')
Localize entity field
Register new localized entity
// Register new localized entity
$this->app['sanatorium.localization.localized']->localize(
'Platform\Menus\Models\Menu'
);
Localize entity field
@localize($entity, 'field')
Translate strings
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
Languages
Manage languages available for the users on the site.
Single request locale setting
Set GET param 'locale' to any supported locale, like this
http://example.com/?locale=en
Persistent locale setting
From browser
Set GET param 'active_locale' to any supported locale, like this
http://example.com/?active_locale=en
In code
Set active_language_locale
session to desired locale.
Translations
Manage string translation in localization files.
Functions
transattr($slug, $fallback = null, $locale = null)
transvalue($slug, $fallback = null, $locale = null)
Changelog
- 3.1.1 - 2016-09-23 - Helper functions
- 3.0.9 - 2016-09-15 - Platform 5, caching
- 0.4.0 - 2016-07-23 - Translation strings override, entity field localization
- 0.3.0 - 2016-05-23 - Translation strings manager
- 0.2.3 - 2016-05-22 - Basic readme file
Support
Support not available.
Hooks
'shop.header' => 'sanatorium/localization::hooks.languages', // @deprecated
'language.switch' => 'sanatorium/localization::hooks.languages',