Comments (5)
Something like this should probably be added to Symfony2's Translation component itself, no?
from jmstranslationbundle.
I posted the issue on Symfony's project too. However I think that this could be an enhancement that a Bundle could first provide and maybe at a certain point could be included in the main project (once it gains a certain level of maturity). I can help developing it (because it's something i'm going to use really soon in my application) here or directly on symfony project, but first I wanted some advices about how to proceed from someone who already extended/improved the core behaviour.
from jmstranslationbundle.
Implementation wise you probably need a new method on the Translator like the transChoice method with an extra set of arguments.
from jmstranslationbundle.
I've seen the transchoice method and the approach is really simple: it takes the string and split it with the | sign. Then, given a specific set of rules, or using the standard one, it choose what plural form to use depending on the number given as parameter. this pipe-approach risks to be a mess if not coded the right way.
One possible approach is to extend the tags and range definitions with something like this:
%user% m{1}, subject m, %friend% {1}m, viewing m: %user% wrote on %friend%'s wall for his birthday|%user% m[2,Inf], subject m, %friend% {1}f, viewing m: %user% wrote on %friend%'s wall for her birthday
In the symfony documentation it's written: The tags can be any descriptive string that ends with a colon (:). The tags also do not need to be the same in the original message as in the translated one.
So basically we are using commas to separate variables, a space to specify gender/number of each variable, gender can be m/f/n, number can be any explicit interval notation taken from this: http://api.symfony.com/master/Symfony/Component/Translation/Interval.html
Using the tags we could possibly even extend the already existing transchoice method (although a new one should be more clear). The only difference is that the passed variable should not be a string/number but an array('string' => 'Mark, John and 2 others', 'number' => 4, 'gender' => 'm') and that we don't need the third parameter anymore
What do you think about it?
from jmstranslationbundle.
Closing as this more belongs to Symfony itself.
from jmstranslationbundle.
Related Issues (20)
- Twig 3 support HOT 3
- Symfony 5 dependencies update HOT 4
- New major release HOT 1
- 1.5 => simplexml_load_file() expects parameter 1 to be a valid path, object given HOT 8
- ExtractTranslationCommand unlink() expects parameter 1 to be a valid path, object given HOT 1
- jms/translation-bundle (1.5.2) HOT 4
- XliffLoader depends on state of libxml_disable_entity_loader HOT 2
- strtolower() expects parameter 1 to be string, object given HOT 3
- KNP/DoctrineBehavior - Translation Entities error on translation:extract command
- Notice: Undefined property: PhpParser\Node\Expr\Closure::$items
- Support for intl-icu translation files HOT 3
- Notice: Trying to get property 'key' of non-object
- All Form Constraint options are extracted without checking if it's a message or not
- Error ArrayStructureDumper
- Command conflict with framework bundle
- Compatibility with Symfony6 HOT 5
- String interpolation deprecation notices with PHP 8.2 HOT 2
- Is this a known error ? HOT 2
- Doctrine/Annotations as required dependency HOT 1
- Typo in dumper note
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 jmstranslationbundle.