How to translate strings in RML? - report

I made a RML report, which is working perfect. In the translation files, the strings which are in the RML file are included, so I can translate the content of the report. But there's one case in which strings aren't recognized, therefore these can't be translated. I'm going to put an example:
Next line is working, "Category" is recognized by the translation files and I can translate it there.
<para style="terp_tblheader_General_Centre">Category</para>
Next one isn't working:
<para>[[ o.type == 'r' and 'Registration' or 'Deregistration' ]]</para>
That is the unique case in which strings are not being recognized. type is a selection field (which can take the values 'r' or 'd'), and I wrote that line to see in the report Registration (in case of type valueing 'r') or Deregistration (in case of type valueing 'd'). But Registration and Deregistration are not being recognized as words to be translated.
I saw this post:
Translation of strings in python code in RML reports
And I tried to write _('Registration') / _('Deregistration') and then _(Registration) / _(Deregistration) instead of 'Registration' / 'Deregistration', but in this case the string don't even appear in the report.
Anyone can help me, please?

For translation you must have to insert text in .po file. You check out under i18n folder for core modules like sale, purchase, account.
Load the translation under this path Setting => Translations => Load a Translation
Now assign language to the partner.
Add text value in .po file
Based on partner language it will change the text label like here is sample code of .rml file
<story>
<para style="terp_default_8">[[repeatIn(objects,'o')]]</para>
<para style="terp_default_8">[[ setLang(o.partner_id.lang) ]]</para>
Hope this will help you.

Related

TinyButStrong magnet tag shows in output docx

Hi my colleague and I has been trying to get the TinyButStrong plugin openTBS to create some docx files.
We have a live system which creates some RTF files, with data from MySQL. We want to change this to docx, use openTBS. A couple of super users then in Word manage the templates.
We have a problem with creating the files, as we need to remove a line, if data isn't present.
If we in the Word template do
<w:p>[*fieldname*;magnet=w:p]*some kind of text*</w:p>
it hiddes the line if fieldname contains no data, and if if contains data, it will show the line. GREAT :-)
The problem is, that it also shows <w:p> and </w:p> when it contains data, and we don't like that.
How do we get it to stop showing these tags?
The TBS parameter ope=minv is done for thus purpose: it performs the magnet behavior but keep the field invisible (minv stands for magnet invisible).
So the solution is:
<w:p>[*fieldname*;magnet=tbs:p;ope=minv]*some kind of text*</w:p>
By the way, magnet=tbs:p is better than magnet=w:p because your template stays compatible when converted to another other format (LibreOffice).

poedit doesn't recognize _x

My .po file contains:
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
"_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;_ex:1,2c;"
"esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n"
And my php/wordpress code contains:
_x( 'Add New', $this->post_type , $domain ),
I know that Poedit is scanning that file (all the other translatable strings are picked up on "update catalog", and share the same domain). And if I change _x to __ (and remove the context parameter) it picks that one as well. But as it is written, the "Add New" string simply wont show in PoEdit.
Even if I add manually the string to the po file, it will put it in the "obsolete strings" after trying to update to .po file from sources...
Would have thought that the "_x:1,2c;" bit would be enough to pick up the string, but it never does.
Is there something I'm doing wrong, or have I encountered an actual bug?
See the documentation for _x() at http://codex.wordpress.org/Function_Reference/_x — the second argument is context, which is a string included in the PO together with the source text to disambiguate otherwise identical strings with different meaning. The codex page above has an example; another one is e.g. "Open" that could be used in different context, so the programmer would use e.g. "File menu" as the context.
The important part is that it is handled the same way as the text to be translated. The text has to be a string literal for xgettext to extract it and so does the context (it has to be: it's something that goes into the PO file!).
$this->post_type is not a literal, which is why xgettext doesn't recognize it. There's no way it could know what the post_type value could be at runtime and so it couldn't possibly know what to write into the created PO file.
To fix this, you need to use _x() with at least the first two arguments string literals.

Why do my Tridion Binary links not show when using REL?

I am generating a Tridion binary link as follows:
Razor TBB generates Link Resolver syntax for binary link
Link resolver TBB generates TCDL.
The output is published as a Dynamic component template of output type REL. The publication target specifies ASP.NET.
What I see in the COMPONENT_PRESENTATIONS table of the broker database is output like this:
<tcdl:Link type="binary" origin="tcm:0-0-0"
destination="tcm:34-669" templateURI="tcm:0-0-0"
linkAttributes="" textOnFail="true" addAnchor=""
variantId="">Document2</tcdl:Link>
so you'd expect at the least to see the text "Document2"
If I hand-craft a binary link control <tridion:BinaryLink..../> this works just fine, however there is no visible output generated by the TCDL listed above.
What might be going wrong? What should I investigate next?
We noticed the same behavior that the Link Resolver TBB does not generate the right case for binaries type. It being generated as <tcdl:Link type="binary" ../> instead of <tcdl:Link type="Binary" ../> (note the lower case b instead of Uppercase B, tough one to catch). The REL TCDLTagRender is case sensitive and does not resolve the tcdl:link with lowercase type:binary and you will see the warning message in cd log files (assume you have log level set to warn or debug).
"WARN LinkTagRenderer - Link type does not exist."
The work around is to replace the output of lowercase binary with the uppercase Binary by introducing a new TBB. We included this as part of the TBB to resolve the RTF field binary link resolving for any multimedia linking like pdf, doc etc..
You do a string replace the lowercase binary with Binary as below in the TBB.
string output = package.GetValue(Package.OutputName);
output = output.Replace("type=\"binary\"", "type=\"Binary\"" );

AppleScript to download files from HTTP server, mutating the URL?

I've never messed with AppleScript so this is only a concept to me. Can this work?
Bungie, the game designer, is hosting a ton of PNGs for Halo Reach in systematically named files and directories. IE:
http://www.bungie.net/images/reachstats/commendations/onyx/onyx_large_precision_multiplayer.png
Change two instances of the same word, and you generate another version of the image. Change "onyx" to "iron", "bronze", "silver" or "gold" and you get a corresponding image, like so:
http://www.bungie.net/images/reachstats/commendations/gold/gold_large_precision_multiplayer.png
Would an AppleScript be able to take an input URL, find and change the instances of the words in the URL, and then download the associated file to a directory? Today is my birthday (Oct 27th! hence the XXVII) and if this will work I would be super excited if someone could make this!
Thanks for all of your kind answers!
This works:
set the destination_file to ((path to desktop as string) & "picture.jpg") as file specification
set thisImageSRC to "http://www.bungie.net/images/reachstats/commendations/gold/gold_large_precision_multiplayer.png"
tell application "URL Access Scripting"
download thisImageSRC to destination_file replacing yes
end tell
String manipulation is done completely with changing Applescript's text item delimiters. So to get the components of the URL into a list, you need to do the following:
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to "/"
set theUrlComponents to (every text item of theURL) as list
set AppleScript's text item delimiters to oldDelims
Add salt to taste, but I agree with the first commenter that there are better languages to do this. Applescript would be my last choice here.

Getting extension of the file in FileUpload Control

At the moment i get file extension of the file like :
string fileExt = System.IO.Path.GetExtension(filUpload.FileName);
But if the user change the file extension of the file ( for example user could rename "test.txt" to "test.jpg" ), I can't get the real extension . What's the solution ?
You seem to be asking if you can identify file-type from its content.
Most solutions will indeed attempt the file extension, but there are too many different possible file types to be reliably identifiable.
Most approaches use the first several bytes of the file to determine what they are.
Here is one list, here another.
If you are only worried about text vs binary, see this SO question and answers.
See this SO answer for checking if a file is a JPG - this approach can be extended to use other file headers as in the first two links in this answer.
Whatever the user renames the file extension to, that is the real file extension.
You should never depend on the file extension to tell you what's in the file, since it can be renamed.
See "how can we check file types before uploading them in asp.net?"
There's no way to get the 'real' file extension - the file extension that you get from the filename is the real one. If file content is your concern, you can retrieve the content type using the .ContentType property and verify that it is a content type that you are expecting - eg. image/jpg.

Resources