Skip to content

Commit

Permalink
Bug 1161138 - Use normal L10N for Pocket strings. r=jaws
Browse files Browse the repository at this point in the history
  • Loading branch information
dolske committed Jun 9, 2015
1 parent edd7eb6 commit daa0f38
Show file tree
Hide file tree
Showing 23 changed files with 78 additions and 497 deletions.
2 changes: 0 additions & 2 deletions browser/base/content/browser-doctype.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
%brandDTD;
<!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd" >
%browserDTD;
<!ENTITY % browserPocketDTD SYSTEM "chrome://browser/content/browser-pocket.dtd" >
%browserPocketDTD;
<!ENTITY % baseMenuDTD SYSTEM "chrome://browser/locale/baseMenuOverlay.dtd" >
%baseMenuDTD;
<!ENTITY % charsetDTD SYSTEM "chrome://global/locale/charsetMenu.dtd" >
Expand Down
19 changes: 0 additions & 19 deletions browser/base/content/browser-places.js
Original file line number Diff line number Diff line change
Expand Up @@ -1563,25 +1563,6 @@ let BookmarkingUI = {

updatePocketItemVisibility: function BUI_updatePocketItemVisibility(prefix) {
let hidden = !CustomizableUI.getPlacementOfWidget("pocket-button");
if (!hidden) {
let locale = Cc["@mozilla.org/chrome/chrome-registry;1"].
getService(Ci.nsIXULChromeRegistry).
getSelectedLocale("browser");
if (locale != "en-US") {
if (locale == "ja-JP-mac")
locale = "ja";
let url = "chrome://browser/content/browser-pocket-" + locale + ".properties";
let bundle = Services.strings.createBundle(url);
let item = document.getElementById(prefix + "pocket");
try {
item.setAttribute("label", bundle.GetStringFromName("pocketMenuitem.label"));
} catch (err) {
// GetStringFromName throws when the bundle doesn't exist. In that
// case, the item will retain the browser-pocket.dtd en-US string that
// it has in the markup.
}
}
}
document.getElementById(prefix + "pocket").hidden = hidden;
document.getElementById(prefix + "pocketSeparator").hidden = hidden;
},
Expand Down
16 changes: 0 additions & 16 deletions browser/base/content/browser-pocket-de.properties

This file was deleted.

9 changes: 0 additions & 9 deletions browser/base/content/browser-pocket-en-US.properties

This file was deleted.

16 changes: 0 additions & 16 deletions browser/base/content/browser-pocket-es-ES.properties

This file was deleted.

16 changes: 0 additions & 16 deletions browser/base/content/browser-pocket-ja.properties

This file was deleted.

16 changes: 0 additions & 16 deletions browser/base/content/browser-pocket-ru.properties

This file was deleted.

12 changes: 0 additions & 12 deletions browser/base/content/browser-pocket.dtd

This file was deleted.

23 changes: 0 additions & 23 deletions browser/base/content/nsContextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,29 +198,6 @@ nsContextMenu.prototype = {
(targetURI.schemeIs("about") && ReaderMode.getOriginalUrl(targetURI.spec)));
canPocket = canPocket && window.gBrowser && this.browser.getTabBrowser() == window.gBrowser;

if (canPocket) {
let locale = Cc["@mozilla.org/chrome/chrome-registry;1"].
getService(Ci.nsIXULChromeRegistry).
getSelectedLocale("browser");
if (locale != "en-US") {
if (locale == "ja-JP-mac")
locale = "ja";
let url = "chrome://browser/content/browser-pocket-" + locale + ".properties";
let bundle = Services.strings.createBundle(url);
let saveToPocketItem = document.getElementById("context-pocket");
let saveLinkToPocketItem = document.getElementById("context-savelinktopocket");
try {
saveToPocketItem.setAttribute("label", bundle.GetStringFromName("saveToPocketCmd.label"));
saveToPocketItem.setAttribute("accesskey", bundle.GetStringFromName("saveToPocketCmd.accesskey"));
saveLinkToPocketItem.setAttribute("label", bundle.GetStringFromName("saveLinkToPocketCmd.label"));
saveLinkToPocketItem.setAttribute("accesskey", bundle.GetStringFromName("saveLinkToPocketCmd.accesskey"));
} catch (err) {
// GetStringFromName throws when the bundle doesn't exist. In that
// case, the item will retain the browser-pocket.dtd en-US string that
// it has in the markup.
}
}
}
this.showItem("context-pocket", canPocket && showSaveCurrentPageToPocket);
let showSaveLinkToPocket = canPocket && !showSaveCurrentPageToPocket &&
(this.onSaveableLink || this.onPlainTextLink);
Expand Down
2 changes: 0 additions & 2 deletions browser/base/content/web-panels.xul
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
<!DOCTYPE page [
<!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd">
%browserDTD;
<!ENTITY % browserPocketDTD SYSTEM "chrome://browser/content/browser-pocket.dtd">
%browserPocketDTD;
<!ENTITY % textcontextDTD SYSTEM "chrome://global/locale/textcontext.dtd">
%textcontextDTD;
]>
Expand Down
6 changes: 0 additions & 6 deletions browser/base/jar.mn
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@ browser.jar:
* content/browser/browser.css (content/browser.css)
* content/browser/browser.js (content/browser.js)
* content/browser/browser.xul (content/browser.xul)
content/browser/browser-pocket-en-US.properties (content/browser-pocket-en-US.properties)
content/browser/browser-pocket.dtd (content/browser-pocket.dtd)
content/browser/browser-pocket-de.properties (content/browser-pocket-de.properties)
content/browser/browser-pocket-es-ES.properties (content/browser-pocket-es-ES.properties)
content/browser/browser-pocket-ja.properties (content/browser-pocket-ja.properties)
content/browser/browser-pocket-ru.properties (content/browser-pocket-ru.properties)
* content/browser/browser-tabPreviews.xml (content/browser-tabPreviews.xml)
* content/browser/chatWindow.xul (content/chatWindow.xul)
content/browser/tab-content.js (content/tab-content.js)
Expand Down
23 changes: 1 addition & 22 deletions browser/components/customizableui/CustomizableWidgets.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -1065,11 +1065,10 @@ if (Services.prefs.getBoolPref("privacy.panicButton.enabled")) {

if (Services.prefs.getBoolPref("browser.pocket.enabled")) {
let isEnabledForLocale = true;
let browserLocale;
if (Services.prefs.getBoolPref("browser.pocket.useLocaleList")) {
let chromeRegistry = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIXULChromeRegistry);
browserLocale = chromeRegistry.getSelectedLocale("browser");
let browserLocale = chromeRegistry.getSelectedLocale("browser");
let enabledLocales = [];
try {
enabledLocales = Services.prefs.getCharPref("browser.pocket.enabledLocales").split(' ');
Expand All @@ -1080,32 +1079,12 @@ if (Services.prefs.getBoolPref("browser.pocket.enabled")) {
}

if (isEnabledForLocale) {
if (browserLocale == "ja-JP-mac")
browserLocale = "ja";
let url = "chrome://browser/content/browser-pocket-" + browserLocale + ".properties";
let strings = Services.strings.createBundle(url);
let label;
let tooltiptext;
try {
label = strings.GetStringFromName("pocket-button.label");
tooltiptext = strings.GetStringFromName("pocket-button.tooltiptext");
} catch (err) {
// GetStringFromName throws when the bundle doesn't exist. In that case,
// fall back to the en-US browser-pocket.properties.
url = "chrome://browser/content/browser-pocket-en-US.properties";
strings = Services.strings.createBundle(url);
label = strings.GetStringFromName("pocket-button.label");
tooltiptext = strings.GetStringFromName("pocket-button.tooltiptext");
}

let pocketButton = {
id: "pocket-button",
defaultArea: CustomizableUI.AREA_NAVBAR,
introducedInVersion: "pref",
type: "view",
viewId: "PanelUI-pocketView",
label: label,
tooltiptext: tooltiptext,
// Use forwarding functions here to avoid loading Pocket.jsm on startup:
onViewShowing: function() {
return Pocket.onPanelViewShowing.apply(this, arguments);
Expand Down
1 change: 0 additions & 1 deletion browser/components/pocket/jar.mn
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ browser.jar:
content/browser/pocket/panels/img/[email protected] (panels/img/[email protected])
content/browser/pocket/panels/img/[email protected] (panels/img/[email protected])
content/browser/pocket/panels/img/[email protected] (panels/img/[email protected])
content/browser/pocket/panels/js/dictionary.js (panels/js/dictionary.js)
content/browser/pocket/panels/js/messages.js (panels/js/messages.js)
content/browser/pocket/panels/js/saved.js (panels/js/saved.js)
content/browser/pocket/panels/js/signup.js (panels/js/signup.js)
Expand Down
13 changes: 13 additions & 0 deletions browser/components/pocket/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,19 @@ var pktUI = (function() {
}
})
});

var _initL10NMessageId = "initL10N";
pktUIMessaging.addMessageListener(_initL10NMessageId, function(panelId, data) {
var strings = {};
var bundle = Services.strings.createBundle("chrome://browser/locale/browser-pocket.properties");
var e = bundle.getSimpleEnumeration();
while(e.hasMoreElements()) {
var str = e.getNext().QueryInterface(Components.interfaces.nsIPropertyElement);
strings[str.key] = str.value;
}
pktUIMessaging.sendResponseMessageToPanel(panelId, _initL10NMessageId, { strings: strings });
});

}

// -- Browser Navigation -- //
Expand Down
Loading

0 comments on commit daa0f38

Please sign in to comment.