Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [01:14 PM] markcarver: steveoliver: ping
- [01:27 PM] steveoliver: markcarver: hola
- [01:28 PM] markcarver: steveoliver: hey there, don't see anyone else on and was told you know a lot about twig
- [01:28 PM] steveoliver: what's goin' on?
- [01:29 PM] markcarver: steveoliver: tryin to figure out how to do #67 in https://drupal.org/node/1927584
- [01:29 PM] Druplicon: https://drupal.org/node/1927584 => Handle trans block as Twig extension [#1927584] => Drupal core, base system, major, needs work, 69 comments, 13 IRC mentions
- [01:30 PM] steveoliver: is the point of this issue to not have to pass and indexed array of args to t() ?
- [01:30 PM] steveoliver: s/and/an/
- [01:31 PM] markcarver: kinda yeah
- [01:31 PM] steveoliver: i get it … by name, but not needing prefix
- [01:31 PM] steveoliver: ! @ %
- [01:31 PM] steveoliver: those are identifiers inline
- [01:32 PM] steveoliver: k, got it
- [01:32 PM] steveoliver: so what's not working about #67?
- [01:32 PM] markcarver: throws an error
- [01:32 PM] steveoliver: same as 2 days ago?
- [01:33 PM] steveoliver: value of Twig_Node_String or whatever ?
- [01:33 PM] markcarver: no, that was a different error, we were tryin to prefix the variable names, like {{ %name }}
- [01:33 PM] steveoliver: k, so you're effectively working at #68 ?
- [01:34 PM] markcarver: with #67, joel had the ideal that we would just send the list of arguments via trans(arg1, arg2)
- [01:34 PM] markcarver: yes
- [01:35 PM] markcarver: not sure why #68 failed, looks like some date issue… i'll re-queue
- [01:36 PM] steveoliver: ew, i don't like plural
- [01:37 PM] markcarver: why not?
- [01:37 PM] steveoliver: can we switch that around, plural case first?
- [01:39 PM] steveoliver: https://gist.github.com/joelpittet/742f9ee5c9c6ac41c39e#
- [01:39 PM] steveoliver: ...anyways...
- [01:39 PM] markcarver: oooh, for the format_plural block, not trans
- [01:40 PM] steveoliver: yeah, sidetracked...
- [01:40 PM] steveoliver: back to trans
- [01:40 PM] markcarver: lol well I kind of agree there, but then you have to different modifiers between format_plural and trans
- [01:41 PM] markcarver: two different syntax*
- [01:42 PM] steveoliver: k, so how do i reproduce your issue?
- [01:43 PM] markcarver: hold on, i'll do a gist patch
- [01:44 PM] markcarver: steveoliver: do you xdebug?
- [01:44 PM] markcarver: with phpstorm
- [01:44 PM] steveoliver: every day
- [01:47 PM] markcarver: steveoliver: http://pastebin.com/TbffXQDp
- [01:48 PM] markcarver: you can include the xdebug stuff if you need it, I can't really make heads or tails on where to actually set a breakpoint in twig tbh
- [02:11 PM] steveoliver: markcarver: have we always had this overlap of implementation of t and format_plural like this?
- [02:12 PM] steveoliver: s/had/supported/
- [02:12 PM] markcarver: not sure if I follow
- [02:13 PM] markcarver: this issue is to introduce the trans and format_plural block
- [02:13 PM] steveoliver: twig_theme_test.trans.html.twig
- [02:13 PM] steveoliver: twig_theme_test.trans.html.twig
- [02:13 PM] steveoliver: that test case
- [02:13 PM] markcarver: no, this is new
- [02:13 PM] steveoliver: is this new
- [02:13 PM] steveoliver: seems a lil strange
- [02:13 PM] steveoliver: what am i missing?
- [02:13 PM] markcarver: read the issue summary
- [02:14 PM] steveoliver: k, i will, again
- [02:14 PM] steveoliver: format_plural isn't in problem/motivation
- [02:15 PM] steveoliver: funny, first in the proposed resolution(s), though
- [02:15 PM] markcarver: well it'll get solved once we figure out the trans block
- [02:15 PM] markcarver: the issue summary is a little outdated right now
- [02:15 PM] markcarver: which is why it's tagged as needing an update
- [02:16 PM] markcarver: read my comment on #65
- [02:16 PM] markcarver: in
- [02:16 PM] steveoliver: k
- [02:17 PM] markcarver: or rather just #58 and on
- [02:17 PM] markcarver: gives you an idea of what the issue now really is
- [02:22 PM] markcarver: steveoliver: basically we're just trying to figure out how to pass the different prefixed argument names to the t() and format_plural() functions.
- [02:22 PM] markcarver: take for instance existing .po files, they specify something like "%count comments."
- [02:22 PM] markcarver: which in reality get's translated and then themed into something like "<em class="placeholder">2</em> comments."
- [02:23 PM] markcarver: !count comments => 2 comments.
- [02:24 PM] markcarver: we had talked about just adding the "<em class="placeholder">{{ count }}</em>
- [02:24 PM] markcarver: to the template, but that will then throw off the .po files
- [02:25 PM] markcarver: needless to say, this is a complex problem, just not sure of the right "twig" way to do it
- [02:26 PM] steveoliver: well tags are the most complex extension to make for twig, so doing two at the same time is getting messy
- [02:26 PM] steveoliver: this issue should stick with trans, then spin off a new issue for format_plural, I think
- [02:26 PM] markcarver: personally, i think the "format_plural" is rather redundant tbg
- [02:26 PM] markcarver: tbh
- [02:27 PM] steveoliver: format_plural in the middle of trans is a wtf to me at this point
- [02:27 PM] steveoliver: in this format at least
- [02:27 PM] steveoliver: .po files aren't concerned with plural, as gabor pointed out in #21, are they?
- [02:30 PM] markcarver: steveoliver: no, .po files aren't concerned with plural
- [02:30 PM] markcarver: the issue really isn't about plural
- [02:30 PM] steveoliver: k, that point is agreed.
- [02:30 PM] markcarver: the issue is about how to out the variable, !name => raw
- [02:30 PM] markcarver: %name => placeholder
- [02:31 PM] markcarver: and that does concern the .po files
- [02:31 PM] steveoliver: right
- [02:31 PM] steveoliver: trans tag needs to support three custom tokens
- [02:32 PM] steveoliver: each with only a opening terminator
- [02:32 PM] markcarver: what are tokens… I saw this in the debug, but didn't know if that was the right approach
- [02:32 PM] steveoliver googles twig docs
- [02:32 PM] markcarver: {{ }}
- [02:32 PM] steveoliver: that is a tag
- [02:32 PM] markcarver: %name%
- [02:32 PM] markcarver: that's a token
- [02:33 PM] steveoliver: right
- [02:33 PM] markcarver: so the other problem with that is
- [02:34 PM] markcarver: how do we determine which token should be used from the template?
- [02:34 PM] markcarver: right now, it's only {{ name }}
- [02:34 PM] steveoliver: well that was my first question: are we trying to get rid of the associative array of replacements given to trans/t ?
- [02:35 PM] steveoliver: because that's how we do it in php (t())
- [02:35 PM] steveoliver: we pass a keyed array
- [02:35 PM] markcarver: like what's in the summary?
- [02:35 PM] markcarver: <p class="submitted">Submitted by !author on @date|t({ '!author': 'author.name', '@date': 'date' })</p>
- [02:36 PM] steveoliver: of course
- [02:36 PM] markcarver: the whole point of this issue is to get rid of that
- [02:36 PM] steveoliver: i don't think the values are single quoted, though
- [02:38 PM] markcarver: which leads me back to #67
- [02:38 PM] steveoliver: so the idea is to be able to do {% trans(author, date) %}Submitted by !author on @date{{ endtrans }}
- [02:38 PM] steveoliver: which is getting murky as far as readability in my mind...
- [02:38 PM] markcarver: in theory
- [02:39 PM] markcarver: I'm half tempted to say this is nearly improbable
- [02:39 PM] steveoliver: what if a placeholder name you don't want to be, say as long as, the value name
- [02:40 PM] steveoliver: associative array++
- [02:40 PM] steveoliver: express intent, clarify connection between things
- [02:40 PM] steveoliver: and allow placeholder to not be long, akward expressions in some cases?
- [02:41 PM] steveoliver: ?
- [02:42 PM] steveoliver: i think the t filter is a lil akward, but at least it's consistent with php syntax
- [02:42 PM] steveoliver: but that doesn't matter
- [02:42 PM] steveoliver: since t() is now more in the theme layer where it should be
- [02:42 PM] steveoliver: so trans, i think can work, but I think the associative array has to stay
- [02:43 PM] markcarver: you mean like {% trans({ '!author': 'author.name', '@date': 'date' }) %}
- [02:44 PM] steveoliver: {% trans('!foo':element.foo, '@bar':element.prop.bar) %} This is some !foo and @bar.{% endtrans %}
- [02:44 PM] markcarver: you mean like {% trans({ '!author': author.name, '@date': date }) %}
- [02:44 PM] steveoliver: eifhr
- [02:44 PM] steveoliver: right
- [02:44 PM] steveoliver: i forgot the {} for the array, but yeah
- [02:44 PM] markcarver: i copied the ' around the var names lol
- [02:44 PM] markcarver: honestly i'm ok with that, but at that point isn't that just a t block?
- [02:45 PM] markcarver: I mean we have a t filter
- [02:45 PM] steveoliver: yes, turned upside down
- [02:45 PM] markcarver: this is better syntactically IMHO though
- [02:46 PM] steveoliver: yeah, i can dig this syntax over t() filter
- [02:46 PM] markcarver: because you're translating a block of text, providing the arguments to this block in the beginning
- [02:46 PM] steveoliver: right
- [02:46 PM] steveoliver: it's cleaner
- [02:46 PM] steveoliver: +1
- [02:46 PM] markcarver: much cleaner
- [02:46 PM] steveoliver: as for the losing the associative array of replacements idea...
- [02:46 PM] markcarver: honestly i don't care about that
- [02:47 PM] steveoliver: it could be done, but i don't think it'd really help AND it'd be a pita to implement
- [02:47 PM] markcarver: we can't lose them…. believe me I tried
- [02:47 PM] steveoliver: -1
- [02:47 PM] steveoliver: k
- [02:47 PM] markcarver: so really the trans block should just be a t block
- [02:48 PM] markcarver: to coincide with the t function
- [02:48 PM] markcarver: we could still give it plural support though right?
- [02:48 PM] steveoliver: but the args are opposite in the t block twig implementation
- [02:48 PM] markcarver: ?
- [02:48 PM] steveoliver: t('text', array(replacements))
- [02:49 PM] steveoliver: trans(replacements, text)
- [02:49 PM] steveoliver: i think format_plural is all wrong in this issue
- [02:49 PM] markcarver: not format_plural
- [02:49 PM] markcarver: the plural modifier in trans
- [02:49 PM] steveoliver: ?
- [02:50 PM] markcarver: which switches the function from t() to format_plural() in the trans block
- [02:50 PM] markcarver: lol just letting you know… I didn't create this mess, I've just inherited it
- [02:50 PM] steveoliver: i know
- [02:51 PM] steveoliver: this is jen's idea, i think
- [02:51 PM] steveoliver: i think i can kinda see the plural switch in trans
- [02:51 PM] steveoliver: tricky… :)
- [02:51 PM] markcarver: honestly, I like it
- [02:51 PM] markcarver: it helps reduce the code
- [02:51 PM] markcarver: from a template standpoint
- [02:52 PM] markcarver: so....
- [02:52 PM] markcarver: I'm thinking the format_plural block is redundant entirely
- [02:52 PM] markcarver: we can keep the trans name for the block
- [02:52 PM] markcarver: which is "similar" to t()
- [02:53 PM] markcarver: but has the ability to add a plural modifier
- [02:53 PM] steveoliver: {% trans({'@name':person.name}, count) %}Please get an apple for @name.{% plural %}Please get {{ count }} apples for @name.{% endtrans %}
- [02:53 PM] markcarver: no...
- [02:53 PM] steveoliver: Q: do we need to pass count into trans?
- [02:53 PM] steveoliver: in your example so far, you haven't
- [02:54 PM] markcarver: {% trans({'@name':person.name}) %}Please get an apple for @name.{% plural count %}Please get {{ count }} apples for @name.{% endtrans %}
- [02:54 PM] steveoliver: that works
- [02:54 PM] steveoliver: ok
- [02:54 PM] markcarver: um...
- [02:54 PM] steveoliver: ?
- [02:54 PM] markcarver: {% trans({'@name':person.name}) %}Please get an apple for @name.{% plural count %}Please get !count apples for @name.{% endtrans %}
- [02:55 PM] steveoliver: right
- [02:55 PM] markcarver: that looks good to me
- [02:55 PM] steveoliver: wait...
- [02:55 PM] markcarver: haha
- [02:55 PM] steveoliver: that's where things get funky
- [02:56 PM] steveoliver: count will always be an integer when used as a switch for count
- [02:56 PM] steveoliver: last count == plural, sorry
- [02:56 PM] markcarver: {% trans({'@name':person.name}) %}Please get an apple for @name.{% plural apples %}Please get !count apples for @name.{% endtrans %}
- [02:56 PM] steveoliver: but that !count token has no value in the incoming replacement arts
- [02:57 PM] steveoliver: the !count key doesn't exist in the incoming args
- [02:57 PM] steveoliver: and that really is only a print statement
- [02:57 PM] steveoliver: {{ count }} makes sense
- [02:57 PM] steveoliver: !count does not
- [02:57 PM] markcarver: not translatable
- [02:58 PM] steveoliver: mmm
- [02:58 PM] markcarver: the plural modifier in the trans block injects the count automatically
- [02:58 PM] steveoliver: how are we going to translate integers?
- [02:58 PM] markcarver: {% trans({'@name':person.name}) %}Please get an apple for @name.{% plural apples %}Please get @count apples for @name.{% endtrans %}
- [02:58 PM] steveoliver: "injects the count automatically" ?
- [02:58 PM] markcarver: https://api.drupal.org/api/drupal/core!includes!common.inc/function/format_plural/8
- [02:59 PM] markcarver: the plural modifier switches the function called to format_plural() from t()
- [02:59 PM] steveoliver: i know
- [02:59 PM] steveoliver: what do you mean by "injects the count automatically" ?
- [03:00 PM] steveoliver: but that'll always be an integer
- [03:00 PM] markcarver: format_plural() takes the $count param and sets it in the argument list (see the funciton): $args['@count'] = $count;
- [03:00 PM] markcarver: automatically
- [03:00 PM] markcarver: we don't need to pass the count as a variable
- [03:00 PM] steveoliver: i know what the function does
- [03:00 PM] steveoliver: i know we don't
- [03:01 PM] steveoliver: i'm saying the var that we give to the plural modifier will always be an int
- [03:01 PM] markcarver: it should be yes
- [03:01 PM] steveoliver: why are we saying !count
- [03:01 PM] steveoliver: ?
- [03:01 PM] markcarver: because I forgot it's really @count
- [03:01 PM] markcarver: which is injected automatically by format_plural()
- [03:02 PM] steveoliver: that saying 'don't format this token', just print it
- [03:02 PM] markcarver: that's what the function sets as the argument to use...
- [03:03 PM] markcarver: i'm confused
- [03:03 PM] steveoliver: what 's wrong with this:
- [03:03 PM] steveoliver: {% trans({'@name':http://person.name/}) %}Please get an apple for @name.{% plural count %}Please get {{ count }} apples for @name.{% endtrans %}
- [03:03 PM] steveoliver: ?
- [03:04 PM] steveoliver: {% plural count %} evaluates count, {{ count }} prints it
- [03:04 PM] steveoliver: !count, prints count
- [03:04 PM] steveoliver: but is less clear
- [03:04 PM] markcarver: because then you're passing "Please get 2 apples for @name" to format plural
- [03:04 PM] steveoliver: right
- [03:04 PM] markcarver: translation....
- [03:04 PM] markcarver: .po files aren't count to have 2 in the string
- [03:04 PM] markcarver: they're going to have @count
- [03:05 PM] steveoliver: k, gotya
- [03:05 PM] markcarver: because @count changes
- [03:05 PM] steveoliver: sorry
- [03:05 PM] markcarver: lol it's all good
- [03:05 PM] markcarver: I'll admit… I was scratching my head for a bit
- [03:06 PM] steveoliver: ok
- [03:06 PM] steveoliver: with that all out of the way...
- [03:07 PM] markcarver: {% trans({ '@name' : person.name }) %}@name has only made one comment.{% plural comments %}@name has made @count comments.{% endtrans %}
- [03:07 PM] steveoliver: {% set apple_count = count(apples) %}{% trans({'@name':user.name, '!count': apples_count}) %}Please get @name !count apples.{% endtrans %}
- [03:08 PM] steveoliver: scratch that — didn't mean to hit enter
- [03:08 PM] markcarver: {% trans({ '@name' : user.name }) %}@name has only made one comment.{% plural comments %}@name has made @count comments.{% endtrans %}
- [03:09 PM] steveoliver: ...{% plural apple_count %}
- [03:09 PM] markcarver: I like to give drupalist examples
- [03:09 PM] markcarver: drupalistic*
- [03:09 PM] steveoliver: ok, but where is @count mapped?
- [03:09 PM] steveoliver: magically in the background?
- [03:09 PM] steveoliver: i think that may not be good
- [03:09 PM] markcarver: yes, in http://drupalcode.org/project/drupal.git/blob/HEAD:/core/includes/common.inc#l938
- [03:10 PM] steveoliver: mmm
- [03:10 PM] markcarver: we don't have to worry about passing the count into the argument list
- [03:10 PM] markcarver: format_plural() does this for us
- [03:11 PM] steveoliver: k
- [03:11 PM] steveoliver: i see
- [03:12 PM] markcarver: {% plural count %} will switch the function the trans block is using from t() to format_plural()
- [03:12 PM] markcarver: if it's more than one
- [03:12 PM] steveoliver: yep
- [03:12 PM] steveoliver: feature, cool
- [03:13 PM] markcarver: which is why I'm thinking that the {% format_plural %} block is now redundant
- [03:13 PM] markcarver: because format_plural() is also translated
- [03:13 PM] steveoliver: cuz it calls t/trans anyways
- [03:13 PM] steveoliver: right
- [03:14 PM] steveoliver: so we'd be kinda switching things up
- [03:14 PM] steveoliver: having trans be the entry point
- [03:14 PM] markcarver: well, we're going to have to
- [03:14 PM] markcarver: there's no other way to get the vars and .po files to work otherwise
- [03:14 PM] steveoliver: so what would we do in twig if we know we are only translating a plural form string?
- [03:15 PM] steveoliver: just use trans, yep
- [03:15 PM] markcarver: exactly
- [03:15 PM] markcarver: we can still leave the |t filter in…. for those that need it
- [03:15 PM] markcarver: or want to use it
- [03:16 PM] markcarver: but the power of plural really lies in {% trans() %}
- [03:16 PM] steveoliver: trans is just a different syntax for format_plural really
- [03:16 PM] markcarver: in theory, you could use {% trans() %} for just t()
- [03:16 PM] steveoliver: ^^ right
- [03:17 PM] markcarver: and TBCH… I think it really should be {% translate() %}
- [03:17 PM] steveoliver: translate +1
- [03:17 PM] steveoliver: "trans is just a different syntax for format_plural really" — what do you think?
- [03:18 PM] markcarver: {% plural count %} only makes it that
- [03:18 PM] steveoliver: just kinda mixed around a lil, with the count being not passed in, as it is in format_plural
- [03:18 PM] markcarver: in reality {% translate() %} can be either t() or format_plural()
- [03:19 PM] markcarver: which is why I think it should be called {% translate() %} to no confuse with either t() or format_plural()
- [03:19 PM] markcarver: because the syntax IS different
- [03:19 PM] steveoliver: switching on a context variable, not an explicit arg to the callback
- [03:19 PM] steveoliver: i like translate
- [03:20 PM] steveoliver: "Where does count come from?" question is still a little "Eh..."
- [03:20 PM] markcarver: _context
- [03:20 PM] steveoliver: i know
- [03:20 PM] markcarver: of the template file
- [03:20 PM] steveoliver: right
- [03:20 PM] steveoliver: that's cooll
- [03:20 PM] steveoliver: ok,
- [03:20 PM] steveoliver: translate tag with array of args...
- [03:21 PM] markcarver: tag or block?
- [03:21 PM] markcarver: can blocks have an array of arguments?
- [03:21 PM] steveoliver: well this is not a block
- [03:21 PM] steveoliver: a block is a codeblock, i.e. region in a template that can be inherited, overriden...
- [03:21 PM] steveoliver: we don't implement any
- [03:21 PM] markcarver: {% trans({ '@name' : user.name }) %}@name has only made one comment.{% plural comments %}@name has made @count comments.{% endtrans %}
- [03:21 PM] markcarver: that's a block
- [03:22 PM] steveoliver: that is a tag, i'm pretty sure
- [03:22 PM] markcarver: {% endtrans %}
- [03:22 PM] markcarver: that makes it a block yes?
- [03:22 PM] steveoliver: {% block header %}Page Header{% endblock %} is a block
- [03:23 PM] steveoliver: http://twig.sensiolabs.org/doc/tags/block.html
- [03:23 PM] markcarver: nm… I'm confusing the concept of and ending tag with block
- [03:23 PM] steveoliver: http://twig.sensiolabs.org/doc/tags/extends.html
- [03:23 PM] markcarver: an*
- [03:24 PM] steveoliver: lol, "block" is an imlpementation of a tag, specifying a chunk of code that can be replaced, inherited
- [03:24 PM] markcarver: yep, on board now
- [03:24 PM] steveoliver: so tag
- [03:24 PM] steveoliver: translate tag
- [03:24 PM] steveoliver: takes args
- [03:24 PM] steveoliver: one for now
- [03:24 PM] steveoliver: being the keyed array of replacements
- [03:24 PM] markcarver: yes
- [03:25 PM] steveoliver: as we've had as the second arg to t() and the fourth arg to format_plural()
- [03:25 PM] steveoliver: s/we've had/we have/
- [03:25 PM] markcarver: yes
- [03:25 PM] steveoliver: and that tag supports tokens
- [03:26 PM] markcarver: for the arguments provided
- [03:26 PM] markcarver: yes
- [03:26 PM] markcarver: no
- [03:26 PM] steveoliver: those tokens have only an opening identifier
- [03:26 PM] markcarver: we don't need tokens
- [03:26 PM] steveoliver: you're right....
- [03:26 PM] steveoliver: those get passed to t()
- [03:26 PM] markcarver: that list of args passed to {% translate() %} just gets passed through
- [03:26 PM] markcarver: yes
- [03:27 PM] steveoliver: Twig needn't care
- [03:27 PM] markcarver: nope
- [03:27 PM] steveoliver: k
- [03:27 PM] steveoliver: that tag has the plural switch
- [03:27 PM] markcarver: exactly
- [03:28 PM] markcarver: which will give us an extra @count arg to use in the plural text
- [03:28 PM] steveoliver: passes second chunk to format_plural
- [03:28 PM] steveoliver: cool
- [03:28 PM] steveoliver: yay no twig token parsing
- [03:28 PM] markcarver: +1
- [03:28 PM] steveoliver: are we any better off now than we were an hour ago?
- [03:29 PM] markcarver: oh most definitely
- [03:29 PM] steveoliver: i think so
- [03:29 PM] steveoliver: cool
- [03:30 PM] steveoliver: are we done? :)
- [03:30 PM] markcarver: yes, I can summarize what needs to go in that issue
- [03:30 PM] markcarver: hell might even attempt a patch, who knows
- [03:30 PM] steveoliver: markcarver++
- [03:30 PM] steveoliver: :)
- [03:30 PM] steveoliver: i've got an issue to update, myself
- [03:30 PM] markcarver: do you know how I might get the arguments for the tag though?
- [03:31 PM] steveoliver: i was wondering about that..
- [03:31 PM] markcarver: I was kinda stumped on that one
- [03:31 PM] steveoliver: that's where we were at?
- [03:31 PM] steveoliver: lemme see
- [03:31 PM] steveoliver: http://twig.sensiolabs.org/doc/tags/macro.html ?
- [03:31 PM] steveoliver: hmm
- [03:32 PM] steveoliver: not quite, but interesting...
- [03:35 PM] markcarver: steveoliver++
- [03:35 PM] markcarver: steveoliver++
- [03:35 PM] markcarver: thanks for your patience and help
- [03:37 PM] steveoliver: {% translate with {'@author:user.name, '@date':node.date} %}Submitted by @name on @date.{% endtranslate %} may be the form
- [03:37 PM] steveoliver: yes, that is the form
- [03:37 PM] steveoliver: we won't be doing {% translate({args}) %} form
- [03:37 PM] steveoliver: that is function form
- [03:37 PM] steveoliver: from my googling
- [03:37 PM] steveoliver: http://mark-story.com/posts/view/making-custom-tags-in-twig
- [03:38 PM] markcarver: steveoliver++
- [03:38 PM] markcarver: thank you!
- [03:38 PM] steveoliver: i.e http://stackoverflow.com/questions/10557436/receiving-arguments-from-twig-templates-in-symfony2
- [03:39 PM] steveoliver: {% translate with { {'@name':name, '@date':date} }String…{% endtranslate %}
- [03:39 PM] steveoliver: the
- [03:39 PM] steveoliver: " with { }" === "functionname(...)"
- [03:40 PM] steveoliver: u good?
- [03:40 PM] steveoliver: i'll be around for a few hours
- [03:40 PM] steveoliver: markcarver++
- [03:40 PM] markcarver: hmm, I don't get the last part
- [03:40 PM] steveoliver: ok
- [03:40 PM] markcarver: " with { }" === "functionname(...)"
- [03:41 PM] steveoliver: the " … with {}" … indicates that the contents of the {} braces are the arguments that are passed to the function represented by the tag
- [03:42 PM] steveoliver: function/method callback, whatever it is..
- [03:42 PM] steveoliver: make sense?
- [03:42 PM] markcarver: oh...
- [03:42 PM] steveoliver: so there is a form where we don't pass args
- [03:42 PM] steveoliver: {% translate %} is valid
- [03:42 PM] steveoliver: it passes no args in..
- [03:42 PM] markcarver: gotcha
- [03:43 PM] steveoliver: which would be cool if plural strings don't need replacements
- [03:43 PM] steveoliver: or rather singular/plural switches don't need to consider replacements
- [03:43 PM] steveoliver: ..that don't need to consider..
- [03:44 PM] markcarver: yeah
- [03:44 PM] steveoliver: {% translate %}Gimme an apple{% plural count %}Gimme some apples!{% endtranslate %}
- [03:44 PM] markcarver: well you could pass the @count still
- [03:45 PM] steveoliver: tag name 'translate' in that example is :(
- [03:45 PM] markcarver: which would be cool
- [03:45 PM] steveoliver: yeah, format_plural would get count
- [03:45 PM] steveoliver: clean
- [03:45 PM] steveoliver: might need to think on the translate name for the tag...
- [03:45 PM] steveoliver: ?
- [03:45 PM] markcarver: how so?
- [03:45 PM] markcarver: it still gets translated
- [03:46 PM] steveoliver: oh, yeah...
- [03:46 PM] markcarver: both for languages
- [03:46 PM] steveoliver: derp
- [03:46 PM] steveoliver: both scenarios
- [03:46 PM] markcarver: and it transforms from singular or plural scenarios
- [03:46 PM] steveoliver: bad ass
- [03:46 PM] steveoliver: i like, alot
- [03:46 PM] steveoliver: a lot ;)
- [03:46 PM] markcarver: hehe me too
- [03:46 PM] markcarver: finally some real power
- [03:46 PM] markcarver: smart*
- [03:46 PM] steveoliver: yeah, very clean
- [03:47 PM] markcarver: alright, I'll get started on this
- [03:47 PM] markcarver: thanks again for all your help
- [03:47 PM] markcarver: steveoliver++
- [03:47 PM] steveoliver: yw. thanks for your patience too
- [03:48 PM] markcarver: :D
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement