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

263 lines
10 KiB
Plaintext
Raw Normal View History

<?xml version="1.0"?>
<!--
The contents of this file are subject to the Netscape 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/NPL/
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.
Contributor(s): J. M. Betak <loadrunner@betak.net>
Josh Soref <timeless@mac.com>
-->
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
<?xul-overlay href="chrome://communicator/content/utilityOverlay.xul"?>
<!DOCTYPE window [
<!ENTITY % brandDTD SYSTEM "chrome://global/locale/brand.dtd" >
%brandDTD;
<!ENTITY % regionDTD SYSTEM "chrome://global-region/locale/region.dtd" >
%regionDTD;
<!ENTITY % prefContentDTD SYSTEM "chrome://content-packs/locale/pref-contentpacks.dtd" >
%prefContentDTD;
]>
<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="parent.initPanel('chrome://content-packs/content/pref-contentpacks.xul'); "
headertitle="&lHeader;">
<stringbundle id="bundle_contentPack"
src="chrome://content-packs/locale/contentpacks.properties"/>
<stringbundle id="bundle_brand"
src="chrome://global/locale/brand.properties"/>
<script type="application/x-javascript">
<![CDATA[
var _elementIDs = ["contentPackList", "languagePackList"];
function Startup()
{
var contentList = document.getElementById( "contentPackList" );
var regionName = contentList.getAttribute("prefvalue");
var regionElements = contentList.getElementsByAttribute("value", regionName);
if (regionElements.length) {
contentList.selectItem(regionElements[0]);
} else {
contentList.selectedIndex = 0;
}
var languageList = document.getElementById( "languagePackList" );
var languageName = languageList.getAttribute("prefvalue");
var languageElements =languageList.getElementsByAttribute("value", languageName);
if (languageElements.length) {
languageList.selectItem(languageElements[0]);
} else {
languageList.selectedIndex = 0;
}
parent.hPrefWindow.registerOKCallbackFunc( SwitchPacks );
}
function SwitchPacks()
{
//Switch the Content pack if necessary
var oldContentPack = parent.hPrefWindow.getPref( "localizedstring", "general.useragent.contentlocale");
var newContentPack;
try {
var listbox = document.getElementById("contentPackList");
if (listbox) {
var selectedItem = listbox.selectedItems.length ? listbox.selectedItems[0] : null;
if (selectedItem) {
newContentPack = selectedItem.getAttribute("value");
}
} else {
newContentPack = parent.hPrefWindow.wsm.dataManager.getItemData( "chrome://communicator/content/pref/pref-content.xul", "contentPackList" ).prefvalue;
}
}
catch (e) {}
if (newContentPack && (newContentPack != oldContentPack))
{
try {
var chromeRegistry = Components.classes["@mozilla.org/chrome/chrome-registry;1"].getService(Components.interfaces.nsIChromeRegistry);
chromeRegistry.selectLocale(newContentPack, true);
var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
observerService.notifyObservers(null, "locale-selected", null);
var contentBundle = document.getElementById("bundle_contentPack");
var brandBundle = document.getElementById("bundle_brand");
var alertText = contentBundle.getString("contentAlert");
alertText = alertText.replace(/%brand%/g, brandBundle.getString("brandShortName"));
var titleText = contentBundle.GetStringFromName("languageTitle");
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService();
promptService = promptService.QueryInterface(Components.interfaces.nsIPromptService);
promptService.alert(window, titleText, alertText);
}
catch(e) {
return false;
}
}
///Switch the Language pack if necessary
var oldLanguagePack = parent.hPrefWindow.getPref( "localizedstring", "general.useragent.locale");
var newLanguagePack;
try {
var languageList = document.getElementById("languagePackList");
if (languageList) {
var selectedItem = languageList.selectedItems.length ? languageList.selectedItems[0] : null;
if (selectedItem) {
newLanguagePack = selectedItem.getAttribute("value");
}
} else {
newLanguagePack = parent.hPrefWindow.wsm.dataManager.getItemData( "chrome://communicator/content/pref/pref-content.xul", "languagePackList" ).prefvalue;
}
}
catch (e) {}
if (newLanguagePack && (newLanguagePack != oldLanguagePack))
{
try {
var chromeRegistry = Components.classes["@mozilla.org/chrome/chrome-registry;1"].getService(Components.interfaces.nsIChromeRegistry);
chromeRegistry.selectLocale(newLanguagePack, true);
var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
observerService.notifyObservers(null, "locale-selected", null);
}
catch(e) {
return false;
}
}
}
function SelectContentPack()
{
var listbox = document.getElementById("contentPackList");
var selectedItem = listbox.selectedItems.length ? listbox.selectedItems[0] : null;
if (selectedItem) {
var classType = selectedItem.getAttribute("class");
if (classType == "outofdate") {
//Make it so that out of date content packs cannot be selected by the user
listbox.removeItemFromSelection(selectedItem);
}
else {
var regionName = selectedItem.getAttribute("value");
listbox.setAttribute("prefvalue", regionName);
}
}
}
function SelectLanguagePack()
{
var listbox = document.getElementById("languagePackList");
var selectedItem = listbox.selectedItems.length ? listbox.selectedItems[0] : null;
if (selectedItem) {
var classType = selectedItem.getAttribute("class");
if (classType == "outofdate") {
//Make it so that out of date language packs cannot be selected by the user
listbox.removeItemFromSelection(selectedItem);
}
else {
var languageName = selectedItem.getAttribute("value");
listbox.setAttribute("prefvalue", languageName);
}
}
}
function DownloadRegionPacks()
{
openTopWin(xlateURL("urn:clienturl:viewmenu:intlwebcontent"));
}
]]>
</script>
<hbox class="box-smallheader" title="&lHeader;"/>
<!-- Content (aka region) pack listbox -->
<description>&contentIntro.label;</description>
<separator class="thin"/>
<description>&installedContentPacks.label;</description>
<listbox id="contentPackList" flex="1" rows="2"
ref="urn:mozilla:locale:root" datasources="rdf:chrome"
sortResource="http://www.mozilla.org/rdf/chrome#name"
preftype="localizedstring" prefstring="general.useragent.contentlocale"
prefvalue="" prefattribute="prefvalue" wsm_attributes="prefvalue"
seltype="false" onselect="SelectContentPack();"
sortDirection="ascending">
<template xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
<!-- This rule displays only up to date content packs based on the localeVersion -->
<rule chrome:localeType="region" chrome:localeVersion="&content.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 content packs -->
<rule chrome:localeType="region">
<listitem uri="..." translation="true" nselected="false" class="outofdate"
label="rdf:http://www.mozilla.org/rdf/chrome#displayName &update.label;"
value="rdf:http://www.mozilla.org/rdf/chrome#name"/>
</rule>
</template>
</listbox>
<!-- Language pack listbox -->
<description>&languageIntro.label;</description>
<separator class="thin"/>
<description>&installedLanguagePacks.label;</description>
<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="value"
seltype="false"
onselect="SelectLanguagePack();"
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>
<listitem uri="..." translation="true" nselected="false" class="outofdate"
label="rdf:http://www.mozilla.org/rdf/chrome#displayName &update.label;"
value="rdf:http://www.mozilla.org/rdf/chrome#name"/>
</rule>
</template>
</listbox>
<separator class="thin"/>
<hbox>
<spacer flex="1"/>
<button id="downloadContentPacks"
label="&downloadContentPacks.label;"
accesskey="&downloadContentPacks.accesskey;"
oncommand="DownloadRegionPacks()"/>
</hbox>
</page>