From 0224fbf23a669aef5a3be98169271acb1a73af35 Mon Sep 17 00:00:00 2001 From: ghost Date: Tue, 3 Oct 2023 23:30:50 +0300 Subject: [PATCH] integrate twig/intl-extra to make locale codes translation #19 --- composer.json | 2 + composer.lock | 133 ++++++++++++++++++++++- templates/default/user/info.html.twig | 8 +- templates/default/user/profile.html.twig | 10 +- 4 files changed, 143 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 19f9be0..d53f074 100644 --- a/composer.json +++ b/composer.json @@ -45,6 +45,8 @@ "symfony/web-link": "6.3.*", "symfony/yaml": "6.3.*", "twig/extra-bundle": "^2.12|^3.0", + "twig/intl-extra": "^3.7", + "twig/string-extra": "^3.7", "twig/twig": "^2.12|^3.0" }, "config": { diff --git a/composer.lock b/composer.lock index 2f8b33c..9dbd264 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "12e4a495651b5797393aa13acc4d132f", + "content-hash": "42f94769f35af5500e3ae6ce20dcb64e", "packages": [ { "name": "christeredvartsen/php-bittorrent", @@ -7344,6 +7344,137 @@ ], "time": "2023-07-29T15:34:56+00:00" }, + { + "name": "twig/intl-extra", + "version": "v3.7.1", + "source": { + "type": "git", + "url": "https://github.com/twigphp/intl-extra.git", + "reference": "4f4fe572f635534649cc069e1dafe4a8ad63774d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/twigphp/intl-extra/zipball/4f4fe572f635534649cc069e1dafe4a8ad63774d", + "reference": "4f4fe572f635534649cc069e1dafe4a8ad63774d", + "shasum": "" + }, + "require": { + "php": ">=7.1.3", + "symfony/intl": "^5.4|^6.0", + "twig/twig": "^2.7|^3.0" + }, + "require-dev": { + "symfony/phpunit-bridge": "^5.4|^6.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Twig\\Extra\\Intl\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + } + ], + "description": "A Twig extension for Intl", + "homepage": "https://twig.symfony.com", + "keywords": [ + "intl", + "twig" + ], + "support": { + "source": "https://github.com/twigphp/intl-extra/tree/v3.7.1" + }, + "funding": [ + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/twig/twig", + "type": "tidelift" + } + ], + "time": "2023-07-29T15:34:56+00:00" + }, + { + "name": "twig/string-extra", + "version": "v3.7.1", + "source": { + "type": "git", + "url": "https://github.com/twigphp/string-extra.git", + "reference": "7230d630a25e91cd91a2bd8e2f0e872962507eab" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/twigphp/string-extra/zipball/7230d630a25e91cd91a2bd8e2f0e872962507eab", + "reference": "7230d630a25e91cd91a2bd8e2f0e872962507eab", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/string": "^5.4|^6.0", + "symfony/translation-contracts": "^1.1|^2|^3", + "twig/twig": "^2.7|^3.0" + }, + "require-dev": { + "symfony/phpunit-bridge": "^5.4|^6.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Twig\\Extra\\String\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + } + ], + "description": "A Twig extension for Symfony String", + "homepage": "https://twig.symfony.com", + "keywords": [ + "html", + "string", + "twig", + "unicode" + ], + "support": { + "source": "https://github.com/twigphp/string-extra/tree/v3.7.1" + }, + "funding": [ + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/twig/twig", + "type": "tidelift" + } + ], + "time": "2023-07-29T15:34:56+00:00" + }, { "name": "twig/twig", "version": "v3.7.1", diff --git a/templates/default/user/info.html.twig b/templates/default/user/info.html.twig index e4caf5c..b3fe873 100644 --- a/templates/default/user/info.html.twig +++ b/templates/default/user/info.html.twig @@ -74,17 +74,13 @@ {{ 'Interface'|trans }} - {{ user.locale|trans }} + {{ user.locale|locale_name(user.locale)|u.title }} {{ 'Content filter'|trans }} - {% for locale in user.locales %} -
- {{ locale|trans }} -
- {% endfor %} + {% for i, locale in user.locales %}{% if i > 0 %},{% endif %} {{ locale|locale_name(locale)|u.title }}{% endfor %} diff --git a/templates/default/user/profile.html.twig b/templates/default/user/profile.html.twig index e287961..01da47c 100644 --- a/templates/default/user/profile.html.twig +++ b/templates/default/user/profile.html.twig @@ -71,9 +71,13 @@ @@ -90,7 +94,7 @@ {% endif %} {% endfor %}