How does QT Linguist know the ts file defined in the project file is for a specific language? (Is the "_ja" characters in the name how it determines the language? I couldn't find anything in the documentation.)
I have a ts file defined as "testdata_ja.ts" in the project file. Running lupdate, the file is generated. In the ts file there is a line:
<TS version="2.1" language="ja_JP">
lupdate seemed to figure it out, but nothing was translated, all entries are "unfinished". I put an entry in the code that was in the Japanese phrase book.
The phrasebook is just a hint/help for the human translator, lupdate will never automatically translate anything for you. Any translations in the .ts file still need to be populated and/or marked as completed "manually" (typically in QtLinguist, but one could use any text editor, or a script, or whatever).
Related
I try to upload the Base App.xlf file from English into German (by Business Central 15), but everytime I upload the file, I receive an error that says "Failed to extract the contents of the uploaded file." after 2-3 minutes. If I upload a smaller .xlf file, everything is fine.
Base App.xlf: 62.25Mb
Smaller file: 74Kb
Both files are written in xliff version 1.2. Regarding to the post below, Custom Translator supports it in 2018.
Custom translator cannot extract contents of XLIFF file
I can't figure out, why the bigger file is not processed. Some more information would be useful. Is this error thrown cause of special character?
I just figuered out that the Base Application has some missing -tags in the -tags, which leads to the error, obviously. I used an xlst-File to delete tags with missing . This deleted -tags with an empty -tag, too.
I've got an issue with a Wordpress that I'm taking over now.
There is a .mo file containing some translations and a .po file that seems to be the source. The .po file seems have been generated somehow but its structure look a little weird to me.
Here is what can be found inside.
#: /Users/yui/Sites/fondation/wp-content/themes/fondation/taxonomy-programme.php:24
msgid "Exhibitions"
msgstr "Expositions"
#: /Users/yui/Sites/fondation/wp-content/themes/fondation/archive.php:69
#: /Users/yui/Sites/fondation/wp-content/themes/fondation/single.php:43
msgid "[:en]Events[:fr]Evénements[:de]Events[:pl]Events"
msgstr ""
When I try to generate the .mo file msgcat fondation-fr_FR.po | msgfmt -o fondation-fr_FR.mo - the .mo file contains only the first one (with both msgid and msgstr) but not the other one. The website also have an issue with that and display only the translation found in the .mo file.
Any thoughts on how to fix the .po file? Is it an old format?
but its structure look a little weird to me.
Indeed. Looks like being done by somebody who had no idea how gettext works or that manuals are a thing and creatively abused gettext files (case in point: see the multiple translations in the msgid of all places).
The second string is not included in the compiled translations table (i.e. MO) because it has no translation — msgstr is empty.
BTW, everything about how gettext works, including how strings are retrieved and why it makes no sense to include untranslated entries in MO (hint: the string is already in the code!), is very well explained in the GNU gettext manual.
BTW2, that invocation of msgcat is also an entirely pointless busy work — see its man page for what it does (same as cat plus some smarts).
For the records.
The .po file had been generated by an old version of qtranslate plugin for Wordpress which didn't know how to properly handle the gettext functions in its firsts versions.
Nothing could be done to get the .po file to work. I had to create a new one manually.
silverstripe does not seem to pick up changes in the language yml files. This used to work. As usual I am doing ?flush=all after the files are changed...
In the templates I am using the t- function like <%t General.GoToPortfolio "zum Portfolio" %>
I was editing existing entries, but the template always shows the old 'version' of the entry. If I remove the en.yml file then the translations are really gone. So I am assuming it works at least a little bit...
At the moment I am using silverstripe 3.1.12
The files are saved here e.g.: module/lang/en.yml
Thanks,
Florian
I had this problems some time ago with german umlauts and wrong encoding of the files. So either tell your editor or IDE to encode and write proper utf-8 (best without bom) or htmlencode your umlauts.
finally found it:
deleted the contents of silverstripe-cache folder and it worked.
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.
I've got a web page with a link, and the link is suppose to correspond to a PDF is the given user's language. I'm wondering where I should put these PDF files though. If I put them in App_LocalResources, I can't specify a link to /App_LocalResources/TOS_en-US.pdf can I?
The PDF should definitely not be in the App_LocalResources folder. That folder is only for RESX files.
The PDF files can go anywhere else in your app. For example, a great place to put them would be in a ~/PDF folder. Then your links will have to be dynamically generated (similar to what Greg has shown):
string cultureSpecificFileName = String.Format("TOS_{0}.pdf", CultureInfo.CurrentCulture.Name);
However, there are some other things to consider:
You need a way to ensure that you actually have a PDF for the given language. If someone shows up at your site and has their culture specified as Klingon, it's unlikely that you have such a PDF.
You need to decide exactly what the file format will be. In the example given, the file would have to be named TOS_en-US.pdf. It you want to use the 2-letter ISO culture names, use CurrentCulture.TwoLetterISOLanguageName and then the file name would be TOS_en.pdf.
I would store the filename somewhere with an argument in it (i.e. "TOS_{0}.pdf" ) and then just add the appropriate suffix in code:
string cultureSpecificFileName = string.Format("TOS_{0}.pdf", CultureInfo.CurrentCulture);
Does the PDF have to have the same file name for each of the different languages? If not, put them all into a directory and just store the path in your resources file.