Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not cascade translation #10

Open
dwt opened this issue Aug 20, 2012 · 4 comments
Open

Does not cascade translation #10

dwt opened this issue Aug 20, 2012 · 4 comments

Comments

@dwt
Copy link

dwt commented Aug 20, 2012

I've noticed that if I interpolate translated strings into translated strings - it doesn't work.

This happens something like this:

warning =  _("Missing correct answers")
object_id = "fnord"

_("${warning} for object with id ${object_id}") 
            % dict(warning=warning, object_id=object_id))

This makes it really hard to use this in places where you do not controll what strings get spliced into a translated strings - which is really unfortunate.

To my understanding, interpolate() needs to check all strings it interpolates and call interpolate on them too as needed.

@rbu
Copy link

rbu commented Nov 6, 2014

@wichert, do you have any idea how this could be fixed? Seems like @dwt stumbled upon this issue at least twice with no feedback yet.

@wichert
Copy link
Member

wichert commented Nov 6, 2014

The %-operator itself does work: that returns a new TranslationString instance with an updated mapping. The underlying issue is better described in #14: interpolate() does not check for TranslationString instances when inserting values. There are a three possible ways of fixing that:

  1. translation manually in your code, and passing the result as a (new) mapping to the translate call.
  2. have TranslationString.interpolate() check for TranslationString instances and do recursive translation
  3. update Translator.translator() to check the mapping for TranslationString instances, and translate those to create a new (translated) mapping)

The first option is cumbersome, but works today. The second option is impossible to implement: the interpolate method does not have access to the translation catalogs/policy, so it can't do the translation. The last option should be doable.

@dwt
Copy link
Author

dwt commented Nov 6, 2014

Thanks for the feedback, do you plan to do that or are you waiting for pull requests on this as you don't have time?

@wichert
Copy link
Member

wichert commented Dec 1, 2014

I'm planning to do it, but considering current priorities and available time it might be a while before I get to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants