browser/components/translation/translation-infobar.xml

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial