Browse Source

integrate twig/intl-extra to make locale codes translation #19

main
ghost 1 year ago
parent
commit
0224fbf23a
  1. 2
      composer.json
  2. 133
      composer.lock
  3. 8
      templates/default/user/info.html.twig
  4. 10
      templates/default/user/profile.html.twig

2
composer.json

@ -45,6 +45,8 @@
"symfony/web-link": "6.3.*", "symfony/web-link": "6.3.*",
"symfony/yaml": "6.3.*", "symfony/yaml": "6.3.*",
"twig/extra-bundle": "^2.12|^3.0", "twig/extra-bundle": "^2.12|^3.0",
"twig/intl-extra": "^3.7",
"twig/string-extra": "^3.7",
"twig/twig": "^2.12|^3.0" "twig/twig": "^2.12|^3.0"
}, },
"config": { "config": {

133
composer.lock generated

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "12e4a495651b5797393aa13acc4d132f", "content-hash": "42f94769f35af5500e3ae6ce20dcb64e",
"packages": [ "packages": [
{ {
"name": "christeredvartsen/php-bittorrent", "name": "christeredvartsen/php-bittorrent",
@ -7344,6 +7344,137 @@
], ],
"time": "2023-07-29T15:34:56+00:00" "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", "name": "twig/twig",
"version": "v3.7.1", "version": "v3.7.1",

8
templates/default/user/info.html.twig

@ -74,17 +74,13 @@
<tr> <tr>
<td class="padding-t-16-px">{{ 'Interface'|trans }}</td> <td class="padding-t-16-px">{{ 'Interface'|trans }}</td>
<td class="padding-t-16-px"> <td class="padding-t-16-px">
{{ user.locale|trans }} {{ user.locale|locale_name(user.locale)|u.title }}
</td> </td>
</tr> </tr>
<tr> <tr>
<td>{{ 'Content filter'|trans }}</td> <td>{{ 'Content filter'|trans }}</td>
<td> <td>
{% for locale in user.locales %} {% for i, locale in user.locales %}{% if i > 0 %},{% endif %} {{ locale|locale_name(locale)|u.title }}{% endfor %}
<div class="padding-y-4-px">
{{ locale|trans }}
</div>
{% endfor %}
</td> </td>
</tr> </tr>
</tbody> </tbody>

10
templates/default/user/profile.html.twig

@ -71,9 +71,13 @@
<select name="locale"> <select name="locale">
{% for locale in locales %} {% for locale in locales %}
{% if locale == user.locale %} {% if locale == user.locale %}
<option value="{{ locale }}" selected="selected">{{ locale|trans }}</option> <option value="{{ locale }}" selected="selected">
{{ locale|locale_name(locale)|u.title }}
</option>
{% else %} {% else %}
<option value="{{ locale }}">{{ locale|trans }}</option> <option value="{{ locale }}">
{{ locale|locale_name(locale)|u.title }}
</option>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</select> </select>
@ -90,7 +94,7 @@
<input name="locales[]" id="{{ locale }}" type="checkbox" value="{{ locale }}" /> <input name="locales[]" id="{{ locale }}" type="checkbox" value="{{ locale }}" />
{% endif %} {% endif %}
<label for="{{ locale }}"> <label for="{{ locale }}">
{{ locale|trans }} {{ locale|locale_name(locale)|u.title }}
</label> </label>
</div> </div>
{% endfor %} {% endfor %}

Loading…
Cancel
Save