Morley
October 19, 2004, 3:41pm
1
Using HTML in i18n works well. But what about merging both HTML and field calls simultaneously.
I need to convert the following into i18n:
var msg = '';
msg += '<html>Welcome <b><font color="red">' + user_name + '</font></b>
';
msg += 'of <b><font color="red">' + gusercomid$to_com.company_name + '</font></b> ID ' + globals.gservoy_id;
plugins.dialogs.showInfoDialog( 'Info',msg);
I’ve tried the following workaround which, on the face of it, is logical, but it’s missing a critical factor – it also doesn’t work.
var title = i18n.getI18NMessage('7office.dlg.welcome');
var msg = '';
msg += '<html>' + i18n.getI18NMessage('7office.dlg.welcomemsg1') + '<b><font color="red">' + user_name + '</font></b>
';
msg += ' ' + i18n.getI18NMessage('7office.dlg.welcomemsg2') + ' <b><font color="red">' + gusercomid$to_com.company_name;
msg += '</font></b> ' + i18n.getI18NMessage('7office.dlg.welcomemsg3') + ' ' + globals.gservoy_id
plugins.dialogs.showInfoDialog(title, msg);
Is there a way someone has worked out?
Hi Morley,
I do this all the time. What doesn’t work in your code? You’re on the right track.
Bob Cusick
Morley
October 19, 2004, 5:41pm
3
bcusick:
I do this all the time. What doesn’t work in your code? You’re on the right track.
The first attempt renders the first word properly, thereafter forgets that it’s interpreting html. In the following I added before each piece of html code.
var title = i18n.getI18NMessage('7office.dlg.welcome');
var msg = '';
msg += '<html>' + i18n.getI18NMessage('7office.dlg.welcomemsg1') + '<html><b><font color="red">' + user_name + '<html></font></b>
';
msg += ' ' + i18n.getI18NMessage('7office.dlg.welcomemsg2') + '<html><b><font color="red"> ' + gusercomid$to_com.company_name;
msg += '<html></font></b> ' + i18n.getI18NMessage('7office.dlg.welcomemsg3') + ' ' + globals.gservoy_id
plugins.dialogs.showInfoDialog(title, msg);
Better, but I’m missing something. There’s a line break at each section, rather than a continuous line of text.
Morley,
Take out the var msg = ‘’ - you don’t need it.
I can’t duplicate your results. If I do this code:
var x = "<html><b>" + i18n.getI18NMessage("s.solution_title") + "</b>"
x += " _ " + i18n.getI18NMessage("s.tt_admin")
plugins.dialogs.showInfoDialog( "title", x, "ok")
Everything is just as expected (one line).
Bob Cusick
Morley
October 20, 2004, 1:15pm
5
Bob, the difference between your code and mine is I’m switching into and out of bold and red, back and forth. Here’s my code, then what I’m after done without i18n, followed by what this code renders. I have my doubts if Servoy can currently do what I’m attempting.
var title = i18n.getI18NMessage('7office.dlg.welcome');
var msg = '<html>' + i18n.getI18NMessage('7office.dlg.welcomemsg1') + '<b><font color="red">' + user_name + '</font></b>
';
msg += + i18n.getI18NMessage('7office.dlg.welcomemsg2') + '<b><font color="red"> ' + gusercomid$to_com.company_name;
msg += '</font></b> ' + i18n.getI18NMessage('7office.dlg.welcomemsg3') + ' ' + globals.gservoy_id
plugins.dialogs.showInfoDialog(title, msg);
IT2Be
October 20, 2004, 1:29pm
6
Why don’t you do this:
the key ‘7office.dlg.welcomemsg’ looks like:```
Welcome
{0}
of
{1} ID {2}
```
the method looks like:
var msg = i18n.getI18NMessage('7office.dlg.welcomemsg', new Array(user_name, gusercomid$to_com.company_name, globals.gservoy_id));
plugins.dialogs.showInfoDialog(title, msg);
Marcel - excellent!
I totally forgot about replacing the placeholders with array values!
Bob Cusick
Morley
October 20, 2004, 2:47pm
8
Brilliant! Here’s the proof. Thanks Marcel
IT2Be
October 20, 2004, 2:48pm
9
So, you won’t ever doubt servoy from now till death do you part