Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

At Last.fm we used PHP+Smarty with a gettext-esque pre-compilation step (a bit like IntSmarty) for templates that allowed translators to embed smarty templating code, so you could write this in smarty:

  {l}Found {$d} directories{/l}
and the replacement for each language could have its own switch on $d to decide how to translate it.

One (unavoidable?) downside is that the translators have to know some basic if/then/smarty syntax, and if they mess it up your template won't compile. Also you have to trust them somewhat, since they essentially get to execute PHP on your webserver.



Another downside is that this simply will not work for inflected languages, as the translation of "directories" will change depending on the number.

(unless I'm misunderstanding something in your templating scheme)


It works because the translator can write template code that is executed by the templating engine at runtime, so the translator can write something like this as the translation:

  {switch $d}
   {case 1} foo {$d}...
   {case 2} {$d} bar..
   {default} ba{$d}z
  {/switch}
We provided the translators with some basic examples of if/then/switches and so on, they were free to do all sorts of crazy things (especially in polish).


Oh, ok, I understand now — that would work fine, then. It's actually a good solution, because it lets your translators customize strings right where they have the full context, e.g. in final templates.


I don't think that downside is unavoidable. In the same way that you can't expect somebody to create some or all of a web page without at least a basic understanding of some form of markup, you can't expect a linguist to handle various differing cases without an understanding of conditionals.

This is a classic case of "make things as simple as possible... but no simpler". You've achieved the first bit. To go any simpler would lose vital granularity.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: