Debian Codegraph @

po/ca@valencia/scripts/ki18n6/ki18n6.js

raw
1 // Set properties of the phrase given by the finalized msgstr in the PO file.
2 // The arguments to the call are consecutive pairs of keys and values,
3 // as many as needed (i.e. total number of arguments must be even).
4 //
5 // The property keys are registered as PO calls taking single argument,
6 // which can be used to retrive the property values for this msgstr
7 // when it is later used as placeholder replacement in another message.
8 //
9 // Always signals fallback.
10 //
11 function setMsgstrProps (/*KEY1, VALUE1, ...*/)
12 {
13 if (arguments.length % 2 != 0)
14 throw Error("Property setter given odd number of arguments.");
15
16 // Collect finalized msgstr.
17 phrase = Ts.msgstrf()
18
19 // Go through all key-value pairs.
20 for (var i = 0; i < arguments.length; i += 2) {
21 var pkey = arguments[i];
22 var pval = arguments[i + 1];
23
24 // Set the value of the property for this phrase.
25 Ts.setProp(phrase, pkey, pval);
26
27 // Set the PO call for getting this property, if not already set.
28 if (!Ts.hascall(pkey)) {
29 Ts.setcall(pkey,
30 function (phr) { return Ts.getProp(phr, this.pkey) },
31 {"pkey" : pkey});
32 }
33 }
34
35 throw Ts.fallback();
36 }
37 Ts.setcall("propietats", setMsgstrProps);
38 // NOTE: You can replace "properties" in the line above with any UTF-8 string,
39 // e.g. one in your language so that it blends nicely inside POs.