js: Don't use templates in files with translations

xgettext gained some support for template strings, and no longer
fails when encountering '/' somewhere between backticks.

Unfortunately its support is still buggy as hell, and it is now
silently dropping translatable strings, yay. I hate making the
code worse, but until xgettext really gets its shit together,
the only viable way forward seems to be to not use template
strings in any files listed in POTFILES.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/1014
This commit is contained in:
Florian Müllner
2020-02-14 16:10:34 +01:00
parent 0c232876c3
commit 9d941f8202
43 changed files with 219 additions and 212 deletions

View File

@ -42,7 +42,7 @@ class ATIndicator extends PanelMenu.Button {
this.add_child(this._hbox);
this._a11ySettings = new Gio.Settings({ schema_id: A11Y_SCHEMA });
this._a11ySettings.connect(`changed::${KEY_ALWAYS_SHOW}`, this._queueSyncMenuVisibility.bind(this));
this._a11ySettings.connect('changed::%s'.format(KEY_ALWAYS_SHOW), this._queueSyncMenuVisibility.bind(this));
let highContrast = this._buildHCItem();
this.menu.addMenuItem(highContrast);
@ -118,7 +118,7 @@ class ATIndicator extends PanelMenu.Button {
settings.is_writable(key),
enabled => settings.set_boolean(key, enabled));
settings.connect(`changed::${key}`, () => {
settings.connect('changed::%s'.format(key), () => {
widget.setToggleState(settings.get_boolean(key));
this._queueSyncMenuVisibility();
@ -150,7 +150,7 @@ class ATIndicator extends PanelMenu.Button {
}
});
interfaceSettings.connect(`changed::${KEY_GTK_THEME}`, () => {
interfaceSettings.connect('changed::%s'.format(KEY_GTK_THEME), () => {
let value = interfaceSettings.get_string(KEY_GTK_THEME);
if (value == HIGH_CONTRAST_THEME) {
highContrast.setToggleState(true);
@ -162,7 +162,7 @@ class ATIndicator extends PanelMenu.Button {
this._queueSyncMenuVisibility();
});
interfaceSettings.connect(`changed::${KEY_ICON_THEME}`, () => {
interfaceSettings.connect('changed::%s'.format(KEY_ICON_THEME), () => {
let value = interfaceSettings.get_string(KEY_ICON_THEME);
if (value != HIGH_CONTRAST_THEME)
iconTheme = value;
@ -187,7 +187,7 @@ class ATIndicator extends PanelMenu.Button {
}
});
settings.connect(`changed::${KEY_TEXT_SCALING_FACTOR}`, () => {
settings.connect('changed::%s'.format(KEY_TEXT_SCALING_FACTOR), () => {
factor = settings.get_double(KEY_TEXT_SCALING_FACTOR);
let active = factor > 1.0;
widget.setToggleState(active);

View File

@ -45,8 +45,8 @@ class DwellClickIndicator extends PanelMenu.Button {
this.add_child(this._hbox);
this._a11ySettings = new Gio.Settings({ schema_id: MOUSE_A11Y_SCHEMA });
this._a11ySettings.connect(`changed::${KEY_DWELL_CLICK_ENABLED}`, this._syncMenuVisibility.bind(this));
this._a11ySettings.connect(`changed::${KEY_DWELL_MODE}`, this._syncMenuVisibility.bind(this));
this._a11ySettings.connect('changed::%s'.format(KEY_DWELL_CLICK_ENABLED), this._syncMenuVisibility.bind(this));
this._a11ySettings.connect('changed::%s'.format(KEY_DWELL_MODE), this._syncMenuVisibility.bind(this));
this._seat = Clutter.get_default_backend().get_default_seat();
this._seat.connect('ptr-a11y-dwell-click-type-changed', this._updateClickType.bind(this));

View File

@ -64,7 +64,7 @@ var InputSource = class {
return this.id;
if (engineDesc.variant && engineDesc.variant.length > 0)
return `${engineDesc.layout}+${engineDesc.variant}`;
return '%s+%s'.format(engineDesc.layout, engineDesc.variant);
else
return engineDesc.layout;
}
@ -138,7 +138,7 @@ class InputSourceSwitcher extends SwitcherPopup.SwitcherList {
var InputSourceSettings = class {
constructor() {
if (this.constructor === InputSourceSettings)
throw new TypeError(`Cannot instantiate abstract class ${this.constructor.name}`);
throw new TypeError('Cannot instantiate abstract class %s'.format(this.constructor.name));
}
_emitInputSourcesChanged() {
@ -211,7 +211,7 @@ var InputSourceSystemSettings = class extends InputSourceSettings {
try {
props = conn.call_finish(result).deep_unpack()[0];
} catch (e) {
log(`Could not get properties from ${this._BUS_NAME}`);
log('Could not get properties from %s'.format(this._BUS_NAME));
return;
}
let layouts = props['X11Layout'].unpack();
@ -239,7 +239,7 @@ var InputSourceSystemSettings = class extends InputSourceSettings {
for (let i = 0; i < layouts.length && !!layouts[i]; i++) {
let id = layouts[i];
if (variants[i])
id += `+${variants[i]}`;
id += '+%s'.format(variants[i]);
sourcesList.push({ type: INPUT_SOURCE_TYPE_XKB, id });
}
return sourcesList;
@ -261,9 +261,9 @@ var InputSourceSessionSettings = class extends InputSourceSettings {
this._KEY_PER_WINDOW = 'per-window';
this._settings = new Gio.Settings({ schema_id: this._DESKTOP_INPUT_SOURCES_SCHEMA });
this._settings.connect(`changed::${this._KEY_INPUT_SOURCES}`, this._emitInputSourcesChanged.bind(this));
this._settings.connect(`changed::${this._KEY_KEYBOARD_OPTIONS}`, this._emitKeyboardOptionsChanged.bind(this));
this._settings.connect(`changed::${this._KEY_PER_WINDOW}`, this._emitPerWindowChanged.bind(this));
this._settings.connect('changed::%s'.format(this._KEY_INPUT_SOURCES), this._emitInputSourcesChanged.bind(this));
this._settings.connect('changed::%s'.format(this._KEY_KEYBOARD_OPTIONS), this._emitKeyboardOptionsChanged.bind(this));
this._settings.connect('changed::%s'.format(this._KEY_PER_WINDOW), this._emitPerWindowChanged.bind(this));
}
_getSourcesList(key) {
@ -1071,7 +1071,7 @@ class InputSourceIndicator extends PanelMenu.Button {
let description = xkbLayout;
if (xkbVariant.length > 0)
description = `${description}\t${xkbVariant}`;
description = '%s\t%s'.format(description, xkbVariant);
Util.spawn(['gkbd-keyboard-display', '-l', description]);
}

View File

@ -48,9 +48,9 @@ class Indicator extends PanelMenu.SystemIndicator {
super._init();
this._settings = new Gio.Settings({ schema_id: LOCATION_SCHEMA });
this._settings.connect(`changed::${ENABLED}`,
this._settings.connect('changed::%s'.format(ENABLED),
this._onMaxAccuracyLevelChanged.bind(this));
this._settings.connect(`changed::${MAX_ACCURACY_LEVEL}`,
this._settings.connect('changed::%s'.format(MAX_ACCURACY_LEVEL),
this._onMaxAccuracyLevelChanged.bind(this));
this._indicator = this._addIndicator();
@ -244,7 +244,7 @@ var AppAuthorizer = class {
this._onAuthDone = onAuthDone;
let appSystem = Shell.AppSystem.get_default();
this._app = appSystem.lookup_app(`${this.desktopId}.desktop`);
this._app = appSystem.lookup_app('%s.desktop'.format(this.desktopId));
if (this._app == null || this._permStoreProxy == null) {
this._completeAuth();

View File

@ -174,7 +174,7 @@ Signals.addSignalMethods(NMConnectionItem.prototype);
var NMConnectionSection = class NMConnectionSection {
constructor(client) {
if (this.constructor === NMConnectionSection)
throw new TypeError(`Cannot instantiate abstract type ${this.constructor.name}`);
throw new TypeError('Cannot instantiate abstract type %s'.format(this.constructor.name));
this._client = client;
@ -306,7 +306,7 @@ var NMConnectionDevice = class NMConnectionDevice extends NMConnectionSection {
super(client);
if (this.constructor === NMConnectionDevice)
throw new TypeError(`Cannot instantiate abstract type ${this.constructor.name}`);
throw new TypeError('Cannot instantiate abstract type %s'.format(this.constructor.name));
this._device = device;
this._description = '';
@ -579,7 +579,8 @@ var NMDeviceModem = class extends NMConnectionDevice {
}
_getSignalIcon() {
return `network-cellular-signal-${signalToIcon(this._mobileDevice.signal_quality)}-symbolic`;
return 'network-cellular-signal-%s-symbolic'.format(
signalToIcon(this._mobileDevice.signal_quality));
}
};
@ -682,10 +683,12 @@ var NMWirelessDialogItem = GObject.registerClass({
}
_getSignalIcon() {
if (this._ap.mode == NM80211Mode.ADHOC)
if (this._ap.mode == NM80211Mode.ADHOC) {
return 'network-workgroup-symbolic';
else
return `network-wireless-signal-${signalToIcon(this._ap.strength)}-symbolic`;
} else {
return 'network-wireless-signal-%s-symbolic'.format(
signalToIcon(this._ap.strength));
}
}
});
@ -1369,7 +1372,7 @@ var NMDeviceWireless = class {
}
if (this._canReachInternet())
return `network-wireless-signal-${signalToIcon(ap.strength)}-symbolic`;
return 'network-wireless-signal-%s-symbolic'.format(signalToIcon(ap.strength));
else
return 'network-wireless-no-route-symbolic';
}
@ -1700,7 +1703,7 @@ class Indicator extends PanelMenu.SystemIndicator {
try {
this._deviceAdded(this._client, devices[i], true);
} catch (e) {
log(`Failed to add device ${devices[i]}: ${e}`);
log('Failed to add device %s: %s'.format(devices[i], e.toString()));
}
}
this._syncDeviceNames();
@ -1998,7 +2001,7 @@ class Indicator extends PanelMenu.SystemIndicator {
} catch (e) { }
});
} else {
log(`Invalid result from portal helper: ${result}`);
log('Invalid result from portal helper: %s'.format(result));
}
}
@ -2033,7 +2036,7 @@ class Indicator extends PanelMenu.SystemIndicator {
new PortalHelperProxy(Gio.DBus.session, 'org.gnome.Shell.PortalHelper',
'/org/gnome/Shell/PortalHelper', (proxy, error) => {
if (error) {
log(`Error launching the portal helper: ${error}`);
log('Error launching the portal helper: %s'.format(error));
return;
}

View File

@ -23,7 +23,7 @@ class Indicator extends PanelMenu.SystemIndicator {
super._init();
this._desktopSettings = new Gio.Settings({ schema_id: 'org.gnome.desktop.interface' });
this._desktopSettings.connect(`changed::${SHOW_BATTERY_PERCENTAGE}`,
this._desktopSettings.connect('changed::%s'.format(SHOW_BATTERY_PERCENTAGE),
this._sync.bind(this));
this._indicator = this._addIndicator();
@ -117,7 +117,7 @@ class Indicator extends PanelMenu.SystemIndicator {
fillLevel === 100)
icon = 'battery-level-100-charged-symbolic';
else
icon = `battery-level-${fillLevel}${chargingState}-symbolic`;
icon = 'battery-level-%d%s-symbolic'.format(fillLevel, chargingState);
// Make sure we fall back to fallback-icon-name and not GThemedIcon's
// default fallbacks

View File

@ -315,7 +315,8 @@ class Indicator extends PanelMenu.SystemIndicator {
let auth = unlocked && allowed;
policy[0] = auth;
log(`thunderbolt: [${device.Name}] auto enrollment: ${auth ? 'yes' : 'no'} (allowed: ${allowed ? 'yes' : 'no'})`);
log('thunderbolt: [%s] auto enrollment: %s (allowed: %s)'.format(
device.Name, auth ? 'yes' : 'no', allowed ? 'yes' : 'no'));
if (auth)
return; /* we are done */

View File

@ -36,7 +36,7 @@ var StreamSlider = class {
this._slider = new Slider.Slider(0);
this._soundSettings = new Gio.Settings({ schema_id: 'org.gnome.desktop.sound' });
this._soundSettings.connect(`changed::${ALLOW_AMPLIFIED_VOLUME_KEY}`, this._amplifySettingsChanged.bind(this));
this._soundSettings.connect('changed::%s'.format(ALLOW_AMPLIFIED_VOLUME_KEY), this._amplifySettingsChanged.bind(this));
this._amplifySettingsChanged();
this._sliderChangedId = this._slider.connect('notify::value',