How to generate language file using linguist and lrelease - qt

I have some code in a proprietary language. Its specially generated to make "plugin-code" and formulars. The main program is developed in c++.
The code looks like
a$ = pm("Datum")
b$ = pm("Seite %1!", page$)
The first argument in the pm() function is the text to be translated. "%1"... should be replaced by the following arguments, that must be strings. "a$", "b$" and "page$" are string variables.
The handout says, to use this function, I need a "foreign language catalogue". To make this I have to use "linguist" and "lrelease".
I have installed (all version 5.12.3)
linguist
lrelease
lpupdate
So how could I make language files?
I tried lupdate -recursive '.' -ts HAUSMITTEIL_de.ts (see here) but get the message
Scanning directory '.'...
Updating 'HAUSMITTEIL_de.ts'...
Found 0 source text(s) (0 new and 0 already existing)
and a XML file HAUSMITTEIL_de.ts
<?xml version="1.0" encoding="utf8"?>
<!DOCTYPE TS>
<TS version="2.1" language="de_DE">
</TS>
I miss the strings to be translated.

Related

How can I get "canonical" name of the text encoding of current Atom active editor?

I have recently adding a fix for atom-script package to resolve garbled text output in compile&run Java code in non-English Windows environment. (Issue #1166, PR #2471)
After this, now in release script package 3.32.1, javac has options -J-Dfile.encoding=UTF-8 and -encoding UTF-8 both. (diff is here) I have just realized that it is better to provide actual encoding of the current active editor which holds the target source code for -encoding option. After some research, I have learnt that the encoding can be acquired by
atom.workspace.getActiveTextEditor().getEncoding()
but, after I have tested in Japanese edition Windows, it returns shiftjis and this is not valid encoding name for javac command line option. (It should be MS932, SJIS or something similar.) I have no idea where I can get this type of encoding names without writing large conversion table for all possible encoding names. Is there any good utility for such purpose?
EDIT:
For demonstrating what I have supposed to do, I have created branch on my fork. Diff is here.
Getting current source code editor encoding by
const fileEncoding = getJavaTextEncodingName(atom.workspace.getActiveTextEditor().getEncoding())
and pass it to javac via
const cmd = `javac -encoding ${fileEncoding} -J-Dfile.encoding=UTF-8 -Xlint -sourcepath '${sourcePath}' -d '${tempFolder}' '${filepath}' && java -Dfile.encoding=UTF-8 -cp '${tempFolder}' ${classPackages}${className}`
And, function "getJavaTextEncodingName()" is the core of the question.
function getJavaTextEncodingName(atomTextEncodingName) {
switch (atomTextEncodingName) {
case "shiftjis" :
return "MS932"
}
return "UTF-8"
}
It is obvious that this is converting "shiftjis" to "MS932" but, it is not so beautiful if we implement all possible encoding name conversions here, so I am seeking better alternative.

Avoid rendering of specific .md files from blogdown::serve_site()

I have a file located at
content/post/data_for_posts/my_file.md
I have it there because it's quite easy to do htmltools::includeMarkdown("data_for_posts/my_file.md") and recycle this file in different posts.
My problem is that when I serve_site() this creates a public/post/data_for_posts/index.html, which means, it gets posted to my website (as a January 1 of 0001). I guess I could change the date to year 10000, but I would rather handle it the way I handle the .Rmd and other files, as suggested here
I have tried to modify my config.toml but have not managed to solve the issue.
ignoreFiles = ["\\.Rmd$", "\\.Rmarkdown$", "_files$", "_cache$", "content/post/data_for_posts/my_file.md"]
Here are a couple techniques that I use to do this:
Rename data_for_posts/my_file.md so it uses a file extension that hugo does not interpret as a known markup language, for example change .md to .markd or mdn.[*]
Rename data_for_posts/my_file.md so it includes a string that you will never use in a real content file, for example data_for_posts-UNPUBLISHED/my_file.md. Then add that string (UNPUBLISHED or whatever) to your config ignoreFiles list.[**]
[*] In the content/ directory, a file with one of the following file extensions will be interpreted by hugo as containing a known markup language: .ad, .adoc, .asciidoc, .htm, .html, .markdown, .md, .mdown, .mmark, .pdc, .pandoc, .org, or .rst (this is an excerpt of something I wrote).
[**] The strings listed in ignoreFiles seem to be case sensitive so I like to use all-upper-case characters in my ignored file names (because I never use upper-case chars in real content file names). Also note that there is no need to specify the path and my experience is that path delimiters (/ or \) cause problems.

How to prevent Qt/cmake from adding carriage returns to resources on windows

I have a Qt program which was developed on Linux. In it are some user settings which are parsed from a config file. Of course, the users don't tend to have that config file during the first launch and we want things to work even if it isn't present, so a copy of the sensible defaults is stored in a resource text file, which is in the same format as the on-disk version would be.
I've run into an annoyance when running on windows...
The resources have had their "\n" line endings all converted to "\r\n" somewhere along the line! I'd really prefer to not have to alter the parsers to optionally accept more than one type of newline.
Is there a way to tell cmake to tell the Qt resource compiler to not do the conversion by passing a flag or similar?
EDIT: To clarify what's going on, I'll explain all of the little details of why I think qrc is adding the newlines...
First, I have a .qrc file which looks roughly like this:
<RCC>
<qresource prefix="/">
<file>res/DefaultSettings.txt</file>
</qresource>
</RCC>
It is added to the executable via cmake using code like this:
qt5_add_resources(QRC_SOURCES
resource.qrc
)
and
add_executable(my_project
resource.qrc
main.cpp
)
finally, it is being loaded with code like this:
QByteArray loadResource(const QString &resource) {
QResource res(resource);
if(!res.isValid()) {
qFatal("Failed to load internal resource");
}
// don't copy the data, if it's uncompressed, we can deal with it in place
auto defaults = QByteArray::fromRawData(reinterpret_cast<const char *>(res.data()), res.size());
if(res.isCompressed()) {
defaults = qUncompress(defaults);
}
// NOTE: at this point, using a debugger, I observe
// "\r\n" newlines in the defaults byte array
return defaults;
}
If by "resource" text file you mean a binary resource stored in the executable via qrc, then no: qrc will never alter the files - it doesn't discriminate between binary and text resources, it's all binary as far as it's concerned. Version control systems such as git may do that on checkin/checkout, though. You may also be reading the file using APIs that convert line endings. You'd ideally want to have a reproducer that outputs the file, and then another one that uses qrc to embed the file and then demonstrate the changed line endings.

What language is this file generated by Mascot version 1.0 written in?

I have been assigned a task to retrieve information from files that were processed from raw mass spectrophotometry data (file.mzML).
These files have just ".data" as extension and when I open them, I cannot recognize the language and therefore I cannot load them into R and work on them.
The files with the .data extension are contained in this folder:
ftp://ftp.pride.ebi.ac.uk/pride/data/archive/2015/11/PXD000299/
Could someone take a look at any of the files.data and tell me the language is in (e.g. F010439)?
EDIT: these is are some snippets
Lines 1 to 10
MIME-Version: 1.0 (Generated by Mascot version 1.0)
Content-Type: multipart/mixed; boundary=gc0p4Jq0M2Yt08jU534c0p
--gc0p4Jq0M2Yt08jU534c0p
Content-Type: application/x-Mascot; name="parameters"
LICENSE=Licensed to: INRA Tours, P-F Proteomique Analytique & Fonction.,Nouzilly (0085-0000003524/1), (2 processors).
MP=
NM=
COM=
Lines 120 to 130
NeutralLoss3_master=63.998285
--gc0p4Jq0M2Yt08jU534c0p
Content-Type: application/x-Mascot; name="unimod"
<?xml version="1.0" encoding="UTF-8" ?>
<umod:unimod xmlns:umod="http://www.unimod.org/xmlns/schema/unimod_2" majorVersion="2" minorVersion="0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.unimod.org/xmlns/schema/unimod_2 unimod_2.xsd">
<umod:elements>
<umod:elem avge_mass="1.00794" full_name="Hydrogen" mono_mass="1.007825035" title="H"/>
<umod:elem avge_mass="2.014101779" full_name="Deuterium" mono_mass="2.014101779" title="2H"/>
<umod:elem avge_mass="6.941" full_name="Lithium" mono_mass="7.016003" title="Li"/>
<umod:elem avge_mass="12.0107" full_name="Carbon" mono_mass="12" title="C"/>
It looks like that file is MIME-encoded "multi-part" file that contains (at least) two components files.
You can decode the multi-part using a MIME decoder.
The first component file looks like a simple "name=value" property file
The second component file is XML.
I don't know if this is relevant, but a search for Mascot file format gave me this reference page:
http://www.matrixscience.com/help/data_file_help.html
Also, there were some interesting hits when I searched for parser "x-mascot" and parser mascot. If you can find an existing parser, then you may be able to save yourself implementation effort.

lupdate is not getting tr() strings from QObject objects

I've been trying to make a simple text editor using QT Creator. This text editor has a translatable UI that supports 3 languages: English, Spanish, and Portuguese.
My problem is that every time I run lupdate, string literals in my code that are tagged as translatable (i.e. enclosed in tr() ) are parsed and can be edited and translated using QLinguist. However, strings that are part of QObjects (E.g. ButtonText for QFileDialog are not parsed. Am I missing some procedure in order for lupdate to parse these strings?
void PeterTextEditor::on_actionOpen_triggered()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Open Document"), QDir::currentPath(),
tr("Text documents (*.txt)"), 0, QFileDialog::DontUseNativeDialog);
if (fileName.isNull())
return;
if ( m_fileName.isNull() && !isWindowModified() )
{
loadFile(fileName);
return;
}
else
{
PeterTextEditor * openFile = new PeterTextEditor( fileName );
openFile->show();
openFile->setAttribute(Qt::WA_DeleteOnClose);
}
}
In above example tr("Open Document") would be parsed, but QFileDialog has QButton and QLabel objects with strings for button text and label text.These are not parsed. I would like these to be parsed so I could add translations using QLinguist.
All compiled translation files (*.qm) should be in the /translations directory and you would load them as shown in QFileDialog localization.
Unfortunately, the Qt libraries don't come with all translations for all languages, and, not all the translations supplied are complete.
For the version that I have (Qt 5.2.1), there is a Spanish translation(qt_es.qm) of the libraries but there are many strings that have not been translated yet, and there is no translation file for Portuguese(qt_pt.qm).
The translation of Qt to other languages is an ongoing project so I suggest you search the web and/or other forums to see if anyone has got updated files you can use.
If you cannot find any, and your Spanish translation is missing a couple of strings you need, you can file the source extraction files(*.ts) in the /Src/qttranslations/translations directory. Unfortunately, you probably will find only one for Spanish.
If you're willing to start a Portuguese translation, you can extract all the necessary strings you want by running lupdate on the /Src/qtbase/qtbase.pro file.

Resources