Jump to content

[SOLVED] Translate in Javascript


waldette

Recommended Posts

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 :(

Link to comment
Share on other sites

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

  • Thanks 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...