File: translation-infobar.xml

package info (click to toggle)
icedove 31.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 1,007,612 kB
  • sloc: cpp: 3,959,977; ansic: 1,866,528; java: 219,720; python: 200,664; xml: 142,383; asm: 133,557; sh: 75,814; makefile: 27,028; perl: 26,849; objc: 4,014; yacc: 1,995; pascal: 1,024; lex: 950; exp: 449; lisp: 228; awk: 211; php: 113; sed: 43; csh: 31; ada: 16; ruby: 3
file content (186 lines) | stat: -rw-r--r-- 7,671 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<?xml version="1.0"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
   - License, v. 2.0. If a copy of the MPL was not distributed with this
   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->

<!DOCTYPE bindings [
<!ENTITY % notificationDTD SYSTEM "chrome://global/locale/notification.dtd">
%notificationDTD;
<!ENTITY % translationDTD SYSTEM "chrome://browser/locale/translation.dtd" >
%translationDTD;
]>

<bindings id="translationBindings"
          xmlns="http://www.mozilla.org/xbl"
          xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
          xmlns:xbl="http://www.mozilla.org/xbl">
  <binding id="translationbar" extends="chrome://global/content/bindings/notification.xml#notification" role="xul:alert">
    <resources>
      <stylesheet src="chrome://global/skin/notification.css"/>
    </resources>
    <content>
      <xul:hbox class="notification-inner outset" flex="1" xbl:inherits="type">
        <xul:hbox anonid="details" align="center" flex="1">
          <xul:image anonid="messageImage" class="messageImage" xbl:inherits="src=image,type,value"/>
          <xul:deck anonid="translationStates" selectedIndex="0">

            <!-- offer to translate -->
            <xul:hbox class="translate-offer-box" align="baseline">
              <xul:label value="&translation.thisPageIsIn.label;"/>
              <xul:menulist anonid="detectedLanguage">
                <xul:menupopup/>
              </xul:menulist>
              <xul:label value="&translation.translateThisPage.label;"/>
              <xul:button label="&translation.translate.button;" anonid="translate"
                          oncommand="document.getBindingParent(this).translate();"/>
              <xul:button label="&translation.notNow.button;" anonid="notNow"
                          oncommand="document.getBindingParent(this).close();"/>
            </xul:hbox>

            <!-- translating -->
            <xul:vbox class="translating-box" pack="center">
              <xul:label value="&translation.translatingContent.label;"/>
            </xul:vbox>

            <!-- translated -->
            <xul:hbox class="translated-box" align="baseline">
              <xul:label value="&translation.translatedFrom.label;"/>
              <xul:menulist anonid="fromLanguage"
                            oncommand="document.getBindingParent(this).translate()">
                <xul:menupopup/>
              </xul:menulist>
              <xul:label value="&translation.translatedTo.label;"/>
              <xul:menulist anonid="toLanguage"
                            oncommand="document.getBindingParent(this).translate()">
                <xul:menupopup/>
              </xul:menulist>
              <xul:label value="&translation.translatedToSuffix.label;"/>
              <xul:button anonid="showOriginal"
                          label="&translation.showOriginal.button;"
                          oncommand="document.getBindingParent(this).showOriginal();"/>
              <xul:button anonid="showTranslation"
                          label="&translation.showTranslation.button;"
                          oncommand="document.getBindingParent(this).showTranslation();"/>
            </xul:hbox>

            <!-- error -->
            <xul:hbox class="translation-error" align="baseline">
              <xul:label value="&translation.errorTranslating.label;"/>
              <xul:button label="&translation.tryAgain.button;" anonid="tryAgain"
                          oncommand="document.getBindingParent(this).translate();"/>
            </xul:hbox>

          </xul:deck>
          <xul:spacer flex="1"/>

          <xul:button type="menu" label="&translation.options.menu;">
            <xul:menupopup/>
          </xul:button>

        </xul:hbox>
        <xul:toolbarbutton ondblclick="event.stopPropagation();"
                           class="messageCloseButton close-icon tabbable"
                           xbl:inherits="hidden=hideclose"
                           tooltiptext="&closeNotification.tooltip;"
                           oncommand="document.getBindingParent(this).close();"/>
      </xul:hbox>
    </content>
    <implementation>
      <property name="state"
                onget="return this._getAnonElt('translationStates').selectedIndex;"
                onset="this._getAnonElt('translationStates').selectedIndex = val;"/>

      <method name="init">
        <parameter name="aTranslation"/>
        <body>
          <![CDATA[
            this.translation = aTranslation;
            let bundle = Cc["@mozilla.org/intl/stringbundle;1"]
                           .getService(Ci.nsIStringBundleService)
                           .createBundle("chrome://global/locale/languageNames.properties");

            // Fill the lists of supported source languages.
            let detectedLanguage = this._getAnonElt("detectedLanguage");
            let fromLanguage = this._getAnonElt("fromLanguage");
            for (let code of Translation.supportedSourceLanguages) {
              let name = bundle.GetStringFromName(code);
              detectedLanguage.appendItem(name, code);
              fromLanguage.appendItem(name, code);
            }
            detectedLanguage.value = this.translation.detectedLanguage;

            // translatedFrom is only set if we have already translated this page.
            if (aTranslation.translatedFrom)
              fromLanguage.value = aTranslation.translatedFrom;

            // Fill the list of supporter target languages.
            let toLanguage = this._getAnonElt("toLanguage");
            for (let code of Translation.supportedTargetLanguages)
              toLanguage.appendItem(bundle.GetStringFromName(code), code);

            if (aTranslation.translatedTo)
              toLanguage.value = aTranslation.translatedTo;

            if (aTranslation.state)
              this.state = aTranslation.state;

            this._handleButtonHiding(aTranslation.originalShown);
          ]]>
        </body>
      </method>

      <method name="_getAnonElt">
        <parameter name="aAnonId"/>
        <body>
          return document.getAnonymousElementByAttribute(this, "anonid", aAnonId);
        </body>
      </method>

      <method name="translate">
        <body>
          <![CDATA[
            if (this.state == this.translation.STATE_OFFER) {
              this._getAnonElt("fromLanguage").value =
                this._getAnonElt("detectedLanguage").value;
              this._getAnonElt("toLanguage").value =
                Translation.defaultTargetLanguage;
            }

            this._handleButtonHiding(false);
            this.translation.translate(this._getAnonElt("fromLanguage").value,
                                       this._getAnonElt("toLanguage").value);
          ]]>
        </body>
      </method>

      <method name="_handleButtonHiding">
        <parameter name="aOriginalShown"/>
        <body>
          <![CDATA[
            this._getAnonElt("showOriginal").hidden = aOriginalShown;
            this._getAnonElt("showTranslation").hidden = !aOriginalShown;
          ]]>
        </body>
      </method>

      <method name="showOriginal">
        <body>
          <![CDATA[
            this._handleButtonHiding(true);
            this.translation.showOriginalContent();
          ]]>
        </body>
      </method>

      <method name="showTranslation">
        <body>
          <![CDATA[
            this._handleButtonHiding(false);
            this.translation.showTranslatedContent();
          ]]>
        </body>
      </method>

    </implementation>
  </binding>
</bindings>