Variable matching in translations #12

Closed
wvanbergen opened this Issue Jun 7, 2010 · 5 comments

Projects

None yet

3 participants

@wvanbergen

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 http://github.com/wvanbergen/tolk
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.

@edward

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.

@wvanbergen

Apparently, I forgot to push to my repo. Now the changes are on Github: http://github.com/wvanbergen/tolk/commit/ac773411969b0f5d8aa7d1c7777acc4928d54452

@lifo
Collaborator

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 ?

Thanks!

@wvanbergen

Fixed, and sent!

@lifo
Collaborator

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