[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/stable/l10n-kde4/ga/scripts/kdelibs/kdelibs4
From:       Chusslove Illich <caslav.ilic () gmx ! net>
Date:       2008-01-09 12:10:55
Message-ID: 1199880655.084830.12649.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 758854 by ilic:

Calls to handle custom answers in message dialogs.

 M  +61 -1     kdelibs4.js  


--- branches/stable/l10n-kde4/ga/scripts/kdelibs/kdelibs4/kdelibs4.js #758853:758854
@@ -42,7 +42,7 @@
 //
 // The call always signals fallback.
 //
-function setprops ()
+function setprops (/*...*/)
 {
     if (arguments.length % 2 != 0)
         throw Error("Property setter given odd number of arguments.");
@@ -69,3 +69,63 @@
     throw Ts.fallback();
 }
 Ts.setcall("properties", setprops);
+
+// ------------------------------
+// Standard message dialogs come with cookie-cutter "Yes", "No", etc. buttons,
+// but we can't translate them properly like that.
+// Instead, attach the proper answers to the message caption/text in the PO,
+// and then retrieve them in filtering messages for message dialog buttons
+// in kdelibs4.po (those with context "@action:button filter-...").
+
+// Dictionary of answers.
+var _answers_ = {};
+
+// Set answers as key-value pairs, as many as needed.
+// The call always signals fallback.
+function setAnswers (/*...*/)
+{
+    if (arguments.length % 2 != 0)
+        throw Error("Answers setter given odd number of arguments.");
+
+    for (var i = 0; i < arguments.length; i += 2) {
+        var akey = arguments[i];
+        var answer = arguments[i + 1];
+        _answers_[akey] = answer;
+    }
+
+    throw Ts.fallback();
+}
+Ts.setcall("set-answers", setAnswers);
+// msgid "Blah, blah...?"
+// msgstr ""
+// "Eh laddy, blah, blah...?"
+// "|/|"
+// "$[set-answers no '&Nay!' yes '&Arr!']"
+
+// Get an answer by key.
+// Signals fallback if the answer with the given key is not set.
+// Deletes the answer from the dictionary, so that it doesn't happen
+// that it gets retrieved in a later, unrelated question.
+function getAnswer (akey)
+{
+    answer = _answers_[akey];
+    if (!answer) throw Ts.fallback();
+    delete _answers_[akey];
+    return answer;
+}
+Ts.setcall("get-answer", getAnswer);
+// msgctxt "@action:button filter-yes"
+// msgid "%1"
+// msgstr "%1|/|$[get-answer yes]"
+
+// Reset all answers, so that they don't get used for the wrong question.
+// Always signals fallback.
+function resetAnswers ()
+{
+    _answers_ = {};
+}
+Ts.setcall("reset-answers", resetAnswers);
+// msgctxt "@action:button post-filter"
+// msgid "."
+// msgstr ".|/|$[reset-answers]"
+
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic