Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Latest commit

 

History

History
88 lines (67 loc) · 2.7 KB

3-Configuration.md

File metadata and controls

88 lines (67 loc) · 2.7 KB

3. Configuration

Settings

// config/localization.php

<?php

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

    'accept-language-header' => true,

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

    'facade'                 => 'Localization',

    //...
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.

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.

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',
        ],
    ],
];