[gnome-shell] environment: put gettext stuff into global environment



commit 898b2b903dd4d0274b4599e9675fab9c6628975a
Author: Dan Winship <danw gnome org>
Date:   Sat Apr 30 09:16:13 2011 -0400

    environment: put gettext stuff into global environment
    
    Rather than defining _() as a local function in every module, put it
    into the global environment (along with C_() and ngettext()).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=649203

 js/misc/util.js                    |    3 ---
 js/ui/appDisplay.js                |    2 --
 js/ui/appFavorites.js              |    2 --
 js/ui/calendar.js                  |    3 ---
 js/ui/dash.js                      |    2 --
 js/ui/dateMenu.js                  |    2 --
 js/ui/docDisplay.js                |    3 ---
 js/ui/endSessionDialog.js          |    3 ---
 js/ui/environment.js               |    5 +++++
 js/ui/lookingGlass.js              |    2 --
 js/ui/main.js                      |    2 --
 js/ui/messageTray.js               |    3 ---
 js/ui/modalDialog.js               |    2 --
 js/ui/notificationDaemon.js        |    2 --
 js/ui/overview.js                  |    2 --
 js/ui/panel.js                     |    2 --
 js/ui/placeDisplay.js              |    2 --
 js/ui/polkitAuthenticationAgent.js |    2 --
 js/ui/popupMenu.js                 |    3 ---
 js/ui/runDialog.js                 |    2 --
 js/ui/search.js                    |    3 ---
 js/ui/searchDisplay.js             |    2 --
 js/ui/status/accessibility.js      |    3 ---
 js/ui/status/bluetooth.js          |    3 ---
 js/ui/status/keyboard.js           |    3 ---
 js/ui/status/network.js            |    3 ---
 js/ui/status/power.js              |    9 +++------
 js/ui/status/volume.js             |    3 ---
 js/ui/statusMenu.js                |    2 --
 js/ui/telepathyClient.js           |    3 ---
 js/ui/viewSelector.js              |    2 --
 js/ui/windowAttentionHandler.js    |    2 --
 js/ui/workspacesView.js            |    2 --
 33 files changed, 8 insertions(+), 81 deletions(-)
---
diff --git a/js/misc/util.js b/js/misc/util.js
index 2d9cef2..a876649 100644
--- a/js/misc/util.js
+++ b/js/misc/util.js
@@ -7,9 +7,6 @@ const Shell = imports.gi.Shell;
 
 const Main = imports.ui.main;
 
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
-
 /* http://daringfireball.net/2010/07/improved_regex_for_matching_urls */
 const _urlRegexp = new RegExp('\\b(([a-z][\\w-]+:(/{1,3}|[a-z0-9%])|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,4}/)([^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:\'\\".,<>?«»â??â??â??â??]))', 'gi');
 
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 0504321..b360e67 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -9,8 +9,6 @@ const Signals = imports.signals;
 const Meta = imports.gi.Meta;
 const St = imports.gi.St;
 const Mainloop = imports.mainloop;
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
 
 const AppFavorites = imports.ui.appFavorites;
 const DND = imports.ui.dnd;
diff --git a/js/ui/appFavorites.js b/js/ui/appFavorites.js
index a3e83c4..a5dce27 100644
--- a/js/ui/appFavorites.js
+++ b/js/ui/appFavorites.js
@@ -3,8 +3,6 @@
 const Shell = imports.gi.Shell;
 const Lang = imports.lang;
 const Signals = imports.signals;
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
 
 const Main = imports.ui.main;
 
diff --git a/js/ui/calendar.js b/js/ui/calendar.js
index abedb26..0f87305 100644
--- a/js/ui/calendar.js
+++ b/js/ui/calendar.js
@@ -8,9 +8,6 @@ const St = imports.gi.St;
 const Signals = imports.signals;
 const Pango = imports.gi.Pango;
 const Gettext_gtk30 = imports.gettext.domain('gtk30');
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
-const C_ = Gettext.pgettext;
 const Mainloop = imports.mainloop;
 const Shell = imports.gi.Shell;
 
diff --git a/js/ui/dash.js b/js/ui/dash.js
index 28e4bdb..af9f1b4 100644
--- a/js/ui/dash.js
+++ b/js/ui/dash.js
@@ -6,8 +6,6 @@ const Lang = imports.lang;
 const Meta = imports.gi.Meta;
 const Shell = imports.gi.Shell;
 const St = imports.gi.St;
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
 
 const AppDisplay = imports.ui.appDisplay;
 const AppFavorites = imports.ui.appFavorites;
diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js
index c0c8cea..b3ae9f4 100644
--- a/js/ui/dateMenu.js
+++ b/js/ui/dateMenu.js
@@ -8,8 +8,6 @@ const Cairo = imports.cairo;
 const Clutter = imports.gi.Clutter;
 const Shell = imports.gi.Shell;
 const St = imports.gi.St;
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
 
 const Util = imports.misc.util;
 const Main = imports.ui.main;
diff --git a/js/ui/docDisplay.js b/js/ui/docDisplay.js
index 2687172..6a289b0 100644
--- a/js/ui/docDisplay.js
+++ b/js/ui/docDisplay.js
@@ -1,8 +1,5 @@
 /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
 
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
-
 const DocInfo = imports.misc.docInfo;
 const Params = imports.misc.params;
 const Search = imports.ui.search;
diff --git a/js/ui/endSessionDialog.js b/js/ui/endSessionDialog.js
index 47963bc..b4e458d 100644
--- a/js/ui/endSessionDialog.js
+++ b/js/ui/endSessionDialog.js
@@ -22,9 +22,6 @@ const DBus = imports.dbus;
 const Lang = imports.lang;
 const Signals = imports.signals;
 
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
-
 const Clutter = imports.gi.Clutter;
 const Gdm = imports.gi.Gdm;
 const GLib = imports.gi.GLib;
diff --git a/js/ui/environment.js b/js/ui/environment.js
index 90e7fa6..2dd9115 100644
--- a/js/ui/environment.js
+++ b/js/ui/environment.js
@@ -7,6 +7,7 @@ imports.gi.versions.GdkPixbuf = '2.0';
 imports.gi.versions.Gtk = '3.0';
 
 const Clutter = imports.gi.Clutter;;
+const Gettext = imports.gettext.domain('gnome-shell');
 const GLib = imports.gi.GLib;
 const Gtk = imports.gi.Gtk;
 const Shell = imports.gi.Shell;
@@ -72,6 +73,10 @@ function init() {
     // browser convention of having that namespace be called 'window'.)
     window.global = Shell.Global.get();
 
+    window._ = Gettext.gettext;
+    window.C_ = Gettext.pgettext;
+    window.ngettext = Gettext.ngettext;
+
     // Set the default direction for St widgets (this needs to be done before any use of St)
     if (Gtk.Widget.get_default_direction() == Gtk.TextDirection.RTL) {
         St.Widget.set_default_direction(St.TextDirection.RTL);
diff --git a/js/ui/lookingGlass.js b/js/ui/lookingGlass.js
index 6e6e22a..db3291f 100644
--- a/js/ui/lookingGlass.js
+++ b/js/ui/lookingGlass.js
@@ -12,8 +12,6 @@ const Shell = imports.gi.Shell;
 const Signals = imports.signals;
 const Lang = imports.lang;
 const Mainloop = imports.mainloop;
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
 
 const History = imports.misc.history;
 const ExtensionSystem = imports.ui.extensionSystem;
diff --git a/js/ui/main.js b/js/ui/main.js
index 2845670..1d27b4c 100644
--- a/js/ui/main.js
+++ b/js/ui/main.js
@@ -11,8 +11,6 @@ const Mainloop = imports.mainloop;
 const Meta = imports.gi.Meta;
 const Shell = imports.gi.Shell;
 const St = imports.gi.St;
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
 
 const Chrome = imports.ui.chrome;
 const CtrlAltTab = imports.ui.ctrlAltTab;
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index fe3420c..8c7dbf8 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -20,9 +20,6 @@ const Params = imports.misc.params;
 const Tweener = imports.ui.tweener;
 const Util = imports.misc.util;
 
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
-
 const ANIMATION_TIME = 0.2;
 const NOTIFICATION_TIMEOUT = 4;
 const SUMMARY_TIMEOUT = 1;
diff --git a/js/ui/modalDialog.js b/js/ui/modalDialog.js
index dfebc47..887475f 100644
--- a/js/ui/modalDialog.js
+++ b/js/ui/modalDialog.js
@@ -10,8 +10,6 @@ const Pango = imports.gi.Pango;
 const St = imports.gi.St;
 const Shell = imports.gi.Shell;
 const Signals = imports.signals;
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
 
 const Params = imports.misc.params;
 
diff --git a/js/ui/notificationDaemon.js b/js/ui/notificationDaemon.js
index d82dd35..00a7d2c 100644
--- a/js/ui/notificationDaemon.js
+++ b/js/ui/notificationDaemon.js
@@ -7,8 +7,6 @@ const Lang = imports.lang;
 const Shell = imports.gi.Shell;
 const Mainloop = imports.mainloop;
 const St = imports.gi.St;
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
 
 const Config = imports.misc.config;
 const Main = imports.ui.main;
diff --git a/js/ui/overview.js b/js/ui/overview.js
index 8fdd661..9d4cad8 100644
--- a/js/ui/overview.js
+++ b/js/ui/overview.js
@@ -8,8 +8,6 @@ const Signals = imports.signals;
 const Lang = imports.lang;
 const St = imports.gi.St;
 const Shell = imports.gi.Shell;
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
 const Gdk = imports.gi.Gdk;
 
 const AppDisplay = imports.ui.appDisplay;
diff --git a/js/ui/panel.js b/js/ui/panel.js
index dc97813..cfc5e4d 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -9,8 +9,6 @@ const Pango = imports.gi.Pango;
 const Shell = imports.gi.Shell;
 const St = imports.gi.St;
 const Signals = imports.signals;
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
 
 const Config = imports.misc.config;
 const CtrlAltTab = imports.ui.ctrlAltTab;
diff --git a/js/ui/placeDisplay.js b/js/ui/placeDisplay.js
index c50c281..59ca4a6 100644
--- a/js/ui/placeDisplay.js
+++ b/js/ui/placeDisplay.js
@@ -7,8 +7,6 @@ const Lang = imports.lang;
 const Mainloop = imports.mainloop;
 const Signals = imports.signals;
 const St = imports.gi.St;
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
 
 const DND = imports.ui.dnd;
 const Main = imports.ui.main;
diff --git a/js/ui/polkitAuthenticationAgent.js b/js/ui/polkitAuthenticationAgent.js
index 4a0fdf6..a99cf3f 100644
--- a/js/ui/polkitAuthenticationAgent.js
+++ b/js/ui/polkitAuthenticationAgent.js
@@ -22,8 +22,6 @@
 
 const Lang = imports.lang;
 const Signals = imports.signals;
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
 const Shell = imports.gi.Shell;
 const Clutter = imports.gi.Clutter;
 const St = imports.gi.St;
diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js
index 4e0ffea..84089d6 100644
--- a/js/ui/popupMenu.js
+++ b/js/ui/popupMenu.js
@@ -13,9 +13,6 @@ const Main = imports.ui.main;
 const Params = imports.misc.params;
 const Tweener = imports.ui.tweener;
 
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
-
 const SLIDER_SCROLL_STEP = 0.05; /* Slider scrolling step in % */
 
 function PopupBaseMenuItem(params) {
diff --git a/js/ui/runDialog.js b/js/ui/runDialog.js
index fdf6c4e..3114bd8 100644
--- a/js/ui/runDialog.js
+++ b/js/ui/runDialog.js
@@ -8,8 +8,6 @@ const Meta = imports.gi.Meta;
 const St = imports.gi.St;
 const Shell = imports.gi.Shell;
 const Signals = imports.signals;
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
 
 const FileUtils = imports.misc.fileUtils;
 const Main = imports.ui.main;
diff --git a/js/ui/search.js b/js/ui/search.js
index eb84b09..a1a6f5f 100644
--- a/js/ui/search.js
+++ b/js/ui/search.js
@@ -7,9 +7,6 @@ const Signals = imports.signals;
 const Shell = imports.gi.Shell;
 const Util = imports.misc.util;
 
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
-
 const FileUtils = imports.misc.fileUtils;
 const Main = imports.ui.main;
 
diff --git a/js/ui/searchDisplay.js b/js/ui/searchDisplay.js
index 6de542d..a8eba1b 100644
--- a/js/ui/searchDisplay.js
+++ b/js/ui/searchDisplay.js
@@ -2,8 +2,6 @@
 
 const Clutter = imports.gi.Clutter;
 const Lang = imports.lang;
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
 const Gtk = imports.gi.Gtk;
 const Meta = imports.gi.Meta;
 const St = imports.gi.St;
diff --git a/js/ui/status/accessibility.js b/js/ui/status/accessibility.js
index b9cf723..5f61aec 100644
--- a/js/ui/status/accessibility.js
+++ b/js/ui/status/accessibility.js
@@ -14,9 +14,6 @@ const PanelMenu = imports.ui.panelMenu;
 const PopupMenu = imports.ui.popupMenu;
 const Util = imports.misc.util;
 
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
-
 const A11Y_SCHEMA = 'org.gnome.desktop.a11y.keyboard';
 const KEY_STICKY_KEYS_ENABLED = 'stickykeys-enable';
 const KEY_BOUNCE_KEYS_ENABLED = 'bouncekeys-enable';
diff --git a/js/ui/status/bluetooth.js b/js/ui/status/bluetooth.js
index fdaaeec..f2bcc49 100644
--- a/js/ui/status/bluetooth.js
+++ b/js/ui/status/bluetooth.js
@@ -16,9 +16,6 @@ const MessageTray = imports.ui.messageTray;
 const PanelMenu = imports.ui.panelMenu;
 const PopupMenu = imports.ui.popupMenu;
 
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
-
 const ConnectionState = {
     DISCONNECTED: 0,
     CONNECTED: 1,
diff --git a/js/ui/status/keyboard.js b/js/ui/status/keyboard.js
index 06a0b49..77e52a8 100644
--- a/js/ui/status/keyboard.js
+++ b/js/ui/status/keyboard.js
@@ -13,9 +13,6 @@ const PopupMenu = imports.ui.popupMenu;
 const PanelMenu = imports.ui.panelMenu;
 const Util = imports.misc.util;
 
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
-
 function LayoutMenuItem() {
     this._init.apply(this, arguments);
 }
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index 756b27f..44468c2 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -18,9 +18,6 @@ const MessageTray = imports.ui.messageTray;
 const ModemManager = imports.misc.modemManager;
 const Util = imports.misc.util;
 
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
-
 const NMConnectionCategory = {
     INVALID: 'invalid',
     WIRED: 'wired',
diff --git a/js/ui/status/power.js b/js/ui/status/power.js
index ca41f3a..1b8df7c 100644
--- a/js/ui/status/power.js
+++ b/js/ui/status/power.js
@@ -11,9 +11,6 @@ const PanelMenu = imports.ui.panelMenu;
 const PopupMenu = imports.ui.popupMenu;
 const Util = imports.misc.util;
 
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
-
 const BUS_NAME = 'org.gnome.PowerManager';
 const OBJECT_PATH = '/org/gnome/PowerManager';
 
@@ -115,15 +112,15 @@ Indicator.prototype = {
                     let timestring;
                     if (time > 60) {
                         if (minutes == 0) {
-                            timestring = Gettext.ngettext("%d hour remaining", "%d hours remaining", hours).format(hours);
+                            timestring = ngettext("%d hour remaining", "%d hours remaining", hours).format(hours);
                         } else {
                             /* TRANSLATORS: this is a time string, as in "%d hours %d minutes remaining" */
                             let template = _("%d %s %d %s remaining");
 
-                            timestring = template.format (hours, Gettext.ngettext("hour", "hours", hours), minutes, Gettext.ngettext("minute", "minutes", minutes));
+                            timestring = template.format (hours, ngettext("hour", "hours", hours), minutes, ngettext("minute", "minutes", minutes));
                         }
                     } else
-                        timestring = Gettext.ngettext("%d minute remaining", "%d minutes remaining", minutes).format(minutes);
+                        timestring = ngettext("%d minute remaining", "%d minutes remaining", minutes).format(minutes);
                     this._batteryItem.label.text = timestring;
                 }
                 this._primaryPercentage.text = Math.round(percentage) + '%';
diff --git a/js/ui/status/volume.js b/js/ui/status/volume.js
index 29ffcee..1db2cc9 100644
--- a/js/ui/status/volume.js
+++ b/js/ui/status/volume.js
@@ -13,9 +13,6 @@ const PanelMenu = imports.ui.panelMenu;
 const PopupMenu = imports.ui.popupMenu;
 const Util = imports.misc.util;
 
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
-
 const VOLUME_ADJUSTMENT_STEP = 0.05; /* Volume adjustment step in % */
 
 const VOLUME_NOTIFY_ID = 1;
diff --git a/js/ui/statusMenu.js b/js/ui/statusMenu.js
index 760d0bc..63d4112 100644
--- a/js/ui/statusMenu.js
+++ b/js/ui/statusMenu.js
@@ -9,8 +9,6 @@ const Shell = imports.gi.Shell;
 const St = imports.gi.St;
 const Tp = imports.gi.TelepathyGLib;
 const UPowerGlib = imports.gi.UPowerGlib;
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
 
 const GnomeSession = imports.misc.gnomeSession;
 const Main = imports.ui.main;
diff --git a/js/ui/telepathyClient.js b/js/ui/telepathyClient.js
index cee8082..252b266 100644
--- a/js/ui/telepathyClient.js
+++ b/js/ui/telepathyClient.js
@@ -9,9 +9,6 @@ const Signals = imports.signals;
 const St = imports.gi.St;
 const Tpl = imports.gi.TelepathyLogger;
 const Tp = imports.gi.TelepathyGLib;
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
-const C_ = Gettext.pgettext;
 
 const History = imports.misc.history;
 const Main = imports.ui.main;
diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js
index 29262dc..29110fd 100644
--- a/js/ui/viewSelector.js
+++ b/js/ui/viewSelector.js
@@ -8,8 +8,6 @@ const Signals = imports.signals;
 const Lang = imports.lang;
 const Shell = imports.gi.Shell;
 const St = imports.gi.St;
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
 
 const Main = imports.ui.main;
 const Search = imports.ui.search;
diff --git a/js/ui/windowAttentionHandler.js b/js/ui/windowAttentionHandler.js
index 560e915..0d4b988 100644
--- a/js/ui/windowAttentionHandler.js
+++ b/js/ui/windowAttentionHandler.js
@@ -2,8 +2,6 @@
 
 const Lang = imports.lang;
 const Shell = imports.gi.Shell;
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
 
 const Main = imports.ui.main;
 const MessageTray = imports.ui.messageTray;
diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js
index 1dd5d02..b25d638 100644
--- a/js/ui/workspacesView.js
+++ b/js/ui/workspacesView.js
@@ -7,8 +7,6 @@ const Meta = imports.gi.Meta;
 const Shell = imports.gi.Shell;
 const St = imports.gi.St;
 const Signals = imports.signals;
-const Gettext = imports.gettext.domain('gnome-shell');
-const _ = Gettext.gettext;
 
 const DND = imports.ui.dnd;
 const Main = imports.ui.main;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]