Behavior QT translate tr() method with arguments (%1) - qt

Will dynamic translation work for such a code:
const QString myText = tr("%1 Hello World").arg(someVar);
I have few doubts:
1: Will the translation entry be generated for above code (when running lupdate). If yes, will the "%1" argument part be ignored?
2: Is the above code correct ? Should the dynamic part be translated separately before using it in the argument with tr. Provided we know all possible value of someVar

When your run lupdate, you will see this in your .ts file:
<source>%1 Hello World</source>
The translator will need to know they can just ignore the '%1' part.
If someVar is a number, there is no need to do anything else. If it's a string, it will need to be translated separately.

Related

Fortran90: Scripting of Standard In not working as expected

Working with Fortran90 in Unix...
I have a programme which needs to read in the input parameters from a file "input-deck.par". This filename is currently hard-coded but I want to run a number of runs using different input-deck files (input-deck01.par, input-deck02.par, input-deck03.par etc.) so I've set-up the code to do a simple "read(*,*) inpfile" to allow the user to input the name of this file directly on run-time with a view to scripting this later.
This works fine interactively. If I execute the programme it asks for the file name, you type it in and the filename is accepted, the file is opened and the programme picks up the parameters from that file.
The issue lies in scripting this. I've tried scripting using the "<" pipe command so:
myprog.e < input-deck01.par
But I get an error saying:
Fortran runtime error: Cannot open file '----------------': No such file or directory
If I print the filename right after the input line, it prints that the filename is '----------------' (I initialise the variable as having 16 characters hence the 16 hyphens I think)
It seems like the "<" pipe is not passing the keyboard input in correctly. I've tried with spaces and quotes around the filename (various combinations) but the errors are the same.
Can anyone help?
(Please be gentle- this is my first post on SO and Fortran is not my primary language....)
Fortran has the ability to read the command line arguments. A simple example is
program foo
implicit none
character(len=80) name
logical available
integer fd
if (command_argument_count() == 1) then
call get_command_argument(1, name)
else
call usage
end if
inquire(file=name, exist=available)
if (.not. available) then
call usage
end if
open(newunit=fd, file=name, status='old')
! Read file
contains
subroutine usage
write(*,'(A)') 'Usage: foo filename'
write(*,'(A)') ' filename --> file containing input info'
stop
end subroutine usage
end program foo
Instead of piping the file into the executable you simply do
% foo input.txt

How to correctly combine "dot notation" and "braces notation" in cocoascript (sketch)?

In sketch documentation it's stated that dot and braces notations can be mixed with each other. It's even an example available:
[[context.document currentPage] deselectAllLayers];
Unfortunately, this code doesn't work in sketch and produce error if executed by "run custom script" command:
SyntaxError: Unexpected identifier 'currentPage'. Expected either a closing ']' or a ',' following an array element..
Plugin “untitled script”, line 2.
» [context.document currentPage]; «Error in command untitled script Script at path (null) does not contain a handler function named: onRun
Script executed in 0.023666s
This can be avoided by adding additional ( and ):
[[(context.document) currentPage] deselectAllLayers];
Why this happens? Is it any documentation available how exactly braces and dot notation can be mixed? Is it some error or expected behaviour?
It seems to me it's an error, but in Sketch documentation. Besides this case you showed, I couldn't find any other example where dot and braces notations are used together in the same statement, without parentheses.
The documentation page about Selections, for instance, tells that you'd use the following code to unselect everything:
var doc = context.document
[[doc currentPage] deselectAllLayers]
Follow this link and look under Clearing the selection header: http://bohemiancoding.com/sketch/support/developer/02-common-tasks/01.html
Even their example plugins don't mix both notations, as you can see here: https://github.com/BohemianCoding/ExampleSketchPlugins/blob/master/Hello%20World/Hello%20World.sketchplugin/Contents/Sketch/script.cocoascript.
In that example, context.document is also assigned to a new variable before being used within braces.

# symbol in Drupal modules

I'm trying to learn Drupal modules. Can someone tell me what the '#' symbol is? I dont remember coming across it in PHP. (Its tricky to search for it cos as far as I can tell, you cant google for symbols). Can I convert it into a normal PHP variable, modify it and finally put it back into an # thing within the PHP of the .module file?
UPDATE: e.g.:
$error['msg'] = t("We're sorry. We have now only #qty of the ....
in file...
http://drupal.org/project/uc_out_of_stock
While that is the case in general PHP, it is used differently in Drupal within the t() function.
You can properly use placeholders in your text (which should be wrapped in t() for translation purposes on i18n capabilities) by putting a # , ! or % in front.
! = insert as is
# = run text through check_plain
% = html escape text
More info on the API page
In PHP the # symbol suppresses error messages.
There's plenty about it in the manual. When in doubt that's the place to go.
http://us3.php.net/manual/en/language.operators.errorcontrol.php

Programmatically adding new line in mx:TextArea

I have a flex 4.5 application. I want to add new line in an mx:TextArea when certain event occurs. I have been searching for the proper way to add a OS independent line ending. I found out that the File class has lineEnding property. However the documentation states that this class is not exposed when running inside a browser (which is my case).
I have searched, but I couldn't find any other class, which can provide this information. Actually I am not sure if the TextArea line ending is OS dependent or not.
So actually I have two questions: Are TextArea line endings OS dependent or not? And if so, how can I get the proper line ending in flex?
You can use String.fromCharCode(13). This will return a line ending.
This is the equivalent of PHP's chr() method.
Example:
var address_str:String = "dog" + String.fromCharCode(64) + "house.net";
trace(address_str); // output: dog#house.net
From my experience, "\r" works in both Windows and Mac.
Quite simply, you just need to add the newline character to the text of the textArea.
myTextArea.text+="\n"; //This should work, if not try the other two
myTextArea.text+="\r";
myTextArea.text+="\r\n";

ControlCommand in AutoIt v3

I am trying to use ControlCommands with a .NET application (hence, these should all be standard Microsoft controls), but most of the ones that are of interest don't seem to do anything.
I am currently looking at a combobox (the drop down box). I used the "showdropdown" command to have it drop down, and it worked successfully.
I then tried to use "SelectString", but it didn't go to the string that I specified. How does the "SelectString" ControlCommand option work?
I have also tried "SetCurrentSelection".
This is the statement I used:
ControlCommand($windowName, "", "[Name:myComboBox]", "SelectString", "a")
I have also tried searching for it first with:
ControlCommand($windowName, "", "[Name:myComboBox]", "FindString", "a")
but it didn't find it either. Strange, the single character "a" is there.
If it helps, this is the control class: WindowsForms10.COMBOBOX
_GUICtrlComboBox_xxx functions also work on external controls. For example, _GUICtrlComboBox_FindString, _GUICtrlComboBox_SelectString, _GUICtrlComboBox_SetCurSel. Try those instead.
Call ControlGetHandle first, then use this handle to call the functions above.
Remember to include the GuiComboBox library, otherwise you will get an error message "Error: Unknown function name":
#include <GuiComboBox.au3>
You can send key presses to this control, like this:
ControlSend("Window title", "", "[NAME:comboBoxName]", "ComboBox value")
It works because ComboBox interprets input as a search string and selects the first item starting with this string.
Note: Because it searches the matching item as you type, there's no need to send a complete value, only the shortest substring.

Resources