There is no other way around than somehow identifying the translated parts (using regexp maybe?) and then setting the translated text again after passing it to tr().
There is no other way around than somehow identifying the translated parts (using regexp maybe?) and then setting the translated text again after passing it to tr().
J-P Nurmi
Hi,
sorry i don't know what are you mean. Can you give me a example please.
Thanks in advance,
Whitefurrows
I think that in that situation you should tr() the whole html code and provide translations for it in the translation file.
Qt Code:
html->append(tr("<HTML><BODY>Text to be translated goes here<BR>\\n" "and you can even have arguments for it like this: %1</BODY></HTML>") .arg(tr("Some argument")));To copy to clipboard, switch view to plain text mode
Hi,
thank you, but this is not my problem. I have attach a example and hope you can help me.
Thanks in advance,
Whitefurrows
And what is the difference between the two?
It’s not unconditional necessary to translate a argunent like arg(tr("Some argument")). I don’t know how can i translate a text that is set in a QTextEdit, can you help me?
Tanks in advance,
Whitefurrows
Nobody says you have to have any arguments. I just said there is a possibility to do that, I didn't say you have to use it. If you have an append() call in your code, just recreate the contents using the same calls. If all those appends have a meaning, you can surely create a list of "commands" and refill the text edit with those commands (think of them as templates) translated to the appropriate language.
Hi,
sorry i don't know how can i create a list of "commands" and refill the text edit with those commands. I have made a example that show you exact what i need, but is not so complex as the original. Please take a look at the example i have need a lot of time to make the example so easy for you. I hope you can help me.
Thanks in advance,
Whitefurrows
I'm sorry, I just don't see the problem, you mean this?
Qt Code:
void MainWindow::showResult(int result) { QString html; html.append("<HTML><BODY>"); html.append("<table border=\"0\" width=\"100%\">"); html.append("<tr><td align=\"center\">" + tr("The result is:") + "</td>"); html.append("</table>"); html.append("</HTML></BODY>"); ui.info->document()->setHtml(html); };To copy to clipboard, switch view to plain text mode
Just store the result somewhere and call this method again with the stored value when you need to retranslate the text edit.
BTW. You can substitute with .
Hi,
thank you for your great help. i think i can do that, i store the result and call showResult again. What can i do in showInfo i set the text again but that wasn't translate. Can you help me?
Thanks in advance,
Whitefurrows
You mean this?
Qt Code:
InfoView info(infos[i], this);To copy to clipboard, switch view to plain text mode
In this situation you have to call tr() here to do the translation and don't translate in setInfo(). You should only translate strings when they are displayed on screen (or shown to user in some other way). In setInfo() you should only mark strings for translation with QT_TR_NOOP().
Hi,
thank you, that's fine. A last little questin. Now is all working, the only thing what's not OK is that:
Qt Code:
To copy to clipboard, switch view to plain text mode
What can i do to translate? I don't want translate the html code.
Thanks in advance,
Whitefurrows
Bookmarks