Git Product home page Git Product logo

Comments (5)

schmittjoh avatar schmittjoh commented on July 29, 2024

Something like this should probably be added to Symfony2's Translation component itself, no?

from jmstranslationbundle.

sroddy avatar sroddy commented on July 29, 2024

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.

schmittjoh avatar schmittjoh commented on July 29, 2024

Implementation wise you probably need a new method on the Translator like the transChoice method with an extra set of arguments.

from jmstranslationbundle.

sroddy avatar sroddy commented on July 29, 2024

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.

schmittjoh avatar schmittjoh commented on July 29, 2024

Closing as this more belongs to Symfony itself.

from jmstranslationbundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.