{% set admin = block_context.settings.admin %}
{% if admin.class is translatable %}
{% set object = block_context.settings.object %}
{% set object_id = object ? admin.id(object) : null %}
{% set locale_switcher_route = block_context.settings.locale_switcher_route|default(object_id is not null ? 'edit' : 'create') %}
{% set locale_switcher_route_parameters = block_context.settings.locale_switcher_route_parameters %}
<div class="locale_switcher">
{% apply spaceless %}
{% for locale in sonata_translation_locales %}
<a href="{{ admin.generateUrl(
locale_switcher_route,
{'id': object_id, 'tl': locale}|merge(locale_switcher_route_parameters)
) }}"
accesskey=""
{% if block_context.settings.current_locale == locale %}class="active"{% endif %}
title="{{ 'admin.locale_switcher.tooltip' |trans([], 'SonataTranslationBundle') }}">
{{ locale|localeName(app.request.locale) }}
</a>
{% endfor %}
{% endapply %}
</div>
{% endif %}