[Building Sakai] Internationalizing a confirmation in RSF

Brian Baillargeon bbailla2 at uwo.ca
Tue Sep 18 10:03:48 PDT 2012


@Steve:
onclick="return confirm('rsf:id="msg=confirm.message"')" was giving me 
trouble. I think the issue may have been this:
"return confirm(' rsf:id=" <- closes the double quotes, and at 
'msg=...'  it starts interpreting a new attribute. Escaping with &quot; 
was displaying the literal "rsf:id..." in the interface.


So to my understanding, rsf:id's are handled during a request processing 
cycle, so the only thing I could think of to grab confirm.message with 
javascript during an onClick is this:

<!--create a hidden html element with the text we need during the 
request processing cycle,
then confirm() will take its innerHTML as a parameter after the request 
processing cycle-->
<h3 id="confirmation" rsf:id="msg=confirm.message" 
style="display:none;"></h3>
<input type="submit" onclick="return 
confirm(document.getElementById('confirmation').innerHTML);" />

This works, but IMO this is an ugly work around, so if anybody thinks of 
anything better (perhaps using Ajax?), please let me know.

Thanks for the suggestions everyone!
Brian

On 12-09-18 04:46 AM, Jean-Francois Leveque wrote:
> Hi Brian,
>
> Did you find what you were looking for with help from Matthew and Steve?
>
> If you found it, what was useful for you and how are you gonna do your 
> i18n?
>
> If you didn't find it, what are you still looking for?
>
> Cheers,
> J-F
>
> On 17/09/2012 23:43, Brian Baillargeon wrote:
>> Hello all
>>
>> When somebody submits a particular form, I'd like to have a yes/no
>> confirmation dialog where the text is internationalized. This is in the
>> context of RSF.
>> So I was thinking of using a javascript confirm to do this, but I want
>> it to show text from Messages.properties.
>>
>> So for example,
>> Messages.properties:
>> ...
>> confirm.message=Are you sure you want to proceed?
>> ...
>>
>> MyForm.html:
>> ...
>> <script>
>> function confirmSubmit()
>> {
>>       var agree=confirm(<Pull me from Messages.properties>);
>>       if (agree)
>>           return true;
>>       else
>>           return false;
>> }
>> </script>
>> ...
>> <input class="submit" type="submit" onclick="return confirmSubmit()"
>> rsf:id="submitClaim" />
>> ...
>>
>> How can this be done? / Is there a better way to approach this in RSF?
>>
>> Thanks,
>> Brian



More information about the sakai-dev mailing list