Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 <?xml version="1.0"?>
2 <!-- This Source Code Form is subject to the terms of the Mozilla Public
3 - License, v. 2.0. If a copy of the MPL was not distributed with this
4 - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
6 <!DOCTYPE bindings [
7 <!ENTITY % notificationDTD SYSTEM "chrome://global/locale/notification.dtd">
8 %notificationDTD;
9 <!ENTITY % translationDTD SYSTEM "chrome://browser/locale/translation.dtd" >
10 %translationDTD;
11 ]>
13 <bindings id="translationBindings"
14 xmlns="http://www.mozilla.org/xbl"
15 xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
16 xmlns:xbl="http://www.mozilla.org/xbl">
17 <binding id="translationbar" extends="chrome://global/content/bindings/notification.xml#notification" role="xul:alert">
18 <resources>
19 <stylesheet src="chrome://global/skin/notification.css"/>
20 </resources>
21 <content>
22 <xul:hbox class="notification-inner outset" flex="1" xbl:inherits="type">
23 <xul:hbox anonid="details" align="center" flex="1">
24 <xul:image anonid="messageImage" class="messageImage" xbl:inherits="src=image,type,value"/>
25 <xul:deck anonid="translationStates" selectedIndex="0">
27 <!-- offer to translate -->
28 <xul:hbox class="translate-offer-box" align="baseline">
29 <xul:label value="&translation.thisPageIsIn.label;"/>
30 <xul:menulist anonid="detectedLanguage">
31 <xul:menupopup/>
32 </xul:menulist>
33 <xul:label value="&translation.translateThisPage.label;"/>
34 <xul:button label="&translation.translate.button;" anonid="translate"
35 oncommand="document.getBindingParent(this).translate();"/>
36 <xul:button label="&translation.notNow.button;" anonid="notNow"
37 oncommand="document.getBindingParent(this).close();"/>
38 </xul:hbox>
40 <!-- translating -->
41 <xul:vbox class="translating-box" pack="center">
42 <xul:label value="&translation.translatingContent.label;"/>
43 </xul:vbox>
45 <!-- translated -->
46 <xul:hbox class="translated-box" align="baseline">
47 <xul:label value="&translation.translatedFrom.label;"/>
48 <xul:menulist anonid="fromLanguage"
49 oncommand="document.getBindingParent(this).translate()">
50 <xul:menupopup/>
51 </xul:menulist>
52 <xul:label value="&translation.translatedTo.label;"/>
53 <xul:menulist anonid="toLanguage"
54 oncommand="document.getBindingParent(this).translate()">
55 <xul:menupopup/>
56 </xul:menulist>
57 <xul:label value="&translation.translatedToSuffix.label;"/>
58 <xul:button anonid="showOriginal"
59 label="&translation.showOriginal.button;"
60 oncommand="document.getBindingParent(this).showOriginal();"/>
61 <xul:button anonid="showTranslation"
62 label="&translation.showTranslation.button;"
63 oncommand="document.getBindingParent(this).showTranslation();"/>
64 </xul:hbox>
66 <!-- error -->
67 <xul:hbox class="translation-error" align="baseline">
68 <xul:label value="&translation.errorTranslating.label;"/>
69 <xul:button label="&translation.tryAgain.button;" anonid="tryAgain"
70 oncommand="document.getBindingParent(this).translate();"/>
71 </xul:hbox>
73 </xul:deck>
74 <xul:spacer flex="1"/>
76 <xul:button type="menu" label="&translation.options.menu;">
77 <xul:menupopup/>
78 </xul:button>
80 </xul:hbox>
81 <xul:toolbarbutton ondblclick="event.stopPropagation();"
82 class="messageCloseButton close-icon tabbable"
83 xbl:inherits="hidden=hideclose"
84 tooltiptext="&closeNotification.tooltip;"
85 oncommand="document.getBindingParent(this).close();"/>
86 </xul:hbox>
87 </content>
88 <implementation>
89 <property name="state"
90 onget="return this._getAnonElt('translationStates').selectedIndex;"
91 onset="this._getAnonElt('translationStates').selectedIndex = val;"/>
93 <method name="init">
94 <parameter name="aTranslation"/>
95 <body>
96 <![CDATA[
97 this.translation = aTranslation;
98 let bundle = Cc["@mozilla.org/intl/stringbundle;1"]
99 .getService(Ci.nsIStringBundleService)
100 .createBundle("chrome://global/locale/languageNames.properties");
102 // Fill the lists of supported source languages.
103 let detectedLanguage = this._getAnonElt("detectedLanguage");
104 let fromLanguage = this._getAnonElt("fromLanguage");
105 for (let code of Translation.supportedSourceLanguages) {
106 let name = bundle.GetStringFromName(code);
107 detectedLanguage.appendItem(name, code);
108 fromLanguage.appendItem(name, code);
109 }
110 detectedLanguage.value = this.translation.detectedLanguage;
112 // translatedFrom is only set if we have already translated this page.
113 if (aTranslation.translatedFrom)
114 fromLanguage.value = aTranslation.translatedFrom;
116 // Fill the list of supporter target languages.
117 let toLanguage = this._getAnonElt("toLanguage");
118 for (let code of Translation.supportedTargetLanguages)
119 toLanguage.appendItem(bundle.GetStringFromName(code), code);
121 if (aTranslation.translatedTo)
122 toLanguage.value = aTranslation.translatedTo;
124 if (aTranslation.state)
125 this.state = aTranslation.state;
127 this._handleButtonHiding(aTranslation.originalShown);
128 ]]>
129 </body>
130 </method>
132 <method name="_getAnonElt">
133 <parameter name="aAnonId"/>
134 <body>
135 return document.getAnonymousElementByAttribute(this, "anonid", aAnonId);
136 </body>
137 </method>
139 <method name="translate">
140 <body>
141 <![CDATA[
142 if (this.state == this.translation.STATE_OFFER) {
143 this._getAnonElt("fromLanguage").value =
144 this._getAnonElt("detectedLanguage").value;
145 this._getAnonElt("toLanguage").value =
146 Translation.defaultTargetLanguage;
147 }
149 this._handleButtonHiding(false);
150 this.translation.translate(this._getAnonElt("fromLanguage").value,
151 this._getAnonElt("toLanguage").value);
152 ]]>
153 </body>
154 </method>
156 <method name="_handleButtonHiding">
157 <parameter name="aOriginalShown"/>
158 <body>
159 <![CDATA[
160 this._getAnonElt("showOriginal").hidden = aOriginalShown;
161 this._getAnonElt("showTranslation").hidden = !aOriginalShown;
162 ]]>
163 </body>
164 </method>
166 <method name="showOriginal">
167 <body>
168 <![CDATA[
169 this._handleButtonHiding(true);
170 this.translation.showOriginalContent();
171 ]]>
172 </body>
173 </method>
175 <method name="showTranslation">
176 <body>
177 <![CDATA[
178 this._handleButtonHiding(false);
179 this.translation.showTranslatedContent();
180 ]]>
181 </body>
182 </method>
184 </implementation>
185 </binding>
186 </bindings>