gecko-dev/suite/common/pref/pref-locales.xul

240 lines
9.3 KiB
XML

<?xml version="1.0"?>
<!-- ***** BEGIN LICENSE BLOCK *****
Version: MPL 1.1/GPL 2.0/LGPL 2.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is mozilla.org Code.
The Initial Developer of the Original Code is
Netscape Communications Corporation.
Portions created by the Initial Developer are Copyright (C) 2001
the Initial Developer. All Rights Reserved.
Contributor(s):
J.Betak <jbetak@netscape.com>
Josh Soref <timeless@mac.com>
Robert Kaiser <kairo@kairo.at>
Alternatively, the contents of this file may be used under the terms of
either the GNU General Public License Version 2 or later (the "GPL"), or
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
in which case the provisions of the GPL or the LGPL are applicable instead
of those above. If you wish to allow use of your version of this file only
under the terms of either the GPL or the LGPL, and not to allow others to
use your version of this file under the terms of the MPL, indicate your
decision by deleting the provisions above and replace them with the notice
and other provisions required by the GPL or the LGPL. If you do not delete
the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL.
***** END LICENSE BLOCK ***** -->
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
<?xul-overlay href="chrome://communicator/content/utilityOverlay.xul"?>
<!DOCTYPE page [
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
%brandDTD;
<!ENTITY % regionDTD SYSTEM "chrome://global-region/locale/region.dtd">
%regionDTD;
<!ENTITY % prefLocalesDTD SYSTEM "chrome://communicator/locale/pref/pref-locales.dtd">
%prefLocalesDTD;
]>
<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="parent.initPanel('chrome://communicator/content/pref/pref-locales.xul');"
headertitle="&pref.locales.title;">
<script type="application/x-javascript">
<![CDATA[
var _elementIDs = ["languagePackList"];
function Startup()
{
var languageList = document.getElementById( "languagePackList" );
var languageName = languageList.getAttribute("prefvalue");
var languageElements = languageList.getElementsByAttribute("value", languageName);
if (languageElements.item(0)) {
languageList.selectItem(languageElements.item(0));
} else {
languageList.selectedIndex = 0;
}
parent.hPrefWindow.registerOKCallbackFunc( SwitchPacks );
}
function SwitchPacks()
{
var shouldRemoveFaslFile = false;
//Switch the Language pack if necessary
var oldLanguagePack = parent.hPrefWindow.getPref( "localizedstring", "general.useragent.locale");
var newLanguagePack = parent.hPrefWindow.wsm.dataManager.getItemData( "chrome://communicator/content/pref/pref-locales.xul", "languagePackList" ).prefvalue;
if (newLanguagePack && (newLanguagePack != oldLanguagePack))
{
try {
parent.hPrefWindow.chromeRegistry.selectLocale(newLanguagePack, true);
shouldRemoveFaslFile = true;
parent.hPrefWindow.observerService.notifyObservers(null, "locale-selected", null);
}
catch(e) {}
}
// If we changed locale, we need to destroy the fastload file so that it
// will load the language strings from the new locale jars. No one should
// have the fastload file open at this moment, so the remove should succeed.
// (XXX actually there is a small window where this is possible, in which
// case we're screwed).
// XXX This should have really been done in the chrome registry itself,
// not be in front-end code, but this patch was only to get this mostly
// working for Mozilla 1.1b - see bug 142623
// "The code below must die before [Mozilla] 1.1final!!" ;-)
if (shouldRemoveFaslFile) {
try {
const XUL_FASTLOAD_FILE_BASENAME = "XUL";
var faslService = Components.classes['@mozilla.org/fast-load-service;1']
.getService(Components.interfaces.nsIFastLoadService);
var faslFile = faslService.newFastLoadFile(XUL_FASTLOAD_FILE_BASENAME);
faslFile.remove(false);
} catch(e) {}
}
return true;
}
function SelectPack(listbox, button)
{
var list = document.getElementById(listbox);
var selectedItem = list.selectedItems.length ? list.selectedItems[0] : null;
if (selectedItem) {
var uninstallButton = document.getElementById(button);
var packID = selectedItem.getAttribute("value");
//current chrome providers cannot be uninstalled
uninstallButton.disabled = (packID == parent.hPrefWindow.getPref("localizedstring", list.getAttribute("prefstring")));
//out-of-date packs cannot become chrome providers
if (selectedItem.getAttribute("class") == "outofdate")
list.setAttribute("prefvalue", parent.hPrefWindow.getPref("localizedstring", list.getAttribute("prefstring")));
else
list.setAttribute("prefvalue", packID);
}
}
function UninstallPack(listbox)
{
var list = document.getElementById(listbox);
var selectedContentItem = list.selectedItems[0];
var packName = selectedContentItem.getAttribute("value");
try {
//uninstall from global chrome
parent.hPrefWindow.chromeRegistry.uninstallLocale(packName, false);
//uninstall from profile-bound chrome
parent.hPrefWindow.chromeRegistry.uninstallLocale(packName, true);
}
catch(e) {}
if (packName == list.getAttribute("prefvalue"))
list.setAttribute("prefvalue", parent.hPrefWindow.getPref("localizedstring", list.getAttribute("prefstring")));
//removed items cannot become chrome providers
var listSelection = list.getElementsByAttribute("value", list.getAttribute("prefvalue"));
//find and select the list item corresponding to the current chrome provider
if (listSelection.item(0))
list.selectedItem = listSelection.item(0);
else
list.selectedIndex = 0;
}
function DownloadRegionPacks()
{
openTopWin(xlateURL("urn:clienturl:viewmenu:intlwebcontent"));
}
]]>
</script>
<hbox class="box-smallheader" title="&pref.locales.title;"/>
<!-- Language pack listbox -->
<description>&languageIntro.label;</description>
<separator class="thin"/>
<label control="languagePackList">&installedLanguagePacks.label;</label>
<listbox id="languagePackList" flex="1" rows="3"
ref="urn:mozilla:locale:root"
datasources="rdf:chrome"
sortResource="http://www.mozilla.org/rdf/chrome#name"
preftype="localizedstring"
prefstring="general.useragent.locale"
prefattribute="prefvalue"
wsm_attributes="prefvalue"
seltype="false"
onselect="SelectPack('languagePackList', 'uninstallLanguagePack');"
sortDirection="ascending">
<template xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
<!-- This rule eliminates region packs from the language pack list -->
<rule chrome:localeType="region"/>
<!-- This rule displays only up to date language packs based on the localeVersion -->
<rule chrome:localeVersion="&lang.version;">
<listitem uri="..." translation="true" nselected="false"
label="rdf:http://www.mozilla.org/rdf/chrome#displayName"
value="rdf:http://www.mozilla.org/rdf/chrome#name"/>
</rule>
<!-- This rule "falls through" to match obsolete language packs -->
<rule>
<conditions>
<content uri="?container"/>
<member container="?container" child="?member"/>
<triple predicate="http://www.mozilla.org/rdf/chrome#localeVersion"
subject="?member" object="?version"/>
</conditions>
<bindings>
<binding predicate="http://www.mozilla.org/rdf/chrome#displayName"
subject="?member" object="?label"/>
<binding predicate="http://www.mozilla.org/rdf/chrome#name"
subject="?member" object="?value"/>
</bindings>
<action>
<listitem uri="?member" label="?label ?version &update.label;" value="?value"
translation="true" nselected="false" class="outofdate"/>
</action>
</rule>
</template>
</listbox>
<hbox>
<vbox>
<button id="uninstallLanguagePack"
label="&uninstallLanguagePack.label;"
accesskey="&uninstallLanguagePack.accesskey;"
oncommand="UninstallPack('languagePackList')"/>
</vbox>
<vbox>
<button id="downloadLanguagePacks"
label="&downloadLanguagePacks.label;"
accesskey="&downloadLanguagePacks.accesskey;"
oncommand="DownloadRegionPacks()"/>
</vbox>
</hbox>
<separator class="thin"/>
<description>&restartOnLangChange.label;</description>
<separator class="thin"/>
</page>