Advertisement
Guest User

Untitled

a guest
Jul 7th, 2013
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.55 KB | None | 0 0
  1. [01:14 PM] markcarver: steveoliver: ping
  2. [01:27 PM] steveoliver: markcarver: hola
  3. [01:28 PM] markcarver: steveoliver: hey there, don't see anyone else on and was told you know a lot about twig
  4. [01:28 PM] steveoliver: what's goin' on?
  5. [01:29 PM] markcarver: steveoliver: tryin to figure out how to do #67 in https://drupal.org/node/1927584
  6. [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
  7. [01:30 PM] steveoliver: is the point of this issue to not have to pass and indexed array of args to t() ?
  8. [01:30 PM] steveoliver: s/and/an/
  9. [01:31 PM] markcarver: kinda yeah
  10. [01:31 PM] steveoliver: i get it … by name, but not needing prefix
  11. [01:31 PM] steveoliver: ! @ %
  12. [01:31 PM] steveoliver: those are identifiers inline
  13. [01:32 PM] steveoliver: k, got it
  14. [01:32 PM] steveoliver: so what's not working about #67?
  15. [01:32 PM] markcarver: throws an error
  16. [01:32 PM] steveoliver: same as 2 days ago?
  17. [01:33 PM] steveoliver: value of Twig_Node_String or whatever ?
  18. [01:33 PM] markcarver: no, that was a different error, we were tryin to prefix the variable names, like {{ %name }}
  19. [01:33 PM] steveoliver: k, so you're effectively working at #68 ?
  20. [01:34 PM] markcarver: with #67, joel had the ideal that we would just send the list of arguments via trans(arg1, arg2)
  21. [01:34 PM] markcarver: yes
  22. [01:35 PM] markcarver: not sure why #68 failed, looks like some date issue… i'll re-queue
  23. [01:36 PM] steveoliver: ew, i don't like plural
  24. [01:37 PM] markcarver: why not?
  25. [01:37 PM] steveoliver: can we switch that around, plural case first?
  26. [01:39 PM] steveoliver: https://gist.github.com/joelpittet/742f9ee5c9c6ac41c39e#
  27. [01:39 PM] steveoliver: ...anyways...
  28. [01:39 PM] markcarver: oooh, for the format_plural block, not trans
  29. [01:40 PM] steveoliver: yeah, sidetracked...
  30. [01:40 PM] steveoliver: back to trans
  31. [01:40 PM] markcarver: lol well I kind of agree there, but then you have to different modifiers between format_plural and trans
  32. [01:41 PM] markcarver: two different syntax*
  33. [01:42 PM] steveoliver: k, so how do i reproduce your issue?
  34. [01:43 PM] markcarver: hold on, i'll do a gist patch
  35. [01:44 PM] markcarver: steveoliver: do you xdebug?
  36. [01:44 PM] markcarver: with phpstorm
  37. [01:44 PM] steveoliver: every day
  38. [01:47 PM] markcarver: steveoliver: http://pastebin.com/TbffXQDp
  39. [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
  40. [02:11 PM] steveoliver: markcarver: have we always had this overlap of implementation of t and format_plural like this?
  41. [02:12 PM] steveoliver: s/had/supported/
  42. [02:12 PM] markcarver: not sure if I follow
  43. [02:13 PM] markcarver: this issue is to introduce the trans and format_plural block
  44. [02:13 PM] steveoliver: twig_theme_test.trans.html.twig
  45. [02:13 PM] steveoliver: twig_theme_test.trans.html.twig
  46. [02:13 PM] steveoliver: that test case
  47. [02:13 PM] markcarver: no, this is new
  48. [02:13 PM] steveoliver: is this new
  49. [02:13 PM] steveoliver: seems a lil strange
  50. [02:13 PM] steveoliver: what am i missing?
  51. [02:13 PM] markcarver: read the issue summary
  52. [02:14 PM] steveoliver: k, i will, again
  53. [02:14 PM] steveoliver: format_plural isn't in problem/motivation
  54. [02:15 PM] steveoliver: funny, first in the proposed resolution(s), though
  55. [02:15 PM] markcarver: well it'll get solved once we figure out the trans block
  56. [02:15 PM] markcarver: the issue summary is a little outdated right now
  57. [02:15 PM] markcarver: which is why it's tagged as needing an update
  58. [02:16 PM] markcarver: read my comment on #65
  59. [02:16 PM] markcarver: in
  60. [02:16 PM] steveoliver: k
  61. [02:17 PM] markcarver: or rather just #58 and on
  62. [02:17 PM] markcarver: gives you an idea of what the issue now really is
  63. [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.
  64. [02:22 PM] markcarver: take for instance existing .po files, they specify something like "%count comments."
  65. [02:22 PM] markcarver: which in reality get's translated and then themed into something like "<em class="placeholder">2</em> comments."
  66. [02:23 PM] markcarver: !count comments => 2 comments.
  67. [02:24 PM] markcarver: we had talked about just adding the "<em class="placeholder">{{ count }}</em>
  68. [02:24 PM] markcarver: to the template, but that will then throw off the .po files
  69. [02:25 PM] markcarver: needless to say, this is a complex problem, just not sure of the right "twig" way to do it
  70. [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
  71. [02:26 PM] steveoliver: this issue should stick with trans, then spin off a new issue for format_plural, I think
  72. [02:26 PM] markcarver: personally, i think the "format_plural" is rather redundant tbg
  73. [02:26 PM] markcarver: tbh
  74. [02:27 PM] steveoliver: format_plural in the middle of trans is a wtf to me at this point
  75. [02:27 PM] steveoliver: in this format at least
  76. [02:27 PM] steveoliver: .po files aren't concerned with plural, as gabor pointed out in #21, are they?
  77. [02:30 PM] markcarver: steveoliver: no, .po files aren't concerned with plural
  78. [02:30 PM] markcarver: the issue really isn't about plural
  79. [02:30 PM] steveoliver: k, that point is agreed.
  80. [02:30 PM] markcarver: the issue is about how to out the variable, !name => raw
  81. [02:30 PM] markcarver: %name => placeholder
  82. [02:31 PM] markcarver: and that does concern the .po files
  83. [02:31 PM] steveoliver: right
  84. [02:31 PM] steveoliver: trans tag needs to support three custom tokens
  85. [02:32 PM] steveoliver: each with only a opening terminator
  86. [02:32 PM] markcarver: what are tokens… I saw this in the debug, but didn't know if that was the right approach
  87. [02:32 PM] steveoliver googles twig docs
  88. [02:32 PM] markcarver: {{ }}
  89. [02:32 PM] steveoliver: that is a tag
  90. [02:32 PM] markcarver: %name%
  91. [02:32 PM] markcarver: that's a token
  92. [02:33 PM] steveoliver: right
  93. [02:33 PM] markcarver: so the other problem with that is
  94. [02:34 PM] markcarver: how do we determine which token should be used from the template?
  95. [02:34 PM] markcarver: right now, it's only {{ name }}
  96. [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 ?
  97. [02:35 PM] steveoliver: because that's how we do it in php (t())
  98. [02:35 PM] steveoliver: we pass a keyed array
  99. [02:35 PM] markcarver: like what's in the summary?
  100. [02:35 PM] markcarver: <p class="submitted">Submitted by !author on @date|t({ '!author': 'author.name', '@date': 'date' })</p>
  101. [02:36 PM] steveoliver: of course
  102. [02:36 PM] markcarver: the whole point of this issue is to get rid of that
  103. [02:36 PM] steveoliver: i don't think the values are single quoted, though
  104. [02:38 PM] markcarver: which leads me back to #67
  105. [02:38 PM] steveoliver: so the idea is to be able to do {% trans(author, date) %}Submitted by !author on @date{{ endtrans }}
  106. [02:38 PM] steveoliver: which is getting murky as far as readability in my mind...
  107. [02:38 PM] markcarver: in theory
  108. [02:39 PM] markcarver: I'm half tempted to say this is nearly improbable
  109. [02:39 PM] steveoliver: what if a placeholder name you don't want to be, say as long as, the value name
  110. [02:40 PM] steveoliver: associative array++
  111. [02:40 PM] steveoliver: express intent, clarify connection between things
  112. [02:40 PM] steveoliver: and allow placeholder to not be long, akward expressions in some cases?
  113. [02:41 PM] steveoliver: ?
  114. [02:42 PM] steveoliver: i think the t filter is a lil akward, but at least it's consistent with php syntax
  115. [02:42 PM] steveoliver: but that doesn't matter
  116. [02:42 PM] steveoliver: since t() is now more in the theme layer where it should be
  117. [02:42 PM] steveoliver: so trans, i think can work, but I think the associative array has to stay
  118. [02:43 PM] markcarver: you mean like {% trans({ '!author': 'author.name', '@date': 'date' }) %}
  119. [02:44 PM] steveoliver: {% trans('!foo':element.foo, '@bar':element.prop.bar) %} This is some !foo and @bar.{% endtrans %}
  120. [02:44 PM] markcarver: you mean like {% trans({ '!author': author.name, '@date': date }) %}
  121. [02:44 PM] steveoliver: eifhr
  122. [02:44 PM] steveoliver: right
  123. [02:44 PM] steveoliver: i forgot the {} for the array, but yeah
  124. [02:44 PM] markcarver: i copied the ' around the var names lol
  125. [02:44 PM] markcarver: honestly i'm ok with that, but at that point isn't that just a t block?
  126. [02:45 PM] markcarver: I mean we have a t filter
  127. [02:45 PM] steveoliver: yes, turned upside down
  128. [02:45 PM] markcarver: this is better syntactically IMHO though
  129. [02:46 PM] steveoliver: yeah, i can dig this syntax over t() filter
  130. [02:46 PM] markcarver: because you're translating a block of text, providing the arguments to this block in the beginning
  131. [02:46 PM] steveoliver: right
  132. [02:46 PM] steveoliver: it's cleaner
  133. [02:46 PM] steveoliver: +1
  134. [02:46 PM] markcarver: much cleaner
  135. [02:46 PM] steveoliver: as for the losing the associative array of replacements idea...
  136. [02:46 PM] markcarver: honestly i don't care about that
  137. [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
  138. [02:47 PM] markcarver: we can't lose them…. believe me I tried
  139. [02:47 PM] steveoliver: -1
  140. [02:47 PM] steveoliver: k
  141. [02:47 PM] markcarver: so really the trans block should just be a t block
  142. [02:48 PM] markcarver: to coincide with the t function
  143. [02:48 PM] markcarver: we could still give it plural support though right?
  144. [02:48 PM] steveoliver: but the args are opposite in the t block twig implementation
  145. [02:48 PM] markcarver: ?
  146. [02:48 PM] steveoliver: t('text', array(replacements))
  147. [02:49 PM] steveoliver: trans(replacements, text)
  148. [02:49 PM] steveoliver: i think format_plural is all wrong in this issue
  149. [02:49 PM] markcarver: not format_plural
  150. [02:49 PM] markcarver: the plural modifier in trans
  151. [02:49 PM] steveoliver: ?
  152. [02:50 PM] markcarver: which switches the function from t() to format_plural() in the trans block
  153. [02:50 PM] markcarver: lol just letting you know… I didn't create this mess, I've just inherited it
  154. [02:50 PM] steveoliver: i know
  155. [02:51 PM] steveoliver: this is jen's idea, i think
  156. [02:51 PM] steveoliver: i think i can kinda see the plural switch in trans
  157. [02:51 PM] steveoliver: tricky… :)
  158. [02:51 PM] markcarver: honestly, I like it
  159. [02:51 PM] markcarver: it helps reduce the code
  160. [02:51 PM] markcarver: from a template standpoint
  161. [02:52 PM] markcarver: so....
  162. [02:52 PM] markcarver: I'm thinking the format_plural block is redundant entirely
  163. [02:52 PM] markcarver: we can keep the trans name for the block
  164. [02:52 PM] markcarver: which is "similar" to t()
  165. [02:53 PM] markcarver: but has the ability to add a plural modifier
  166. [02:53 PM] steveoliver: {% trans({'@name':person.name}, count) %}Please get an apple for @name.{% plural %}Please get {{ count }} apples for @name.{% endtrans %}
  167. [02:53 PM] markcarver: no...
  168. [02:53 PM] steveoliver: Q: do we need to pass count into trans?
  169. [02:53 PM] steveoliver: in your example so far, you haven't
  170. [02:54 PM] markcarver: {% trans({'@name':person.name}) %}Please get an apple for @name.{% plural count %}Please get {{ count }} apples for @name.{% endtrans %}
  171. [02:54 PM] steveoliver: that works
  172. [02:54 PM] steveoliver: ok
  173. [02:54 PM] markcarver: um...
  174. [02:54 PM] steveoliver: ?
  175. [02:54 PM] markcarver: {% trans({'@name':person.name}) %}Please get an apple for @name.{% plural count %}Please get !count apples for @name.{% endtrans %}
  176. [02:55 PM] steveoliver: right
  177. [02:55 PM] markcarver: that looks good to me
  178. [02:55 PM] steveoliver: wait...
  179. [02:55 PM] markcarver: haha
  180. [02:55 PM] steveoliver: that's where things get funky
  181. [02:56 PM] steveoliver: count will always be an integer when used as a switch for count
  182. [02:56 PM] steveoliver: last count == plural, sorry
  183. [02:56 PM] markcarver: {% trans({'@name':person.name}) %}Please get an apple for @name.{% plural apples %}Please get !count apples for @name.{% endtrans %}
  184. [02:56 PM] steveoliver: but that !count token has no value in the incoming replacement arts
  185. [02:57 PM] steveoliver: the !count key doesn't exist in the incoming args
  186. [02:57 PM] steveoliver: and that really is only a print statement
  187. [02:57 PM] steveoliver: {{ count }} makes sense
  188. [02:57 PM] steveoliver: !count does not
  189. [02:57 PM] markcarver: not translatable
  190. [02:58 PM] steveoliver: mmm
  191. [02:58 PM] markcarver: the plural modifier in the trans block injects the count automatically
  192. [02:58 PM] steveoliver: how are we going to translate integers?
  193. [02:58 PM] markcarver: {% trans({'@name':person.name}) %}Please get an apple for @name.{% plural apples %}Please get @count apples for @name.{% endtrans %}
  194. [02:58 PM] steveoliver: "injects the count automatically" ?
  195. [02:58 PM] markcarver: https://api.drupal.org/api/drupal/core!includes!common.inc/function/format_plural/8
  196. [02:59 PM] markcarver: the plural modifier switches the function called to format_plural() from t()
  197. [02:59 PM] steveoliver: i know
  198. [02:59 PM] steveoliver: what do you mean by "injects the count automatically" ?
  199. [03:00 PM] steveoliver: but that'll always be an integer
  200. [03:00 PM] markcarver: format_plural() takes the $count param and sets it in the argument list (see the funciton): $args['@count'] = $count;
  201. [03:00 PM] markcarver: automatically
  202. [03:00 PM] markcarver: we don't need to pass the count as a variable
  203. [03:00 PM] steveoliver: i know what the function does
  204. [03:00 PM] steveoliver: i know we don't
  205. [03:01 PM] steveoliver: i'm saying the var that we give to the plural modifier will always be an int
  206. [03:01 PM] markcarver: it should be yes
  207. [03:01 PM] steveoliver: why are we saying !count
  208. [03:01 PM] steveoliver: ?
  209. [03:01 PM] markcarver: because I forgot it's really @count
  210. [03:01 PM] markcarver: which is injected automatically by format_plural()
  211. [03:02 PM] steveoliver: that saying 'don't format this token', just print it
  212. [03:02 PM] markcarver: that's what the function sets as the argument to use...
  213. [03:03 PM] markcarver: i'm confused
  214. [03:03 PM] steveoliver: what 's wrong with this:
  215. [03:03 PM] steveoliver: {% trans({'@name':http://person.name/}) %}Please get an apple for @name.{% plural count %}Please get {{ count }} apples for @name.{% endtrans %}
  216. [03:03 PM] steveoliver: ?
  217. [03:04 PM] steveoliver: {% plural count %} evaluates count, {{ count }} prints it
  218. [03:04 PM] steveoliver: !count, prints count
  219. [03:04 PM] steveoliver: but is less clear
  220. [03:04 PM] markcarver: because then you're passing "Please get 2 apples for @name" to format plural
  221. [03:04 PM] steveoliver: right
  222. [03:04 PM] markcarver: translation....
  223. [03:04 PM] markcarver: .po files aren't count to have 2 in the string
  224. [03:04 PM] markcarver: they're going to have @count
  225. [03:05 PM] steveoliver: k, gotya
  226. [03:05 PM] markcarver: because @count changes
  227. [03:05 PM] steveoliver: sorry
  228. [03:05 PM] markcarver: lol it's all good
  229. [03:05 PM] markcarver: I'll admit… I was scratching my head for a bit
  230. [03:06 PM] steveoliver: ok
  231. [03:06 PM] steveoliver: with that all out of the way...
  232. [03:07 PM] markcarver: {% trans({ '@name' : person.name }) %}@name has only made one comment.{% plural comments %}@name has made @count comments.{% endtrans %}
  233. [03:07 PM] steveoliver: {% set apple_count = count(apples) %}{% trans({'@name':user.name, '!count': apples_count}) %}Please get @name !count apples.{% endtrans %}
  234. [03:08 PM] steveoliver: scratch that — didn't mean to hit enter
  235. [03:08 PM] markcarver: {% trans({ '@name' : user.name }) %}@name has only made one comment.{% plural comments %}@name has made @count comments.{% endtrans %}
  236. [03:09 PM] steveoliver: ...{% plural apple_count %}
  237. [03:09 PM] markcarver: I like to give drupalist examples
  238. [03:09 PM] markcarver: drupalistic*
  239. [03:09 PM] steveoliver: ok, but where is @count mapped?
  240. [03:09 PM] steveoliver: magically in the background?
  241. [03:09 PM] steveoliver: i think that may not be good
  242. [03:09 PM] markcarver: yes, in http://drupalcode.org/project/drupal.git/blob/HEAD:/core/includes/common.inc#l938
  243. [03:10 PM] steveoliver: mmm
  244. [03:10 PM] markcarver: we don't have to worry about passing the count into the argument list
  245. [03:10 PM] markcarver: format_plural() does this for us
  246. [03:11 PM] steveoliver: k
  247. [03:11 PM] steveoliver: i see
  248. [03:12 PM] markcarver: {% plural count %} will switch the function the trans block is using from t() to format_plural()
  249. [03:12 PM] markcarver: if it's more than one
  250. [03:12 PM] steveoliver: yep
  251. [03:12 PM] steveoliver: feature, cool
  252. [03:13 PM] markcarver: which is why I'm thinking that the {% format_plural %} block is now redundant
  253. [03:13 PM] markcarver: because format_plural() is also translated
  254. [03:13 PM] steveoliver: cuz it calls t/trans anyways
  255. [03:13 PM] steveoliver: right
  256. [03:14 PM] steveoliver: so we'd be kinda switching things up
  257. [03:14 PM] steveoliver: having trans be the entry point
  258. [03:14 PM] markcarver: well, we're going to have to
  259. [03:14 PM] markcarver: there's no other way to get the vars and .po files to work otherwise
  260. [03:14 PM] steveoliver: so what would we do in twig if we know we are only translating a plural form string?
  261. [03:15 PM] steveoliver: just use trans, yep
  262. [03:15 PM] markcarver: exactly
  263. [03:15 PM] markcarver: we can still leave the |t filter in…. for those that need it
  264. [03:15 PM] markcarver: or want to use it
  265. [03:16 PM] markcarver: but the power of plural really lies in {% trans() %}
  266. [03:16 PM] steveoliver: trans is just a different syntax for format_plural really
  267. [03:16 PM] markcarver: in theory, you could use {% trans() %} for just t()
  268. [03:16 PM] steveoliver: ^^ right
  269. [03:17 PM] markcarver: and TBCH… I think it really should be {% translate() %}
  270. [03:17 PM] steveoliver: translate +1
  271. [03:17 PM] steveoliver: "trans is just a different syntax for format_plural really" — what do you think?
  272. [03:18 PM] markcarver: {% plural count %} only makes it that
  273. [03:18 PM] steveoliver: just kinda mixed around a lil, with the count being not passed in, as it is in format_plural
  274. [03:18 PM] markcarver: in reality {% translate() %} can be either t() or format_plural()
  275. [03:19 PM] markcarver: which is why I think it should be called {% translate() %} to no confuse with either t() or format_plural()
  276. [03:19 PM] markcarver: because the syntax IS different
  277. [03:19 PM] steveoliver: switching on a context variable, not an explicit arg to the callback
  278. [03:19 PM] steveoliver: i like translate
  279. [03:20 PM] steveoliver: "Where does count come from?" question is still a little "Eh..."
  280. [03:20 PM] markcarver: _context
  281. [03:20 PM] steveoliver: i know
  282. [03:20 PM] markcarver: of the template file
  283. [03:20 PM] steveoliver: right
  284. [03:20 PM] steveoliver: that's cooll
  285. [03:20 PM] steveoliver: ok,
  286. [03:20 PM] steveoliver: translate tag with array of args...
  287. [03:21 PM] markcarver: tag or block?
  288. [03:21 PM] markcarver: can blocks have an array of arguments?
  289. [03:21 PM] steveoliver: well this is not a block
  290. [03:21 PM] steveoliver: a block is a codeblock, i.e. region in a template that can be inherited, overriden...
  291. [03:21 PM] steveoliver: we don't implement any
  292. [03:21 PM] markcarver: {% trans({ '@name' : user.name }) %}@name has only made one comment.{% plural comments %}@name has made @count comments.{% endtrans %}
  293. [03:21 PM] markcarver: that's a block
  294. [03:22 PM] steveoliver: that is a tag, i'm pretty sure
  295. [03:22 PM] markcarver: {% endtrans %}
  296. [03:22 PM] markcarver: that makes it a block yes?
  297. [03:22 PM] steveoliver: {% block header %}Page Header{% endblock %} is a block
  298. [03:23 PM] steveoliver: http://twig.sensiolabs.org/doc/tags/block.html
  299. [03:23 PM] markcarver: nm… I'm confusing the concept of and ending tag with block
  300. [03:23 PM] steveoliver: http://twig.sensiolabs.org/doc/tags/extends.html
  301. [03:23 PM] markcarver: an*
  302. [03:24 PM] steveoliver: lol, "block" is an imlpementation of a tag, specifying a chunk of code that can be replaced, inherited
  303. [03:24 PM] markcarver: yep, on board now
  304. [03:24 PM] steveoliver: so tag
  305. [03:24 PM] steveoliver: translate tag
  306. [03:24 PM] steveoliver: takes args
  307. [03:24 PM] steveoliver: one for now
  308. [03:24 PM] steveoliver: being the keyed array of replacements
  309. [03:24 PM] markcarver: yes
  310. [03:25 PM] steveoliver: as we've had as the second arg to t() and the fourth arg to format_plural()
  311. [03:25 PM] steveoliver: s/we've had/we have/
  312. [03:25 PM] markcarver: yes
  313. [03:25 PM] steveoliver: and that tag supports tokens
  314. [03:26 PM] markcarver: for the arguments provided
  315. [03:26 PM] markcarver: yes
  316. [03:26 PM] markcarver: no
  317. [03:26 PM] steveoliver: those tokens have only an opening identifier
  318. [03:26 PM] markcarver: we don't need tokens
  319. [03:26 PM] steveoliver: you're right....
  320. [03:26 PM] steveoliver: those get passed to t()
  321. [03:26 PM] markcarver: that list of args passed to {% translate() %} just gets passed through
  322. [03:26 PM] markcarver: yes
  323. [03:27 PM] steveoliver: Twig needn't care
  324. [03:27 PM] markcarver: nope
  325. [03:27 PM] steveoliver: k
  326. [03:27 PM] steveoliver: that tag has the plural switch
  327. [03:27 PM] markcarver: exactly
  328. [03:28 PM] markcarver: which will give us an extra @count arg to use in the plural text
  329. [03:28 PM] steveoliver: passes second chunk to format_plural
  330. [03:28 PM] steveoliver: cool
  331. [03:28 PM] steveoliver: yay no twig token parsing
  332. [03:28 PM] markcarver: +1
  333. [03:28 PM] steveoliver: are we any better off now than we were an hour ago?
  334. [03:29 PM] markcarver: oh most definitely
  335. [03:29 PM] steveoliver: i think so
  336. [03:29 PM] steveoliver: cool
  337. [03:30 PM] steveoliver: are we done? :)
  338. [03:30 PM] markcarver: yes, I can summarize what needs to go in that issue
  339. [03:30 PM] markcarver: hell might even attempt a patch, who knows
  340. [03:30 PM] steveoliver: markcarver++
  341. [03:30 PM] steveoliver: :)
  342. [03:30 PM] steveoliver: i've got an issue to update, myself
  343. [03:30 PM] markcarver: do you know how I might get the arguments for the tag though?
  344. [03:31 PM] steveoliver: i was wondering about that..
  345. [03:31 PM] markcarver: I was kinda stumped on that one
  346. [03:31 PM] steveoliver: that's where we were at?
  347. [03:31 PM] steveoliver: lemme see
  348. [03:31 PM] steveoliver: http://twig.sensiolabs.org/doc/tags/macro.html ?
  349. [03:31 PM] steveoliver: hmm
  350. [03:32 PM] steveoliver: not quite, but interesting...
  351. [03:35 PM] markcarver: steveoliver++
  352. [03:35 PM] markcarver: steveoliver++
  353. [03:35 PM] markcarver: thanks for your patience and help
  354. [03:37 PM] steveoliver: {% translate with {'@author:user.name, '@date':node.date} %}Submitted by @name on @date.{% endtranslate %} may be the form
  355. [03:37 PM] steveoliver: yes, that is the form
  356. [03:37 PM] steveoliver: we won't be doing {% translate({args}) %} form
  357. [03:37 PM] steveoliver: that is function form
  358. [03:37 PM] steveoliver: from my googling
  359. [03:37 PM] steveoliver: http://mark-story.com/posts/view/making-custom-tags-in-twig
  360. [03:38 PM] markcarver: steveoliver++
  361. [03:38 PM] markcarver: thank you!
  362. [03:38 PM] steveoliver: i.e http://stackoverflow.com/questions/10557436/receiving-arguments-from-twig-templates-in-symfony2
  363. [03:39 PM] steveoliver: {% translate with { {'@name':name, '@date':date} }String…{% endtranslate %}
  364. [03:39 PM] steveoliver: the
  365. [03:39 PM] steveoliver: " with { }" === "functionname(...)"
  366. [03:40 PM] steveoliver: u good?
  367. [03:40 PM] steveoliver: i'll be around for a few hours
  368. [03:40 PM] steveoliver: markcarver++
  369. [03:40 PM] markcarver: hmm, I don't get the last part
  370. [03:40 PM] steveoliver: ok
  371. [03:40 PM] markcarver: " with { }" === "functionname(...)"
  372. [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
  373. [03:42 PM] steveoliver: function/method callback, whatever it is..
  374. [03:42 PM] steveoliver: make sense?
  375. [03:42 PM] markcarver: oh...
  376. [03:42 PM] steveoliver: so there is a form where we don't pass args
  377. [03:42 PM] steveoliver: {% translate %} is valid
  378. [03:42 PM] steveoliver: it passes no args in..
  379. [03:42 PM] markcarver: gotcha
  380. [03:43 PM] steveoliver: which would be cool if plural strings don't need replacements
  381. [03:43 PM] steveoliver: or rather singular/plural switches don't need to consider replacements
  382. [03:43 PM] steveoliver: ..that don't need to consider..
  383. [03:44 PM] markcarver: yeah
  384. [03:44 PM] steveoliver: {% translate %}Gimme an apple{% plural count %}Gimme some apples!{% endtranslate %}
  385. [03:44 PM] markcarver: well you could pass the @count still
  386. [03:45 PM] steveoliver: tag name 'translate' in that example is :(
  387. [03:45 PM] markcarver: which would be cool
  388. [03:45 PM] steveoliver: yeah, format_plural would get count
  389. [03:45 PM] steveoliver: clean
  390. [03:45 PM] steveoliver: might need to think on the translate name for the tag...
  391. [03:45 PM] steveoliver: ?
  392. [03:45 PM] markcarver: how so?
  393. [03:45 PM] markcarver: it still gets translated
  394. [03:46 PM] steveoliver: oh, yeah...
  395. [03:46 PM] markcarver: both for languages
  396. [03:46 PM] steveoliver: derp
  397. [03:46 PM] steveoliver: both scenarios
  398. [03:46 PM] markcarver: and it transforms from singular or plural scenarios
  399. [03:46 PM] steveoliver: bad ass
  400. [03:46 PM] steveoliver: i like, alot
  401. [03:46 PM] steveoliver: a lot ;)
  402. [03:46 PM] markcarver: hehe me too
  403. [03:46 PM] markcarver: finally some real power
  404. [03:46 PM] markcarver: smart*
  405. [03:46 PM] steveoliver: yeah, very clean
  406. [03:47 PM] markcarver: alright, I'll get started on this
  407. [03:47 PM] markcarver: thanks again for all your help
  408. [03:47 PM] markcarver: steveoliver++
  409. [03:47 PM] steveoliver: yw. thanks for your patience too
  410. [03:48 PM] markcarver: :D
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement