Skip to content

Instantly share code, notes, and snippets.

@mcamara
Last active January 4, 2016 00:09
Show Gist options
  • Save mcamara/8539973 to your computer and use it in GitHub Desktop.
Save mcamara/8539973 to your computer and use it in GitHub Desktop.
Language Bar with flags Laravel, Blade, mcamara/laravel-localization
php artisan config:publish mcamara/laravel-localization
php artisan view:publish mcamara/laravel-localization
.flag {
width: 25px;
height: 15px;
background:url('/images/flags.png') no-repeat
}
.flag.flag-de {background-position: -25px 0}
.flag.flag-es {background-position: -50px 0}
.flag.flag-fr {background-position: 0 -15px}
.flag.flag-en {background-position: -25px -15px}
<ul class="language_bar_chooser">
@foreach(LaravelLocalization::getSupportedLocales() as $localeCode => $properties)
@if($localeCode == LaravelLocalization::getCurrentLocale())
<li class="active">
<img class="flag flag-{{$localeCode}}"/>
</li>
@elseif($url = LaravelLocalization::getLocalizedURL($localeCode))
<li>
<a rel="alternate" hreflang="{{$localeCode}}" href="{{$url}}">
<img class="flag flag-{{$localeCode}}"/>
</a>
</li>
@endif
@endforeach
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment