Comments (4)
I'm bringing this subject back to 0.2-dev and extending it.
I realize we can't translate strings based on a number. The old way was to use transchoice
:
{{ '{0} No users|{1} 1 user|]1,Inf[ %count% users' | trans(users|length) }}
But transchoice
no longer exists since Symfony 5! Two solutions:
- Use conditions in the template:
{% if users|length == 0 %}
{{ 'No users' | trans }}
{% elseif users|length == 1 %}
{{ '1 user' | trans }}
{% else %}
{{ '%count% users' | trans({ '%choice%': users|length }) }}
{% endif %}
- use ICU format
The first solution is definitely not an option on the long term and makes things complicated.
The second solution looks better (ICU is the current supported format), but I had troubles the last time I tried.
Hopefully problems have been fixed since then.
The migration to ICU format should be done in four steps:
- migrate files to
+intl-icu.yaml
- adapt current strings to use ICU format
- change translation keys to use a keyword format (e.g.
users.number
) (ICU format is more verbose) - adapt the
make i18n-extract
script?
from bileto.
References:
- symfony/symfony-docs#11002 (comment)
- https://symfony.com/doc/current/translation.html
- https://symfony.com/doc/current/reference/formats/message_format.html
from bileto.
I just migrated the translations to ICU format. It was painful because I wanted to use a keyword format for keys. At least it's done for the messages domain.
The validators domain is not fully migrated since the {{ value }}
variables have to be renamed to { value }
and there are a lot of strings. Instead, I'd like to remove all the unused keys (generated by Symfony) and only keep the ones that I explicitly use in Bileto. Btw, it seems that TranslatableMessage
is optional for entity assertions messages (see https://symfony.com/doc/current/validation/translations.html), BUT the extract
command was only able to find some keys when I tried 🤷
It would be the occasion to improve the error messages to be more assertive and explain what have to be done to fix the errors (e.g. "Choose a different email address since { value } is already used.")
from bileto.
I think I found a solution:
- change the domain of the actual "validators" and "security" (only https://github.com/Probesys/bileto/blob/main/src/Controller/BaseController.php#L33 is concerned) domains to "errors" (but keep the files for the default translations of Symfony)
- stop extracting messages for the "validators" and "security" domains
- extract the "errors" domain as it is done for "messages"
The only potential problem is that I don't know if the --domain
argument of the extract command can take several domains. Otherwise, I'll have to extract "errors" and "messages" with two different commands :/
from bileto.
Related Issues (20)
- List of administrators HOT 1
- Add a page to display information about a user
- Provide a simplified interface to create tickets (API?)
- Link a finished contract to a ticket
- Assign tickets and unaccounted time spent when creating or renewing a contract
- Allow to filter/search into the list of organizations
- List "on-call" times
- Associate email domains with an organization
- Define a default user role HOT 1
- Automatically assign a ticket to a team/agent
- Detect and block spam
- Automatically close a resolved ticket after a certain amount of time HOT 1
- Allow users to reset their password
- Redesign the popup menu on mobile
- Put all the "new" buttons on the right
- Update to PHP-IMAP 5.6 (when released)
- Fix Foundry changing the Symfony error handler
- Bileto a ticket manager with Agile Scrum to manage project and tickets HOT 3
- Allow to import teams' agents
- Allow to import organizations' observers
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bileto.