How to translate Trac custom content added with site.html? - html

We have customized our Trac instance to display additional content to the newticket page, with the following site.html file (as explained in documentation):
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://genshi.edgewall.org/"
py:strip="">
<form py:match="div[#id='content' and #class='ticket']/form[#action='/newticket#ticket']" py:attrs="select('#*')">
<div class="warning">
<p>You are about to create a new JOSM ticket.
</p>
<p>Please make sure to always use this link in About Dialog (Shift-F1) to come here:</p>
<img src="raw-attachment/wiki/Help/Action/About/bugreport_small.png" alt="Bug report link in About dialog" height="53" width="361" />
<p>Clicking on this link prefills the bug report with useful information for us (Status Report).
</p>
<p>In any case, don't be shy :) Please let us a way to contact you if needed (either by creating an account or entering your e-mail address below (it won't be publicly visible but will allow us to reach you, and you will be notified about ticket progress).
</p>
</div>
${select('*')}
</form>
</html>
I don't see anything in the documentation about translation. How can we translate this text now?

Unfortunately this is not easy until something like the proposal for custom labels has been realized.
Currently it requires adding your additional msgids to Trac core PO files and recompiling and installing that custom Trac version - quite ugly and not remotely as modifiable as the template.
Providing custom translations within a plugin would not be effective, because plugin translations would reside in a translation domain, that is not evaluated for Trac core templates like the (new) ticket page.

I have finally come up with a small JavaScript solution.
It's simple when you only need a few languages with a text that doesn't change:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://genshi.edgewall.org/"
py:strip="">
<form py:match="div[#id='content' and #class='ticket']/form[#action='/newticket#ticket']" py:attrs="select('#*')">
<div class="warning">
<table style="border:0; border-collapse:separate; border-spacing:0 10px" class="wiki">
<tr><td style="background:#FFFC75; border:1px solid #ccc; border-right:0" valign="top">
<p id="josm_warning_01">You are about to create a new JOSM ticket.
</p>
<p id="josm_warning_02">Please make sure to always use Help/Report bug or this link in About Dialog (Shift-F1) to come here:</p>
<img src="raw-attachment/wiki/Help/Action/ReportBug/reportbug.png" alt="Bug report menu entry" height="84" width="207" />
<img src="raw-attachment/wiki/Help/Action/About/bugreport_small.png" alt="Bug report link in About dialog" height="53" width="361" />
</td></tr>
</table>
</div>
<script type="text/javascript">
if (navigator.language.indexOf('fr') == 0) {
document.getElementById("josm_warning_01").innerHTML = 'Vous êtes sur le point de créer un nouveau ticket JOSM.';
document.getElementById("josm_warning_02").innerHTML = 'S\'il vous plaît, assurez-vous de toujours utiliser Aide/Rapporter un bug ou ce lien dans la fenêtre À propos (Shift-F1) pour venir ici:';
} else if (navigator.language.indexOf('de') == 0) {
document.getElementById("josm_warning_01").innerHTML = 'Sie sind dabei, ein neues JOSM-Ticket zu erstellen.';
document.getElementById("josm_warning_02").innerHTML = 'Bitte nutzen Sie immer Hilfe → Fehler melden oder diesen Link im "Über JOSM..."-Fenster, um hierher zu gelangen:';
}
</script>
${select('*')}
</form>
</html>

Related

Which is the proper or best way to use i18n with many html tags on rails?

I have a code like that needs to be added to i18n, and I was wondering which would be the best/safest way to do it, For now I put it as is on i18n and called it on ruby code with a variable and html_safe, but I dont know if it implies any security danger, I also thought of passing the html tags as parameters of those i18n variables
<p>Através dos princípios da<strong> economia colaborativa </strong> e do <strong>
<span id="yellow">poder da tecnologia</span></strong> nosso modelo de negócio
alia a <strong> <span id="green"> expertise do executive search </span></strong>
<strong><span id="red">, a </span></strong>importância das relações humanas <strong> e o<span id="blue">alcance das redes</span>
You might want to have localized snippets for the whole thing instead (Rails Guides: Localized views):
spanish version in own file
# marketing.es.erb
<p>Através dos princípios da<strong> economia colaborativa </strong> e do <strong>
<span id="yellow">poder da tecnologia</span></strong> nosso modelo de negócio
alia a <strong> <span id="green"> expertise do executive search </span></strong>
<strong><span id="red">, a </span></strong>importância das relações humanas <strong> e o<span id="blue">alcance das redes</span>
and then the english one
# marketing.en.erb
<p>Something<strong> in english</strong>... <strong>
<span id="yellow">... </span></strong>
And automatically include the correct partial
(other content)
<%= render :marketing %>

Trouble in converting PCRE Regex to sed

I'm running into trouble on how to use a working PCRE regex in sed. I found a related topic, but unfortunately it's not working for me (I'm working on Linux not MacOS X if that should be necessary information).
I have some HTML code of which I need a special part - however not between the same tags. The regex I have is working according to some regex testing sites (like regex101 or regexr.com), however, when trying to use it on sed, it shows me the whole file instead of the wanted part.
My regex is:
/((<div id="main-content" class="wiki-content">)([\w\d\s\S]*))(<\/rdf:RDF>\n-->)/g
It grabs a part starting with the specific div and collects everything including the following RDF part.
The text I'm working with looks (with the interesting part - the rest around I cut due to length and also this part only appears once the file) as follows (inlcuding the gaps):
[...]
a href="#page-metadata-start" class="assistive">Go to start of metadata</a>
<div id="page-metadata-end" class="assistive"></div>
<div id="main-content" class="wiki-content">
<p><br/></p><p><br/></p><div class="panel conf-macro output-block" data-hasbody="true" data-macro-name="panel" style="border-color: #004237;border-width: 1px;"><div class="panelHeader" style="border-bottom-width: 1px;border-bottom-color: #004237;background-color: #004237;color: white;"><b>Inhalt</b></div><div class="panelContent">
<p> </p><div class="toc-macro client-side-toc-macro conf-macro output-block" data-hasbody="false" data-headerelements="H1,H2,H3,H4,H5,H6,H7" data-macro-name="toc"> </div><p> </p>
</div></div><h1 id="id-01-Dokumentation-1EinstiegindiePlanung">1 Einstieg in die Planung</h1><p><br/></p><h2 id="id-01-Dokumentation-1.1Startseite">1.1 Startseite</h2><p>Nach der Anmeldung im System findet sich der User auf der Startseite wieder. Von hier aus gelangt er zur "Planning Map".</p><p>Durch das Umschalten der Company auf die Counter Company kann der Planer die zuvor eingetragenen Werte kontrollieren. Diese erscheinen nach dem Umschalten in der zweiten<br/>Tabelle als negativer Wert auf dem gemappten IC Account.</p><p><br/></p><div class="table-wrap"><table class="wrapped confluenceTable"><colgroup><col/><col/><col/></colgroup><tbody><tr><th class="confluenceTh">Button</th><th class="confluenceTh">Aktion</th><th class="confluenceTh">Beschreibung</th></tr><tr><p>Alle Eintragungen werden auf der untersten Ebene (weißer Hintergrund) ausgeführt. Monate, die nicht mehr beplant werden können sind farblich hinterlegt. Ebenfalls farblich hinterlegt sind<br/>die Accounts, die hier nicht beplant werden können (IC / Capex und Rule belegte Accounts).</p><p><br/></p><div class="table-wrap"><table class="wrapped confluenceTable"><colgroup><col/><col/><col/></colgroup><tbody><tr><th class="confluenceTh">Button</th><th class="confluenceTh">Aktion</th><th class="confluenceTh">Beschreibung</th></tr><tr><td colspan="1" class="confluenceTd">Back</td><td colspan="1" class="confluenceTd">Sheet Wechsel</td><td colspan="1" class="confluenceTd">Zurück zum Sheet Planning Map</td></tr><tr><td colspan="1" class="confluenceTd">Refresh</td><td colspan="1" class="confluenceTd">Prozess ausführen</td><td colspan="1" class="confluenceTd">Sheet wird nochmals neu aufgebaut</td></tr></tbody></table></div>
</div>
<!--
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
<rdf:Description
rdf:about="https://confluence.example.org/confluence/display/KUN/01+-+Dokumentation"
dc:identifier="https://confluence.example.org/confluence/display/KUN/01+-+Dokumentation"
dc:title="01 - Dokumentation"
trackback:ping="https://confluence.example.org/confluence/rpc/trackback/47022143"/>
</rdf:RDF>
-->
[...]
So when I try this regex on the mentioned test websites, it marks the part I need (between <div id="main-content" class="wiki-content"> and </rdf:RDF>\n-->).
But when using sed -r '/((<div id="main-content" class="wiki-content">)([\w\d\s\S]*))(<\/rdf:RDF>\n-->)/g' testfile.txt it shows me the complete file content instead only the part I'm looking for (sed -E... produces the same).
I can't work out, where my problem is, so any help would be very much appreciated. Also, I'm not a professional regex user...
I'm not sure about how it will work in your case, as I need probably some more data, but this one could work for you:
sed -ne '/<div id="main-content" class="wiki-content">/,/-->/{p}' file.html

Google Language Translator overrides the style

I am creating a website using wordpress and I just integrate Google language translator . Everything works fine but the problem is that when I translate language it changes the font size . So by default (without translating) I am getting
<h1 class="intro-text">iDEAS , Solutions , Strategies for your Business <br>
</h1>
from the inspect element . But when I translate it to Spanish or any other languages it reduce the size . I inspect in the Inspect element and I am getting
<h1 class="intro-text">
<font><font>ideas, soluciones, estrategias para su negocio </font></font>
<br> </h1>
. That is why the problem occurs how to over come this . If I translate I need a result like ,
<h1 class="intro-text">
ideas, soluciones, estrategias para su negocio
<br> </h1>
any help will be really appreciated .
If you want same font-size even when you translate the page, then you should write CSS for font tags which are being appended while the translation within class="intro-text".
<!-- Bofore Translation -->
<h1 class="intro-text">
iDEAS , Solutions , Strategies for your Business <br>
</h1>
<!-- After Translation -->
<h1 class="intro-text">
<font><font>ideas, soluciones, estrategias para su negocio </font></font><br>
</h1>
CSS:
.intro-text,
.intro-text font { font-size:20px;}
This will maintain the same font-size after the translation.

Can't delete the space and backgroundcolor in table

I'm trying to build a newsletter with tables. div boxes aren't working to 100 % percent in every mail client.
As you can see, here
is this what I prepared in Photoshop and I have some problems with the tables. How can I delete this space between the two images down and change the background color from the text ( in the middle of the pictures and the buttons ) to grey, if I'm giving it a new td ,then is nothing working. It should look like the pic I uploaded. would be very nice if you can help me out.
<td width="29"> </td>
<td width="291" valign="top">
<a target="_blank" href="#">
<img src="images/angebotbild1.jpg" style="display: block;" border="0" width="355" height="150"></a>
<div style="margin-top: 3px;"></div>
<font color="#778da7" face="Trebuchet, Arial, Verdana, Helvetica, sans-serif" size="2" style="font-size: 12px">
Wie gemacht für alle, die den etwas
anderen Sommer
erleben wollen: Diese Reise führt Sie zu den großen
Metropolen und kleinen Städten des Baltikums. Jede
davon wird Sie durch den Kontrast zwischen prunkvoller
Architektur in den historischen Stadtzentren und der
nachhaltigen in den neuen Arealen Bauweise faszinieren.
Jeder Ort erzählt hier seine eigene, spannende
Geschichte. Lassen Sie sich verzaubern.
</font>
<img border="0" src="images/button.jpg" width="335" height="60" style="display:block;" border="0" />
</td>
</tr>
</table>
jsfiddle
here is the complete code,
Change your style inside bottom a link from float:right to float:left
change img tag inside a link, and make the image width 355 instead of 335.
The bottom button is an image (button.jpg), you can only change it's background color by edit with photoshop, and don't forget to change its image size to 355px.
Next time please put your files in public area, we can not see what does it look right now and can only guess how it suppose to look like.
Since the OP answer seems to be covered already, here is an alternative output option for you for future use(s):
Rather than creating the tables yourself and manually working with the code, you can allow Photoshop to automate the process within the save for web option. This alternative allows you to save images as well as text so the text area you have in that section would simply be a slice type of No Image (Right Click with slice tool on a slice > Edit Slice Options). Now simply add the text right there within that selected slice.
When you save for web it will output a table with the images and text aligned properly. You can then clean up the text within the table with css to suit your needs.

Joomla add &quote on my html code

This is my first time using Joomla. I'm editing a website and if I change the code in the module and save it, Joomla adds \" to all attributes.
This is my code
<div class="container-fluid">
<h1 id="consumers">Per chi compra</h1>
<div class="row-fluid">
<div class="span3 gk-demo-content"><img src="templates/meet_gavern/images/content/icon_tick.png" alt="Affidabile, come PayPal" title="TrustBack.me è affidabile" width="109" height="109" />
<h2>Affidabile. Come PayPal.</h2>
<p>Misuriamo l'affidabilità del commercio elettronico. E quando è vero, ci permettiamo anche di dire che un merchant non è affidabile.</p>
</div>
This is the code edited by Joomla :D
<div class="\"container-fluid\"">
<h1 id="\"consumers\"">Per chi compra</h1>
<div class="\"row-fluid\"">
<div class="\"span3"><img src="\"templates/meet_gavern/images/content/icon_tick.png\"" alt="\"Affidabile," title="\"TrustBack.me" width="\"109\"" height="\"109\"" />
<h2>Affidabile. Come PayPal.</h2>
<p>Misuriamo l\'affidabilità del commercio elettronico. E quando è vero, ci permettiamo anche di dire che un merchant non è affidabile.</p>
</div>
Check your php.ini to see if you have Magic Quotes disabled. If you don't have access to this file, check in the Joomla backend, by going to: [System] -> [System Information] -> [PHP Setting]
If it's set to "on", ask your host if they can turn it off for you.
Also, again in the Joomla backend, go to: [System] -> [Global Configuration] -> [Text Filter Settings] and ensure it is set to "No Filtering" for Super Users.
Please also ensure you are running the latest version of the Joomla 3.0 series (3.0.3).