Adding twig functions for mcamara/laravel-localization

v1.0.2 2017-11-08 14:26 UTC

This package is not auto-updated.

Last update: 2019-06-29 02:42:27 UTC


Adding twig functions for mcamara/laravel-localization



Install with composer

composer require frysch/laravel-localization-twig

Add twig extension in app/config/twigbridge.php

'extensions' => [
    'enabled' => [
        /*** Other enabled extensions ***/

Twig functions

3 functions just maps to LaravelLocalization methods:

l10n_url -> LaravelLocalization::getLocalizedURL

l10n_locales_ordered -> LaravelLocalization::getLocalesOrder

l10n_locales_supported -> LaravelLocalization::getSupportedLocales

l10n_url_by_route sort of maps to LaravelLocalization::getURLFromRouteNameTranslated , but arguments is not in the same order and it defaults to current locale if not supplied. Make sure you put your localized routes in lang/routes.php as per mcamara/laravel-localization instructions.

l10n_is_current_route checks if supplied route is current

public static function getByRoute($route, $attributes = [], $locale = null, $forceDefaultLocation = false)