How can I put placeholders for numbers in google translate API? - google-translate

I have an Android-style string along the lines of say:
You got %1$s questions out of %2$s correctly
how do I pass this string in google translate API to get a correct translated string with placeholders?

You can use the html5 translate attribute:
You got <i translate="no">%1$s</i> questions out of <i translate="no">%2$s</i> correctly
The API should not translate what's inside the html tag.
Finally, you can remove the html tags added with a regex in the translated string.

Related

Convert html tagged text to string for a pdf itext7

I am working on a project in asp.net MVC which involves printing various information that the user enters previously.
I use the TinyMCE for comment type fields.
As we know Tiny allows you to format text using different types of fonts, adding bold words, etc.
The string it produces will have tags that allow reading the style chosen for the word or phrase in HTML.
I use Itext7 to produce pdfs, when I print the fields I mentioned above, obviously all the HTML tags are shown, for example:
<p> Hello World! </p>
Is there a way to tell Itext7 that when these tags are present, it must use an associated style for that tag?
I created "Hello World" here and used bold, italic and underline. Copy the source code via "Tools" and just use the following code to convert it via iText7:
String htmlString = "<p><span style=\"text-decoration: underline;\"><em><strong>Hello World</strong></em></span></p>";
HtmlConverter.convertToPdf(htmlString, new PdfWriter(destinationFolder + "test.pdf"));
The resultanting PDF:

How to use notranslate in Google Translate text file

How to tell Google to not translate some text file in a text file? This is my sample text file:
"hp1": "Swipe to the right to reveal the left menu.",
"hp2": "(On desktop click and drag from left to right)",
"ht": "Welcome",
"TITLE": "Welcome",
"name":"Gowrisankar Reddy"
google converting above one like this
"hp1": "ఎడమ మెనుని బహిర్గతం చేయడానికి కుడివైపుకు స్వైప్ చేయండి.",
"hp2": "(డెస్క్టాప్ క్లిక్ చేసి ఎడమ నుండి కుడికి లాగండి)",
"ht": "స్వాగతం",
"TITLE": "స్వాగతం",
"పేరు": "గౌరీశంకర్ రెడ్డి"
I don't want to convert "name". How can I do that?
I am not using HTML, using text file only.
Thanks.
I am using google translate not used any code
Google Translator can normally skip translations by HTML tags with class notranslate.
But since it has a built-in html parser, as a hack, you can pretend one or more words are a tag.
<name> will not get translated
Another hack is to capitalize NAME

Replace commas with <br> in CSS

We are using a CRM database which is accessed from a web console front-end. One of the merge fields retrieved from the database is the site address, which is returned as a one-line string separated by commas instead of the address format used for mailing addresses.
That is, instead of:
45 Seafield Place
FORT WILLIAM
PH33 4XJ
...it inserts:
45 Seafield Place, FORT WILLIAM, PH33 4XJ
As a proprietary product, we have no access to the configuration of the web server or the ability to modify the PHP used to generate the pages within it. The templates for customer letters are fully customisable and are simple HTML, with a #media print CSS block to control the styling when letters are printed straight from the browser (similar to Google Docs).
As I cannot control the content or make use of JavaScript/JQuery to perform text replacement, is there any way CSS can replace each comma within a class with a <br> tag?
unfortunately the only way to achieve this is using javascript.
since your server strips all javascript from the page, you have to 'trick' it and add javascript that it will not strip.
i believe it can be done by putting your javascript code into an onload attribute of your body element, this way the server will not see it as javascript but rather just an attribute and will leave it be.
<body onload="var spans = document.querySelectorAll('span');spans[0].innerHTML=spans[0].innerHTML.replace(/,/g,'<br/>');">
<span>
45 Seafield Place, FORT WILLIAM, PH33 4XJ
</span>
</body>
Live Example
UPDATE
you can even strip the javascript code yourself after executing it:
<body onload="var spans = document.querySelectorAll('span');spans[0].innerHTML=spans[0].innerHTML.replace(/,/g,'<br/>'); document.getElementsByTagName(
'body')[0].removeAttribute('onload');">
<span>
45 Seafield Place, FORT WILLIAM, PH33 4XJ
</span>
</body>
2nd Example

Mediawiki Extension:RSS

The MediaWiki Extension:RSS (http://www.mediawiki.org/wiki/Extension:RSS) uses the plainlinks class to present the RSS feed link. I have tried all manner of searching, including trying to edit the MediaWiki:Rss-feed template to force the link to presented in non-bolded format.
Has anyone used this extension and can tell me how to change the fonts in the RSS link?
Thanks
As far as I can understand your question, you should be able to remove the boldface formatting from the RSS item titles by editing the page MediaWiki:Rss-item (not MediaWiki:Rss-feed) on your wiki.
What you need to do is two things:
remove the string ''' (MediaWiki markup for bold text) from either side of the title, and
remove the ; (MediaWiki markup for a list definition, which is also bolded by the default style sheet) from the beginning of the line.
That is, change the default content of the page:
; '''<span class='plainlinks'>[{{{link}}} {{{title}}}]</span>'''
: {{{description}}}
: {{{author}}} {{{date}}}<!-- don't use newline here -->
to this:
<span class='plainlinks'>[{{{link}}} {{{title}}}]</span>
: {{{description}}}
: {{{author}}} {{{date}}}<!-- don't use newline here -->

Set google translate don't translate name

I using google translate to translate the entire of my site. but i want Google don't translate some name. Example on this link. http://ulundanu.gusdecool.com/facilities/restaurants
There is name “Ulun Danu Restaurant”, when we translate it into Indonesia. It change into "Pura Ulun Danu Restaurant". I want google didn't translate that part. How to do that?
maybe is there some option put some class on it to make google understand not translate that part.
Just add class="notranslate" to any HTML element to prevent that element from being translated.
<span class="notranslate">Ulun Danu Restaurant<span>
Google Translate Help-Preventing translation of your webpages

Resources