You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by sridhar <sr...@tatanova.com> on 2002/10/19 20:21:05 UTC

i18n messages in javascript js file

My application uses javascript validations (at the client side) and all the validations are done in a validate.js file and displays the error messages with alerts. And all the messages in the javascript are hardcoded and the js file is used in many jsp's. Can i make the messages internationalized using struts frames work? if yes how can i do that ?

thanks in advance.
sridhar

Re: i18n messages in javascript js file

Posted by CuteProgrammer <cu...@hotmail.com>.
I think this works fine for u

JS Function
function _alert(key)
{  
   var url="/app/view/jsp/Alert.jsp?name="+key;   
   window.showModalDialog(url,null,'dialogHeight:120px;dialogWidth:400px;scroll:no;status:no');   
   return false;
}

Alert.jsp
<%
  String _key=null;
  if(request.getParameter("name")!=null)
    _key=request.getParameter("name");  
%>
<bean:message key="<%= _key %>" locale="app_sitelanguage" />


Just pass the key as a parameter for the function _alert(key)
where u can get this key from property file

Regards
Varma


----- Original Message ----- 
From: "sridhar" <sr...@tatanova.com>
To: <st...@jakarta.apache.org>
Sent: Saturday, October 19, 2002 11:51 PM
Subject: i18n messages in javascript js file


My application uses javascript validations (at the client side) and all the validations are done in a validate.js file and displays the error messages with alerts. And all the messages in the javascript are hardcoded and the js file is used in many jsp's. Can i make the messages internationalized using struts frames work? if yes how can i do that ?

thanks in advance.
sridhar



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: i18n messages in javascript js file

Posted by CuteProgrammer <cu...@hotmail.com>.
 I think this works fine for u

 JS Function
 function _alert(key)


    var url="/app/view/jsp/Alert.jsp?name="+key;

window.showModalDialog(url,null,'dialogHeight:120px;dialogWidth:400px;scroll
:no;status:no');
    return false;
 }

 Alert.jsp
 <%
   String _key=null;
   if(request.getParameter("name")!=null)
     _key=request.getParameter("name");
 %>
 <bean:message key="<%= _key %>" locale="app_sitelanguage" />


 Just pass the key as a parameter for the function _alert(key)
 where u can get this key from property file
 Regards
 Varma
----- Original Message -----
From: "sridhar" <sr...@tatanova.com>
To: <st...@jakarta.apache.org>
Sent: Saturday, October 19, 2002 11:51 PM
Subject: i18n messages in javascript js file


My application uses javascript validations (at the client side) and all the
validations are done in a validate.js file and displays the error messages
with alerts. And all the messages in the javascript are hardcoded and the js
file is used in many jsp's. Can i make the messages internationalized using
struts frames work? if yes how can i do that ?

thanks in advance.
sridhar


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: i18n messages in javascript js file

Posted by James Mitchell <jm...@telocity.com>.
Have you taken a look at using the validator (its part of core struts now)?

By using this validation framework, you can add both client side and server
side validations to your web application.

You can get up to speed by reading the docs or (as I prefer) run the
struts-example and 'take a look under the hood'.


James Mitchell
Software Engineer/Struts Evangelist
http://www.open-tools.org




> -----Original Message-----
> From: sridhar [mailto:sridhard@tatanova.com]
> Sent: Sunday, October 20, 2002 12:12 PM
> To: Struts Users Mailing List
> Cc: jmitchtx@telocity.com
> Subject: Re: i18n messages in javascript js file
>
>
> Thanks James,
>     That's how we had implemented for now, but is it right to have just
> javavascript code in a separate jsp and include it in all the other jsp's.
> is there any better solution ?
>
> sridhar
>
> ----- Original Message -----
> From: "James Mitchell" <jm...@telocity.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Sunday, October 20, 2002 2:06 AM
> Subject: RE: i18n messages in javascript js file
>
>
> > Yes you can.
> >
> > Since you are using a .js file (client side include), if you prefer to
> have
> > the least amount of impact on your application, change it to a .jsp file
> and
> > add the necessary changes (adding bean:message for each i18n'd message)
> >
> > Is this enough info?
> >
> > If you need further assistance, submit a portion of your validation
> scripts
> > and I'll send you back a working example.
> >
> >
> > James Mitchell
> > Software Engineer/Struts Evangelist
> > http://www.open-tools.org
> >
> >
> >
> >
> > > -----Original Message-----
> > > From: sridhar [mailto:sridhard@tatanova.com]
> > > Sent: Saturday, October 19, 2002 2:21 PM
> > > To: struts-user@jakarta.apache.org
> > > Subject: i18n messages in javascript js file
> > >
> > >
> > > My application uses javascript validations (at the client side)
> > > and all the validations are done in a validate.js file and
> > > displays the error messages with alerts. And all the messages in
> > > the javascript are hardcoded and the js file is used in many
> > > jsp's. Can i make the messages internationalized using struts
> > > frames work? if yes how can i do that ?
> > >
> > > thanks in advance.
> > > sridhar
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: i18n messages in javascript js file

Posted by sridhar <sr...@tatanova.com>.
Thanks James,
    That's how we had implemented for now, but is it right to have just
javavascript code in a separate jsp and include it in all the other jsp's.
is there any better solution ?

sridhar

----- Original Message -----
From: "James Mitchell" <jm...@telocity.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Sunday, October 20, 2002 2:06 AM
Subject: RE: i18n messages in javascript js file


> Yes you can.
>
> Since you are using a .js file (client side include), if you prefer to
have
> the least amount of impact on your application, change it to a .jsp file
and
> add the necessary changes (adding bean:message for each i18n'd message)
>
> Is this enough info?
>
> If you need further assistance, submit a portion of your validation
scripts
> and I'll send you back a working example.
>
>
> James Mitchell
> Software Engineer/Struts Evangelist
> http://www.open-tools.org
>
>
>
>
> > -----Original Message-----
> > From: sridhar [mailto:sridhard@tatanova.com]
> > Sent: Saturday, October 19, 2002 2:21 PM
> > To: struts-user@jakarta.apache.org
> > Subject: i18n messages in javascript js file
> >
> >
> > My application uses javascript validations (at the client side)
> > and all the validations are done in a validate.js file and
> > displays the error messages with alerts. And all the messages in
> > the javascript are hardcoded and the js file is used in many
> > jsp's. Can i make the messages internationalized using struts
> > frames work? if yes how can i do that ?
> >
> > thanks in advance.
> > sridhar
> >
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: i18n messages in javascript js file

Posted by James Mitchell <jm...@telocity.com>.
Yes you can.

Since you are using a .js file (client side include), if you prefer to have
the least amount of impact on your application, change it to a .jsp file and
add the necessary changes (adding bean:message for each i18n'd message)

Is this enough info?

If you need further assistance, submit a portion of your validation scripts
and I'll send you back a working example.


James Mitchell
Software Engineer/Struts Evangelist
http://www.open-tools.org




> -----Original Message-----
> From: sridhar [mailto:sridhard@tatanova.com]
> Sent: Saturday, October 19, 2002 2:21 PM
> To: struts-user@jakarta.apache.org
> Subject: i18n messages in javascript js file
>
>
> My application uses javascript validations (at the client side)
> and all the validations are done in a validate.js file and
> displays the error messages with alerts. And all the messages in
> the javascript are hardcoded and the js file is used in many
> jsp's. Can i make the messages internationalized using struts
> frames work? if yes how can i do that ?
>
> thanks in advance.
> sridhar
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>