[105055] users/cal/base-rewrite/src/macports2.0/macports.tcl

cal at macports.org cal at macports.org
Mon Apr 8 10:18:50 PDT 2013


Revision: 105055
          https://trac.macports.org/changeset/105055
Author:   cal at macports.org
Date:     2013-04-08 10:18:50 -0700 (Mon, 08 Apr 2013)
Log Message:
-----------
macports.tcl: provide macports::msg for debugging purposes

Modified Paths:
--------------
    users/cal/base-rewrite/src/macports2.0/macports.tcl

Modified: users/cal/base-rewrite/src/macports2.0/macports.tcl
===================================================================
--- users/cal/base-rewrite/src/macports2.0/macports.tcl	2013-04-08 17:18:05 UTC (rev 105054)
+++ users/cal/base-rewrite/src/macports2.0/macports.tcl	2013-04-08 17:18:50 UTC (rev 105055)
@@ -39,6 +39,8 @@
 package require macports::private 2.0
 package require macports::priority 2.0
 
+package require msgcat 1.4.2
+
 ##
 # This is the MacPorts core. It provides all API calls for all features present
 # in MacPorts and is supposed to be used from a MacPorts client. The `port`
@@ -226,4 +228,29 @@
         }
         return {}
     }
+
+    ##
+    # Print a (translatable) message to the client of this API and log the
+    # message. The logged message will not be translated. After translation, the
+    # message will be passed to the callback registered using \c
+    # register_ui_callback. No priority filtering is done in this function;
+    # callbacks are expected to filter on their own based on their current
+    # settings (which might change at runtime).
+    #
+    # @param[in] priority one of the constants in \c macports::priority, setting
+    #                     the severity of the message.
+    # @param[in] message a string containing \c printf style placeholders that
+    #                    is subject to localization. For each placeholder used,
+    #                    a value must be passed in the variadic argument list.
+    # @param[in] args list of variadic arguments used to fill in the
+    #                 placeholders in the message.
+    proc msg {priority message args} {
+        set localized [::msgcat::mc $message]
+        if {$private::ui_callback != {}} {
+            eval $private::ui_callback $priority $localized {*}$args
+        } else {
+            # TODO: Remove this after debugging!
+            puts "$priority: [format $localized {*}$args]"
+        }
+    }
 }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20130408/c0bdff20/attachment.html>


More information about the macports-changes mailing list