waldette Posted July 22, 2013 Posted July 22, 2013 Hello, I have a code like this: $("label#phone_error").text("Required"); and I want to do it translatable... is it possible in javascript? I try some like: $("label#phone_error").text($("label#phone_error").text("{l s='Required' mod='module'}")); but don't work Share this post Link to post Share on other sites More sharing options...
NemoPS Posted July 22, 2013 Posted July 22, 2013 You can't translate if you use a separate jjavascript file. However, you can do it inside a .tpl file with a script tag, like this <script type="text/javascript"> // <![CDATA[ var noSelectedCategoryTxt = "{l s='You must select at least one category!' mod='modulename'}"; //]]> </script> Then you can access the same variable in your .js file, inside a jquery ready statement 1 Share this post Link to post Share on other sites More sharing options...
vekia Posted July 22, 2013 Posted July 22, 2013 everything depends on what kind of script you've got it's a script in separate js file? or it's a <script></script> in the .tpl file? Share this post Link to post Share on other sites More sharing options...
waldette Posted July 22, 2013 Posted July 22, 2013 Its a separated js file... Share this post Link to post Share on other sites More sharing options...
NemoPS Posted July 22, 2013 Posted July 22, 2013 If it's a module, you can always attach the script tags as I showed you to your tpl file Share this post Link to post Share on other sites More sharing options...
waldette Posted July 22, 2013 Posted July 22, 2013 (edited) Ok it works perfectly. I already had the tpl file created, so I just put the code you said and it works at first. Thanks! EDIT: Ah, you can mark the topic solved ^^ Edited July 22, 2013 by waldette (see edit history) Share this post Link to post Share on other sites More sharing options...
NemoPS Posted July 22, 2013 Posted July 22, 2013 Amazing! Glad it worked! marking as solved Share this post Link to post Share on other sites More sharing options...
vekia Posted July 22, 2013 Posted July 22, 2013 but it translates also javascripts? i don't think so If i am wrong please correct me 1 Share this post Link to post Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now