Skip to content

Added support for custom order #406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 18, 2017
Merged

Added support for custom order #406

merged 2 commits into from
Feb 18, 2017

Conversation

sarotnem
Copy link
Contributor

Added another field in the configuration file so the language order can be specified.

Basically we define the order we want in the 'localesOrder' field.
Example 'localesOrder' => ['es','en']

Then in the blade file we output the language selector we call

<ul class="language_bar_chooser">
  @foreach(LaravelLocalization::getLocalesOrder() as $localeCode => $properties)
    <li>
      <a rel="alternate" hreflang="{{$localeCode}}" href="{{LaravelLocalization::getLocalizedURL($localeCode) }}">
        {{ $properties['native'] }}
      </a>
    </li>
  @endforeach
</ul>

and then the languages will have the order we specified. Don't forget to run php artisan config:cache after a config change

@mcamara
Copy link
Owner

mcamara commented Feb 17, 2017

Can you add this function to the README.md? Thanks! 👍

@sarotnem
Copy link
Contributor Author

For some reason Travis is failing with 5.6 and hhvm... Nothing but the readme.md was changed

@mcamara mcamara merged commit c27cb0d into mcamara:master Feb 18, 2017
@mcamara
Copy link
Owner

mcamara commented Feb 18, 2017

Thanks for the changes! I'll take a look to the tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants