Why doesn't weblate recognize my pot file? - weblate

I'm using a hosted weblate.
I'm in the "Files" section of my component configuration.
Below is my setup.
Translation files:
File format: gettext PO file
Filemask: src/translations/*.po
Language filter: ^[^.]+$
Monolingual translations:
All fields empty
Edit base file checked
Adding new languages:
Template for new translations: src/translations/template.pot
Adding new translation: Create new language file
Language code style: Default based on the file format
I can't validate these settings, I have an error below fields "Template for new translations" and "Adding new translation":
The error is "Unrecognized base file for new translations".
I'm am 100% sure the pot file exists on the branch weblate is configured to use and also on master and that the path is correct.
Here are the first few lines of the pot file:
"Content-Type: text/plain; charset=UTF-8\n"
#: src/screens/CardList/CardList.texts.js:9
msgctxt "CardList"
msgid "hello"
msgstr ""
#: src/screens/CardList/CardList.texts.js:11
msgctxt "CardList"
msgid "cards"
msgstr ""
I don't understand what is happening, am I doing something wrong ?

The header of the file seems stripped. At least you should prepend following to make it syntactically valid:
msgid ""
msgstr ""
See https://github.com/WeblateOrg/weblate/blob/master/weblate/locale/django.pot for real life POT file

Related

OpenVMS - Add STRING to Filename via DCL

I have a number of files created by a program on our selling system that are produced in a format like the following:
CRY_SKI_14_EDI.LIS
CRY_SUM_14_EDI.LIS
THO_SKI_14_EDI.LIS
THO_LAK_14_EDI.LIS
CRY_SKI_IE_14_EDI.LIS
These files differ in numbers depending on the split of our product to different brandings. Is it possible to rename them all so that they read like the following:
CRY_SKI_14_EDI_DEMO.LIS
CRY_SUM_14_EDI_DEMO.LIS
THO_SKI_14_EDI_DEMO.LIS
THO_LAK_14_EDI_DEMO.LIS
CRY_SKI_IE_14_EDI_DEMO.LIS
I need the files to be correctly named prior to their FTP as a hardcoded file could potentially not exist due to the brand not being on sale and terminate the FTP which would prevent the other files following it from being transmitted to our FTP server.
The OpenVMS rename command is more handy (imho) than the windows or unix variants, because it can bulk change chuncks of the full file name. Such as 'name', 'type' or (sub)directory.
For example:
$ rename *.dat *.old
That's great but it will not change within the chunks (components) like the name part requested here.
For that, the classic DCL approach is a quick loop, either parsing directory output (Yuck!) or using F$SEARCH. For example:
$loop:
$ file = f$search("*EDI.LIS")
$ if file .eqs. "" then exit
$ name = f$parse(file,,,"name","syntax_only") ! grab name component from full name
$ rename/log 'file' 'name'_demo ! rename 'fills in the blanks'
$ goto loop
Personally I use PERL one-liners for this kind of work.
(and I test with -le using 'print' instead of 'rename' first. :-)
$ perl -e "for (<*edi.lis>) { $old = $_; s/_edi/_edi_demo/; rename $old,$_}"
Enjoy!
Hein

How to document Visual Basic with Doxygen

I am trying to use some Doxygen filter for Visual Basic in Windows.
I started with Vsevolod Kukol filter, based on gawk.
There are not so many directions.
So I started using his own commented VB code VB6Module.bas and, by means of his vbfilter.awk, I issued:
gawk -f vbfilter.awk VB6Module.bas
This outputs a C-like code on stdin. Therefore I redirected it to a file with:
gawk -f vbfilter.awk VB6Module.bas>awkout.txt
I created this Doxygen test.cfg file:
PROJECT_NAME = "Test"
OUTPUT_DIRECTORY = test
GENERATE_LATEX = NO
GENERATE_MAN = NO
GENERATE_RTF = NO
CASE_SENSE_NAMES = NO
INPUT = awkout.txt
QUIET = NO
JAVADOC_AUTOBRIEF = NO
SEARCHENGINE = NO
To produce the documentation I issued:
doxygen test.cfg
Doxygen complains as the "name 'VB6Module.bas' supplied as the second argument in the \file statement is not an input file." I removed the comment #file VB6Module.bas from awkout.txt. The warning stopped, but in both cases the documentation produced was just a single page with the project name.
I tried also the alternative filter by Basti Grembowietz in Python vbfilter.py. Again without documentation, again producing errors and without any useful output.
After trials and errors I solved the problem.
I was unable to convert a .bas file in a format such that I can pass it to Doxygen as input.
Anyway, following #doxygen user suggestions, I was able to create a Doxygen config file such that it can interpret the .bas file comments properly.
Given the file VB6Module.bas (by the Doxygen-VB-Filter author, Vsevolod Kukol), commented with Doxygen style adapted for Visual Basic, I wrote the Doxygen config file, test.cfg, as follows:
PROJECT_NAME = "Test"
OUTPUT_DIRECTORY = test
GENERATE_LATEX = NO
GENERATE_MAN = NO
GENERATE_RTF = NO
CASE_SENSE_NAMES = NO
INPUT = readme.md VB6Module.bas
QUIET = YES
JAVADOC_AUTOBRIEF = NO
SEARCHENGINE = NO
FILTER_PATTERNS = "*.bas=vbfilter.bat"
where:
readme.md is any Markdown file that can used as the main documentation page.
vbfilter.bat contains:
#echo off
gawk.exe -f vbfilter.awk "%1%"
vbfilter.awk by the filter author is assumed to be in the same folder as the input files to be documented and obviously gawk should be in the path.
Running:
doxygen test.cfg
everything is smooth, apart two apparently innocuous warnings:
gawk: vbfilter.awk:528: warning: escape sequence `\[' treated as plain `['
gawk: vbfilter.awk:528: warning: escape sequence `\]' treated as plain `]'
Now test\html\index.html contains the proper documentation as extracted by the ".bas" and the Markdown files.
Alright I did some work:
You can download this .zip file. It contains:
MakeDoxy.bas The macro that makes it all happen
makedoxy.cmd A shell script that will be executed by MakeDoxy
configuration Folder that contains doxygen and gawk binaries which are needed to create the doxygen documentation as well as some additional filtering files which were already used by the OP.
source Folder that contains example source code for doxygen
How To Use:
Note: I tested it with Excel 2010
Extract VBADoxy.zip somehwere (referenced as <root> from now on)
Import MakeDoxy.bas into your VBA project. You can also import the files from source or use your own doxygen-documented VBA code files but you'll need at least one documented file in the same VBA project.
Add "Microsoft Visual Basic for Applications Extensibility 5.3" or higher to your VBA Project References (did not test it with lower versions). It's needed for the export-part (VBProject, VBComponent).
Run macro MakeDoxy
What is going to happen:
You will be asked for the <root> folder.
You will be asked if you want to delete <root>\source afterwards It is okay to delete those files. They will not be removed from your VBA Project.
MakeDoxy will export all .bas, cls and .frm files to location:<root>\source\<modulename>\<modulename>(.bas|.cls|.frm)
cmd.exewill be commanded to run makedoxy.cmd and delete <root>\source if you've chosen that way which alltogether will result in your desired documentation.
A logfile MakeDoxy.bas.logwill be re-created each time MakeDoxy is executed.
You can play with configuration\vbdoxy.cfg a little if you want to change doxygens behavior.
There is still some room for improvements but I guess this is something one can work with.

How to double-click a file to perform a number of CMD commands on it (using "Open With...")?

I have a set of files with a common file extension, e.g. *.EXT.
These files are located in different folders on my PC.
I have a cmd script "Script.bat", located in C:/foo/ folder
I've set an "Open with..." file association for the *.EXT files to be opened by this "Script.bat" CMD script.
The questions is:
which variable do I have to use to designate the filename and the location of the doubleclicked EXT file within the script.
The associated application, in your case your batch file, will be called with the "double clicked" file as the first command line argument. Thus, the fully qualified filename to that file (including the "location") will be available in %1.
Example (sort of):
#echo off
REM assuming this is your "Script.bat"
echo You double clicked on "%~1"
Note that using %~1 instead of simply %1 removes enclosing quotes, which have been automatically added by Windows when it called your application (batch file).
For example, Windows will call it like you would have entered it in CMD.EXE like this:
Script.bat "C:\Wherever it is\file.ext"
To extract individual parts you have a couple of options:
echo Filename only: %~n1
echo Filename and extension: %~nx1
echo Drive and directory only: %~dp1
For a complete list of possibilities enter FOR /? on the prompt and page all the way to the end (mentally replace "%I" by "%1" for your example).

Can I have variables in .po files?

I'd like to use variables in some way in gettext .po files, for example:
msgid "ui_settings_connect_text"
msgstr "Connect to another running instance of " APP_NAME
Has anyone tried to do something like this before?
In your .po file:
msgid "Connect to another running instance of %s"
msgstr "Connect to another running instance of %s"
In your app:
printf(_("Connect to another running instance of %s"), app_name);
I made a preprocessor to do this as well, as I don't believe the application code should be coupled to whether some text will contain the application name (to use Tom's example), or any other translated snippets.
I've put source up on github and provided a Windows .exe, but if you're not using Windows it will need Mono.
https://github.com/Treer/POpp
To solve the problem proposed by Tom, the .po file would look like this:
msgid "APP_NAME"
msgstr "Tom's app"
msgid "ui_settings_connect_text"
msgstr "Connect to another running instance of {id:APP_NAME}"
Which should be useable in any GUI PO editor.
The preprocessor is just run like this:
popp source.po destination.po

Error while downloading file with "." in name in RoR3

When I download a file that contains "." in its name my code throws an exception:
No route matches "/test/download/File%201.0%20BETA.docx"
The file name is: "File 1.0 BETA.docx"
Here is my code for downloading file in my controller file:
def download
path = params[:path]
path = "#{Rails.root}/public/data/" + path
send_file(path+"."+params[:format])
end
How can I solve it?
This is most likely caused by your routes not supporting multiple "." in the path. For example, if your routes look like this:
'/test/download/:path.:extension'
Then that will break if the filename contains more then one "."
Instead you could do a routing like this:
'/test/download/*path.:extension'
That will make sure that multiple "." is functioning