Skip to content

Latest commit

 

History

History
108 lines (81 loc) · 3.25 KB

2-Configuration.md

File metadata and controls

108 lines (81 loc) · 3.25 KB

2. Configuration

Table of contents

  1. Installation and Setup
  2. Configuration
  3. Usage
  4. FAQ

Settings

// config/localization.php

<?php

return [

    'supported-locales'      => ['en', 'es', 'fr'],

    'accept-language-header' => true,

    'hide-default-in-url'    => false,

    'facade'                 => 'Localization',

    'utf-8-suffix'           => '.UTF-8',

    //...
Name Description
supported-locales Your supported locales. (DUH !)
accept-language-header Using the locale negotiator to get locale from Accept-Language header.
hide-default-in-url If true, the non localized root is treated as the application's default locale (app.locale).
facade The alias name for the facade.
Locale suffix for LC_TIME and LC_MONETARY: Defaults to most common ".UTF-8". Set to blank on Windows systems, change to ".utf8" on CentOS and similar.

Route

// config/localization.php
<?php

return [
    // ...

    'route'                  => [
        'middleware' => [
            'localization-session-redirect' => true,
            'localization-cookie-redirect'  => false,
            'localization-redirect'         => true,
            'localized-routes'              => true,
            'translation-redirect'          => true,
        ]
    ],

    // ...
Name Description
localization-session-redirect Redirect all "non-localized" to the "localized" URLs by using sessions.
localization-cookie-redirect Redirect all "non-localized" to the "localized" URLs by using cookies.
localization-redirect Redirect all "non-localized" to the "localized" URLs.
localized-routes Allows to register all translatable routes.
translation-redirect Allows to translate the route attributes by using the translation event.

Ignored URI/Route from localization

    'ignored-redirection' => [
        //
    ],

You can set a list of uris or route names to ignore from localization checks / redirection.

Locales

// config/localization.php
<?php

return [
    // ...

    'locales'   => [
        // A
        //====================================================>
        'aa'         => [
            'name'   => 'Afar',
            'script' => 'Latn',
            'dir'    => 'ltr',
            'native' => 'Qafar',
        ],

        // ...

        'zu'         => [
            'name'   => 'Zulu',
            'script' => 'Latn',
            'dir'    => 'ltr',
            'native' => 'IsiZulu',
        ],
    ],
];