~ubuntu-branches/ubuntu/oneiric/kde-l10n-nn/oneiric-proposed

« back to all changes in this revision

Viewing changes to scripts/kdelibs/kdelibs4/kdelibs4.js

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2008-10-03 16:52:48 UTC
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: james.westby@ubuntu.com-20081003165248-2a2b8m29kec7lj9g
Tags: upstream-4.1.2
ImportĀ upstreamĀ versionĀ 4.1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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("eigenskap", 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.