Laravel Domain Localization

kevindierkx/laravel-domain-localization

Examples

Creating a language selector

Using the helper methods we can create a simple but effective language switcher. The example below uses a Bootstrap dropdown.

<ul class="nav navbar-nav">
    <li class="dropdown">
        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
            {{ Localization::getNameForCurrentLocale() }}
        </a>
        <ul class="dropdown-menu">
            @foreach(Localization::getSupportedLocales() as $locale => $properties)
                <li>
                    <a rel="alternate" hreflang="{{ $locale }}" href="{{ Localization::getLocalizedUrl($locale) }}">
                        {{ Localization::getNameForLocale($locale) }} - {{ Localization::getNativeForLocale($locale) }}
                    </a>
                </li>
            @endforeach
        </ul>
    </li>
</ul>

Flushing, The Netherlands contact@distortedfusion.com
Chamber Of Commerce
74088041
VAT
NL002267401B33
GitHub
Twitter
LinkedIn

Resources


//
kevindierkx/laravel-domain-localization

Copyright © 2023 Distorted Fusion - All rights reserved.