i18n_viz icon indicating copy to clipboard operation
i18n_viz copied to clipboard

RFE: Support dynamic external tool url based on current language selection

Open atodorov opened this issue 8 years ago • 4 comments

As far as I can see the external_tool_url can't change during runtime, can it ? WebTranslateIt for example uses URLs of the form XXX/en..fr/YYY. This will stay the same even if I'm viewing the same page in German, supposedly wanting to work on the German translations.

How hard would it be to be able to set the external_tool_url depending on what page is being viewed ? I'm OK if this is done in Rails if you can't do it in JavaScript.

atodorov avatar Apr 05 '16 21:04 atodorov

sounds like a good idea.

I guess just providing the gem with a ruby proc that gets evaluated dynamically should do the job pretty well. Would you mind taking a stab at implementing this?

jhilden avatar Apr 14 '16 08:04 jhilden

@jhilden - I don't mind looking into this but I will need some pointers/examples since my Rails/Ruby experience is a bit limited. I need to know what to look for before trying to implement anything.

atodorov avatar Apr 14 '16 08:04 atodorov

no problem.

we have a different gem where we allow users to pass in certain configuration options in form of a Proc or lambda (instead of like a integer or string). see https://github.com/railslove/rack-tracker#google-analytics the :user_id. That way this code will always be executed, when the configuration option is accessed.

when using the configuration option in the code you need to check if it responds to a call method (which procs/lambdas do), like we are doing here: https://github.com/railslove/rack-tracker/blob/05265a3273944215f58992f34e9ad9dcb08ee5fc/lib/rack/tracker/google_analytics/google_analytics.rb#L57

let me know if you have additional questions.

jhilden avatar Apr 14 '16 08:04 jhilden

@jhilden - one more question. How do I change the external_tool_url setting at runtime ? I want to assign a labmda to it in one of the tests, without affecting the rest of them. Otherwise I think I got it working fairly easy,

atodorov avatar Apr 17 '16 20:04 atodorov