Fix for bugscape bug 11874: Better description of language desired in

Lang dropdown menu (r=smeredith)
This commit is contained in:
shrutiv%netscape.com 2002-05-06 20:34:26 +00:00
Родитель e37db329a3
Коммит fae65893f8
7 изменённых файлов: 160 добавлений и 13 удалений

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

@ -75,21 +75,20 @@ Name=Text5888
Value=Operating System:
Start_x=11
Start_y=65
Width=80
Width=70
Height=15
[Widget 6888]
Type=DropBox
Name=lPlatform
Value=Windows
Start_x=100
Start_x=85
Start_y=64
Width=64
Width=107
height=75
onInit=GenerateDirList(self,%Root%Version\%Version%\*.*)
onCommand=GenerateDirList(self,%Root%Version\%Version%\*.*);GenerateDirList(Language,%Root%Version\%Version%\%lPlatform%\*.*);ChangePlatform(lPlatform)
onCommand=GenerateDirList(self,%Root%Version\%Version%\*.*);GenerateLocaleNameList(Language,%Root%Version\%Version%\%lPlatform%\*.*);ChangePlatform(lPlatform)
Target=Language
;toggleEnabled2(%lPlatform%,Button4888);
[Widget 7888]
Type=Text
@ -97,19 +96,19 @@ Name=Text7888
Value=Language-Region:
Start_x=11
Start_y=95
Width=80
Width=70
Height=15
[Widget 8888]
Type=DropBox
Name=Language
Value=enus
Start_x=100
Value=English-United States (enus)
Start_x=85
Start_y=94
Width=64
Width=107
height=75
onInit=GenerateDirList(self,%Root%Version\%Version%\%lPlatform%\*.*)
onCommand=GenerateDirList(self,%Root%Version\%Version%\%lPlatform%\*.*);ChangePlatform(Language)
onInit=GenerateLocaleNameList(self,%Root%Version\%Version%\%lPlatform%\*.*)
onCommand=GenerateLocaleNameList(self,%Root%Version\%Version%\%lPlatform%\*.*);ChangePlatform(Language)
;[Widget 9888]
;Type=Text

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

@ -38,5 +38,5 @@ SSLportno=0
SOCKSportno=0
Version=6.5
lPlatform=Windows
Language=enus
Language=English-United States (enus)

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

@ -475,6 +475,32 @@ void CInterpret::GenerateList(CString action, WIDGET* curWidget, CString parentD
fileList.Close();
}
void CInterpret::GenerateLocaleNameList(WIDGET *curWidget, CString parentDirPath)
{
// Generate the list of all subdirectories in parent directory
// and display the corresponing pretty locale name
CFileFind fileList;
CString tmpFile;
int i = 0;
BOOL dirFound = fileList.FindFile(parentDirPath);
while (dirFound)
{
dirFound = fileList.FindNextFile();
tmpFile = fileList.GetFileName();
if (fileList.IsDirectory() && !(tmpFile == "." || tmpFile == ".."))
{
CString localeName = GetLocaleName(tmpFile);
curWidget->options.value[i] = new char[localeName.GetLength()+1];
strcpy(curWidget->options.value[i], (char *)(LPCTSTR) localeName);
i++;
}
}
curWidget->numOfOptions = i;
fileList.Close();
}
CString CInterpret::replaceVars(CString str, char *listval)
{
char *theStr = (char *) (LPCTSTR) str;
@ -1142,6 +1168,29 @@ BOOL CInterpret::interpret(CString cmds, WIDGET *curWidget)
GenerateList(pcmd, w, p2path);
}
}
else if (strcmp(pcmd, "GenerateLocaleNameList") == 0)
{
// Generate the list of all subdirectories in the specified
// path and display the pretty locale names of the directories
// in the widget
char *p2 = strchr(parms, ',');
if (p2)
*p2++ = '\0';
CString value = replaceVars(parms, NULL);
WIDGET *w;
if (strcmp(parms, "self") == 0)
w = curWidget;
else
w = findWidget(parms);
if (w)
{
CString parentDirPath = replaceVars(p2,NULL);
GenerateLocaleNameList(w, parentDirPath);
}
}
else if (strcmp(pcmd, "CreateDirs") == 0)
{
WIDGET *wid = findWidget("BlobinstallerPath");

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

@ -41,6 +41,7 @@ public:
BOOL BrowseFile(WIDGET *curWidget);
CString BrowseDir(WIDGET *curWidget);
void GenerateList(CString action, WIDGET* curWidget, CString ext);
void GenerateLocaleNameList(WIDGET *curWidget, CString parentDirPath);
BOOL Progress(); // Not actually used right now
BOOL ShowSection(WIDGET *curWidget);
BOOL IterateListBox(char *parms);

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

@ -142,7 +142,7 @@ int GenerateComponentList(CString parms, WIDGET *curWidget)
nscpxpiPath;
CString curVersion = GetGlobal("Version");
CString curPlatform = GetGlobal("lPlatform");
CString curLanguage = GetGlobal("Language");
CString curLanguage = GetLocaleCode(GetGlobal("Language"));
CString localePath = rootPath+"Version\\"+curVersion+"\\"+curPlatform+"\\"+curLanguage;
if (SearchPath(workspacePath, "NSCPXPI", NULL, 0, NULL, NULL))

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

@ -2,6 +2,7 @@
#include "WizardTypes.h"
#include "winbase.h" // for CopyDir
#include <direct.h>
#include <fstream.h>
__declspec(dllexport) WIDGET GlobalWidgetArray[1000];
__declspec(dllexport) int GlobalArrayIndex=0;
@ -356,6 +357,101 @@ void PopulateNscpxpi(CString rootPath, CString platformInfo,
}
}
__declspec(dllexport)
CString GetLocaleName(CString localeCode)
{
/*
Gets the pretty locale name given the locale code
Reads the browser region.properties and language.properties files to
get the pretty region name and pretty language name respectively and
finally returns the pretty locale name
For example, return 'English-United States (enus)' given 'enus'
*/
CString rootPath, languageFile, regionFile, langCode, regCode,
langName,regName, localeName;
int langlen, reglen;
char buffer[MIN_SIZE];
rootPath = GetGlobal("Root");
strVersion = GetGlobal("Version");
languageFile = rootPath + "Version\\"+strVersion+"\\Windows\\enus\\"
"languageNames.properties";
regionFile = rootPath + "Version\\"+strVersion+"\\Windows\\enus\\"
"regionNames.properties";
ifstream languageNames(languageFile);
ifstream regionNames(regionFile);
langCode = (localeCode.Left(2)) + " = ";
langlen = langCode.GetLength();
regCode = (localeCode.Right(2)) + "\t=\t";
reglen = regCode.GetLength();
if (!languageNames)
{
AfxMessageBox("Cannot open file", MB_OK);
languageNames.close();
return "";
}
while (!languageNames.eof())
{
languageNames.getline(buffer,sizeof(buffer));
CString tempstr = buffer;
int templen = tempstr.GetLength();
if ((tempstr.Find(langCode)) != -1)
{
langName = tempstr.Right(templen-langlen);
break;
}
}
if (!regionNames)
{
AfxMessageBox("Cannot open file", MB_OK);
languageNames.close();
regionNames.close();
return "";
}
while (!regionNames.eof())
{
regionNames.getline(buffer,sizeof(buffer));
CString tempstr = buffer;
int templen = tempstr.GetLength();
if ((tempstr.Find(regCode)) != -1)
{
regName = tempstr.Right(templen-reglen);
break;
}
}
if ((regName.IsEmpty()) && (!langName.IsEmpty()))
localeName = langName + " (" + localeCode + ")";
else if ((!regName.IsEmpty()) && (langName.IsEmpty()))
localeName = regName + " (" + localeCode + ")";
else if ((regName.IsEmpty()) && (langName.IsEmpty()))
localeName = "(" + localeCode + ")";
else
localeName = langName + "-" + regName + " (" + localeCode + ")";
languageNames.close();
regionNames.close();
return localeName;
}
__declspec(dllexport)
CString GetLocaleCode(CString localeName)
{
// Get the locale code given the pretty locale name
// For example, return 'enus' given 'English-United States (enus)'
int pos = localeName.Find("(");
int localelen = localeName.GetLength();
CString localeCode = localeName.Right(localelen-pos-1);
localeCode.Remove(')');
return localeCode;
}
__declspec(dllexport)
CString GetModulePath()
{

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

@ -17,5 +17,7 @@ extern "C" __declspec(dllimport) void CopyDirectory(CString source, CString dest
extern "C" __declspec(dllimport) void EraseDirectory(CString sPath);
__declspec(dllimport) CString SearchDirectory(CString dirPath, BOOL subDir, CString searchStr);
extern "C" __declspec(dllimport) void CreateDirectories(CString instblobPath);
__declspec(dllexport) CString GetLocaleCode(CString localeName);
__declspec(dllexport) CString GetLocaleName(CString localeCode);
__declspec(dllimport) CString GetModulePath();