jquery-localize icon indicating copy to clipboard operation
jquery-localize copied to clipboard

Trigger localization based on URL?

Open vilbht opened this issue 9 years ago • 3 comments

Hi there

The plugin looks amazing. Is there a way to trigger a string's localization based on the URL of the page?

For instance, on website.com/fr, a string like "Hello" would be "Bonjour" Similarly on website.com/es, the string could be "Hola"?

Any tips on how to accomplish this?

vilbht avatar Jul 14 '16 08:07 vilbht

hi vilav

relying on the url for your persisting your language sounds kinda fragile to me depending how is your website setup i.e. how are you going to parse and populate the url implementations vary significantly but a high level flow would like this

have links that point to each language click the link read the parameter from url assign it to the plugin

would you be willing to consider a session based language switcher https://github.com/coderifous/jquery-localize/issues/77

perhaps you could extend it to read the params from the href attribute, where the full exists, instead of the data-lang attribute

regards alex

alexwebgr avatar Jul 14 '16 10:07 alexwebgr

Do you have any example code how I can structure that? The URL will be setup in a way that the suffix of language (de/fr etc.) is always persistent in that piece of content. the URL could be a simpler trigger to toggle language content making it easy to integrate with static and cms-based sites, do you think so?

vilbht avatar Jul 14 '16 12:07 vilbht

the github editor ate my link ! click on number 77 in my previous post

alexwebgr avatar Jul 14 '16 13:07 alexwebgr