From 25f836940219c0590c0cee88396e136512fc9a43 Mon Sep 17 00:00:00 2001 From: David mattei Date: Mon, 30 Sep 2024 16:07:22 +0200 Subject: [PATCH] feat(admin/user): new get user language and sort tabs (#1026) --- dev/core-bundle/twig/core.md | 2 +- upgrade.md | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/dev/core-bundle/twig/core.md b/dev/core-bundle/twig/core.md index 4399972..c45f85a 100644 --- a/dev/core-bundle/twig/core.md +++ b/dev/core-bundle/twig/core.md @@ -84,7 +84,7 @@ This filter replaces the filter `|data_label`. Context for the expression: - rawData: array containing the rawData from document or revision -- userLocale: the preferred locale of the user, fallback environment variable `EMSCO_FALLBACK_LOCALE` +- userLocale: the preferred language of the user, default 'en' ```twig {# Print the label in the users preferred locale, fallback to label_fr #} diff --git a/upgrade.md b/upgrade.md index 1a432b6..3481909 100644 --- a/upgrade.md +++ b/upgrade.md @@ -11,6 +11,20 @@ * [version 4.x](#version-4x) * [Tips and tricks](#tips-and-tricks) +## version 5.22.x + +* Removed environment variable: `EMSCO_FALLBACK_LOCALE` +* Add new method `getLanguage` on user object + + preferred locale 'nl_FR' returns 'nl' + ```twig + {% set language = app.user.localePreferred[0:2] %} //before + {% set language = app.user.language %} //now + + {# sort based on user language #} + {% set languages = ['fr', 'nl']|sort((a, b) => a == app.user.language ? -1 : b == app.user.language ? 1 : 0) %} + ``` + ## version 5.21.x * Core twig component Media library: Removed the option `fieldPathOrder`, use new option `sort` (defining all possible sorts)