Skip to content
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

Use app global variable for locale #1562

Merged
merged 1 commit into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions templates/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
See https://symfony.com/doc/current/templates.html#template-inheritance-and-layouts
#}
<!DOCTYPE html>
<html lang="{{ app.request.locale }}">
<html lang="{{ app.locale }}">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
Expand Down Expand Up @@ -102,7 +102,7 @@
{{ render_esi(controller('Symfony\\Bundle\\FrameworkBundle\\Controller\\TemplateController::templateAction', {
'template': 'blog/about.html.twig',
'sharedAge': 600,
'_locale': app.request.locale
'_locale': app.locale
})) }}
{% endblock %}
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/blog/index.xml.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<pubDate>{{ 'now'|date('r', timezone='GMT') }}</pubDate>
<lastBuildDate>{{ (paginator.results|last).publishedAt|default('now')|date('r', timezone='GMT') }}</lastBuildDate>
<link>{{ url('blog_index') }}</link>
<language>{{ app.request.locale }}</language>
<language>{{ app.locale }}</language>

{% for post in paginator.results %}
<item>
Expand Down
4 changes: 2 additions & 2 deletions templates/default/_language_selector.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<a href="#" class="nav-link dropdown-toggle language-selector-dropdown-button" data-toggle="modal" data-target="#locale-selector-modal" role="button" id="locales">
<twig:ux:icon name="tabler:world"/>
{% if display_current_language %}
<span class="current-language">{{ app.request.locale|locale_name }}</span>
<span class="current-language">{{ app.locale|locale_name }}</span>
{% endif %}
<span class="caret"></span>
<span class="sr-only">{{ 'menu.choose_language'|trans }}</span>
Expand All @@ -24,7 +24,7 @@
<div class="modal-body">
<ul class="locales">
{% for locale in locales() %}
{% set is_active = app.request.locale == locale.code %}
{% set is_active = app.locale == locale.code %}
{% set is_rtl = locale.code in ['ar', 'fa', 'he'] %}
<li class="{{ is_active ? 'active' }} {{ is_rtl ? 'rtl' }}" translate="no">
<a class="stretched-link" lang="{{ locale.code }}" hreflang="{{ locale.code }}" href="{{ path(app.request.get('_route', 'blog_index'), app.request.get('_route_params', [])|merge({_locale: locale.code})) }}">
Expand Down