the
'
of
(
format ,
parameter ,
parameter ,
...
)
'
(
format ,
parameter ,
parameter ,
...
)
Format yields a format string
. Parameter yields any variant
.
'
("Hello, ^1!", "World")
'
("^{^1?no items|one item|^1 items}", myCount)
The '
function returns a string produced from the given format string using the given parameters.
Sequences in the format string starting with the ^ character are replaced with parameters, conditional text, or special characters as described below.
A ^ character followed by an integer is replaced with a parameter. The parameter after the format string is parameter 1. The parameter number may be followed by a lowercase n
and a minimum string length; a lowercase m
and a maximum string length; a lowercase l
and a character for left padding; or a lowercase r
and a character for right padding. Optionally, the sequence can end with one of the following format specifiers:
s |
a string (the default) |
l |
a list, delimited by commas |
L |
a list, delimited by a comma followed by a space |
i |
an integer, using the current numberFormat |
I |
an integer, using the local number format |
n |
a number, using the current numberFormat |
N |
a number, using the local number format |
o |
an octal number |
h |
a hexadecimal number, in lowercase |
H |
a hexadecimal number, in uppercase |
c |
a complex, using the current numberFormat |
C |
a complex, using the local number format |
d |
a date |
t |
a time |
b |
a binary, without spacing between bytes |
B |
a binary, with spacing between bytes |
Finally, if the sequence will be followed by a digit or letter, a tilde (~) can be used to indicate the end of the sequence.
A ^ character followed by an opening brace is replaced with conditional text. The opening brace must be followed by an expression using only parameter numbers preceded by ^, string and number literals, and operators named using only symbols. A question mark (?) separates the expression from a list of alternatives. Each alternative is a format string of its own. The first alternative corresponds to a value of true or zero, the second alternative to a value of false or one, the third alternative to a value of two, and so on; the last alternative is chosen if the value is greater than the number of alternatives. Alternatives are delimited using vertical bars (|). Finally, a closing brace indicates the end of the list of alternatives.
Finally, the special sequences ^}
, ^|
, and ^^
are replaced with a literal closing brace, vertical bar, or caret, respectively.
The '
form of this function is used with strings that should be localized. By running OpenXION with the -M
parameter, a message file will be generated for your language and locale. By editing the message file, you or other people can translate your script's messages into other languages without having to modify the script itself.