Bug #280825 --> Add Pref UI for changing the Spell As You Type Dictionary

This commit is contained in:
scott%scott-macgregor.org 2005-04-27 22:49:00 +00:00
Родитель f39f996aa2
Коммит c1648bc125
3 изменённых файлов: 116 добавлений и 1 удалений

Просмотреть файл

@ -42,6 +42,7 @@ var gComposePane = {
mInitialized: false,
mDirectories: null,
mLDAPPrefsService: null,
mSpellChecker: null,
init: function ()
{
@ -51,6 +52,10 @@ var gComposePane = {
this.createDirectoriesList();
this.enableAutocomplete();
this.initLanguageMenu();
document.getElementById('downloadDictionaries').setAttribute('href', xlateURL('urn:clienturl:composer:spellcheckers'));
var preference = document.getElementById("mail.preferences.compose.selectedTabIndex");
if (preference.value)
document.getElementById("composePrefs").selectedIndex = preference.value;
@ -250,6 +255,88 @@ var gComposePane = {
this.mDirectories = null;
this.loadDirectories(popup);
gRefresh = false;
}
},
initLanguageMenu: function ()
{
this.mSpellChecker = Components.classes['@mozilla.org/spellchecker/myspell;1'].createInstance(Components.interfaces.mozISpellCheckingEngine);
var o1 = {};
var o2 = {};
var languageMenuList = document.getElementById('LanguageMenulist');
// Get the list of dictionaries from
// the spellchecker.
this.mSpellChecker.getDictionaryList(o1, o2);
var dictList = o1.value;
var count = o2.value;
// Load the string bundles that will help us map
// RFC 1766 strings to UI strings.
// Load the language string bundle.
var languageBundle = document.getElementById("languageBundle");
var regionBundle;
// If we have a language string bundle, load the region string bundle.
if (languageBundle)
regionBundle = document.getElementById("regionBundle");
var menuStr2;
var isoStrArray;
var defaultItem = null;
var langId;
var i;
for (i = 0; i < dictList.length; i++)
{
try {
langId = dictList[i];
isoStrArray = dictList[i].split("-");
dictList[i] = new Array(2); // first subarray element - pretty name
dictList[i][1] = langId; // second subarray element - language ID
if (languageBundle && isoStrArray[0])
dictList[i][0] = languageBundle.getString(isoStrArray[0].toLowerCase());
if (regionBundle && dictList[i][0] && isoStrArray.length > 1 && isoStrArray[1])
{
menuStr2 = regionBundle.getString(isoStrArray[1].toLowerCase());
if (menuStr2)
dictList[i][0] = dictList[i][0] + "/" + menuStr2;
}
if (!dictList[i][0])
dictList[i][0] = dictList[i][1];
} catch (ex) {
// GetString throws an exception when
// a key is not found in the bundle. In that
// case, just use the original dictList string.
dictList[i][0] = dictList[i][1];
}
}
// note this is not locale-aware collation, just simple ASCII-based sorting
// we really need to add loacel-aware JS collation, see bug XXXXX
dictList.sort();
var curLang = languageMenuList.value;
// now select the dictionary we are currently using
for (i = 0; i < dictList.length; i++)
{
var item = languageMenuList.appendItem(dictList[i][0], dictList[i][1]);
if (curLang && dictList[i][1] == curLang)
defaultItem = item;
}
// Now make sure the correct item in the menu list is selected.
if (defaultItem)
languageMenuList.selectedItem = defaultItem;
else
languageMenuList.selectedIndex = 0;
},
};

Просмотреть файл

@ -45,10 +45,15 @@
<overlay id="ComposePaneOverlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:nc="http://home.netscape.com/NC-rdf#"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<prefpane id="paneCompose" onpaneload="gComposePane.init();">
<script type="application/x-javascript" src="chrome://messenger/content/preferences/compose.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/builtinURLs.js"/>
<stringbundle id="languageBundle" src="chrome://global/locale/languageNames.properties"/>
<stringbundle id="regionBundle" src="chrome://global/locale/regionNames.properties"/>
<preferences>
<preference id="mail.preferences.compose.selectedTabIndex" name="mail.preferences.compose.selectedTabIndex" type="int"/>
@ -65,6 +70,7 @@
<preference id="ldap_2.autoComplete.directoryServer" name="ldap_2.autoComplete.directoryServer" type="string"/>
<preference id="mail.collect_email_address_outgoing" name="mail.collect_email_address_outgoing" type="bool"/>
<preference id="mail.collect_addressbook" name="mail.collect_addressbook" type="string"/>
<preference id="spellchecker.dictionary" name="spellchecker.dictionary" type="wstring"/>
</preferences>
<tabbox id="composePrefs" flex="1" onselect="gComposePane.tabSelectionChanged();">
@ -186,6 +192,24 @@
<checkbox id="inlineSpellCheck" label="&spellCheckInline.label;"
preference="mail.spellcheck.inline"
accesskey="&spellCheckInline.accesskey;"/>
<separator class="thin"/>
<hbox align="center" pack="start">
<label value ="&languagePopup.label;" control="LanguageMenulist" accesskey="&languagePopup.accessKey;"/>
<menulist id="LanguageMenulist" preference="spellchecker.dictionary">
<menupopup>
<!-- dynamic content populated by JS -->
</menupopup>
</menulist>
<spring flex="1"/>
</hbox>
<separator/>
<html:a id="downloadDictionaries"
style="display: block; color: blue; text-decoration: underline; margin-left: 5px;">&downloadDictionaries.label;</html:a>
</tabpanel>
</tabpanels>
</tabbox>

Просмотреть файл

@ -16,6 +16,10 @@
<!ENTITY spellCheck.accesskey "C">
<!ENTITY spellCheckInline.label "Enable spell as you type">
<!ENTITY spellCheckInline.accesskey "n">
<!ENTITY languagePopup.label "Dictionary Language:">
<!ENTITY languagePopup.accessKey "y">
<!ENTITY downloadDictionaries.label "Download More Dictionaries">
<!ENTITY useMIME.label "For messages that contain 8-bit characters, use 'quoted printable' MIME encoding">
<!ENTITY useMIME.accesskey "o">
<!ENTITY warnOnSendAccelKey.label "Confirm when using keyboard shortcut to send message">