Variable matching in translations #12

wvanbergen opened this Issue Jun 7, 2010 · 5 comments


None yet

3 participants


As a proof of concept, I added a simple validator to the Translation model that checks whether the variables in the translation and the primary text match. I am now using the following rules for the translation of a phrase:

  • All variables in the primary translation should be used.
  • No new variable names should be invented in the secondary translation.
  • Changing the order of variables is allowed: "{{world}}, {{hello}}!"
  • Repetition of variables is allowed: "{{hello}} {{world}}, and {{hello}} again!"

I added tests for this behavior as well. See my fork at
Before going further, the questions is whether these rules are OK and should be enforced strictly (by using a validation). Also, currently the app does not display validation errors.


I like the sound of these constraints. Feels like something that should be on by default (and validated strictly) and turned off with a bit of work.


Apparently, I forgot to push to my repo. Now the changes are on Github:


I think this is pretty good. It should also detecte %{} variable format though ( that's the new default in Rails 3 ). Could you please send a pull request too ?



Fixed, and sent!


I've merged your branch.

Thanks for the patch!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment