From a1be17c1cea81ebb1e8b131a662c698d78f3f7f2 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Mon, 4 Jun 2018 13:17:38 +0200 Subject: Issue #303 Part 1: Move basilisk files from /browser to /application/basilisk --- .../components/translation/translation-infobar.xml | 441 +++++++++++++++++++++ 1 file changed, 441 insertions(+) create mode 100644 application/basilisk/components/translation/translation-infobar.xml (limited to 'application/basilisk/components/translation/translation-infobar.xml') diff --git a/application/basilisk/components/translation/translation-infobar.xml b/application/basilisk/components/translation/translation-infobar.xml new file mode 100644 index 000000000..db0695c03 --- /dev/null +++ b/application/basilisk/components/translation/translation-infobar.xml @@ -0,0 +1,441 @@ + + + + +%notificationDTD; + +%translationDTD; +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + &translation.options.attribution.beforeLogo; + + &translation.options.attribution.afterLogo; + + &translation.options.attribution.yandexTranslate; + + + + + + + + + + + + + + + + + + + + [code, bundle.GetStringFromName(code)]) + .sort((a, b) => a[1].localeCompare(b[1])); + }; + + // Fill the lists of supported source languages. + let detectedLanguage = this._getAnonElt("detectedLanguage"); + let fromLanguage = this._getAnonElt("fromLanguage"); + let sourceLanguages = + sortByLocalizedName(Translation.supportedSourceLanguages); + for (let [code, name] of sourceLanguages) { + 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 supported target languages. + let toLanguage = this._getAnonElt("toLanguage"); + let targetLanguages = + sortByLocalizedName(Translation.supportedTargetLanguages); + for (let [code, name] of targetLanguages) + toLanguage.appendItem(name, code); + + if (aTranslation.translatedTo) + toLanguage.value = aTranslation.translatedTo; + + if (aTranslation.state) + this.state = aTranslation.state; + + // Show attribution for the preferred translator. + let engineIndex = Object.keys(Translation.supportedEngines) + .indexOf(Translation.translationEngine); + if (engineIndex != -1) { + this._getAnonElt('translationEngine').selectedIndex = engineIndex; + } + + const kWelcomePref = "browser.translation.ui.welcomeMessageShown"; + if (Services.prefs.prefHasUserValue(kWelcomePref) || + this.translation.browser != gBrowser.selectedBrowser) + return; + + this.addEventListener("transitionend", function onShown() { + this.removeEventListener("transitionend", onShown); + + // These strings are hardcoded because they need to reach beta + // without riding the trains. + let localizedStrings = { + en: ["Hey look! It's something new!", + "Now the Web is even more accessible with our new in-page translation feature. Click the translate button to try it!", + "Learn more.", + "Thanks"], + "es-AR": ["\xA1Mir\xE1! \xA1Hay algo nuevo!", + "Ahora la web es a\xFAn m\xE1s accesible con nuestra nueva funcionalidad de traducci\xF3n integrada. \xA1Hac\xE9 clic en el bot\xF3n traducir para probarla!", + "Conoc\xE9 m\xE1s.", + "Gracias"], + "es-ES": ["\xA1Mira! \xA1Hay algo nuevo!", + "Con la nueva funcionalidad de traducci\xF3n integrada, ahora la Web es a\xFAn m\xE1s accesible. \xA1Pulsa el bot\xF3n Traducir y pru\xE9bala!", + "M\xE1s informaci\xF3n.", + "Gracias"], + pl: ["Sp\xF3jrz tutaj! To co\u015B nowego!", + "Sie\u0107 sta\u0142a si\u0119 w\u0142a\u015Bnie jeszcze bardziej dost\u0119pna dzi\u0119ki opcji bezpo\u015Bredniego t\u0142umaczenia stron. Kliknij przycisk t\u0142umaczenia, aby spr\xF3bowa\u0107!", + "Dowiedz si\u0119 wi\u0119cej", + "Dzi\u0119kuj\u0119"], + tr: ["Bak\u0131n, burada yeni bir \u015Fey var!", + "Yeni sayfa i\xE7i \xE7eviri \xF6zelli\u011Fimiz sayesinde Web art\u0131k \xE7ok daha anla\u015F\u0131l\u0131r olacak. Denemek i\xE7in \xC7evir d\xFC\u011Fmesine t\u0131klay\u0131n!", + "Daha fazla bilgi al\u0131n.", + "Te\u015Fekk\xFCrler"], + vi: ["Nh\xECn n\xE0y! \u0110\u1ED3 m\u1EDBi!", + "Gi\u1EDD \u0111\xE2y ch\xFAng ta c\xF3 th\u1EC3 ti\u1EBFp c\u1EADn web d\u1EC5 d\xE0ng h\u01A1n n\u1EEFa v\u1EDBi t\xEDnh n\u0103ng d\u1ECBch ngay trong trang. Hay nh\u1EA5n n\xFAt d\u1ECBch \u0111\u1EC3 th\u1EED!", + "T\xECm hi\u1EC3u th\xEAm.", + "C\u1EA3m \u01A1n"] + }; + + let locale = Cc["@mozilla.org/chrome/chrome-registry;1"] + .getService(Ci.nsIXULChromeRegistry) + .getSelectedLocale("browser"); + if (!(locale in localizedStrings)) + locale = "en"; + let strings = localizedStrings[locale]; + + this._getAnonElt("welcomeHeadline").setAttribute("value", strings[0]); + this._getAnonElt("welcomeBody").textContent = strings[1]; + this._getAnonElt("learnMore").setAttribute("value", strings[2]); + this._getAnonElt("thanksButton").setAttribute("label", strings[3]); + + let panel = this._getAnonElt("welcomePanel"); + panel.openPopup(this._getAnonElt("messageImage"), + "bottomcenter topleft"); + + Services.prefs.setBoolPref(kWelcomePref, true); + }); + ]]> + + + + + + + return document.getAnonymousElementByAttribute(this, "anonid", aAnonId); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3