mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Hooking up appLocale.
This commit is contained in:
parent
fc5fb7a36d
commit
d4b95c3193
@ -109,7 +109,7 @@ function help() {
|
||||
}
|
||||
|
||||
function strresTest() {
|
||||
var Bundle = srGetStrBundle("resource:/res/strres.properties", null);
|
||||
var Bundle = srGetStrBundle("resource:/res/strres.properties");
|
||||
var ostr1 = Bundle.GetStringFromName("file");
|
||||
dump("\n--** JS strBundle GetStringFromName file=" + ostr1 +
|
||||
"len=" + ostr1.length + "**--\n");
|
||||
|
@ -1,30 +1,57 @@
|
||||
var strBundleService = null;
|
||||
function srGetStrBundle(path, locale)
|
||||
|
||||
function srGetAppLocale()
|
||||
{
|
||||
var localeService = null;
|
||||
var applicationLocale = null;
|
||||
|
||||
localeService = Components.classes["component://netscape/intl/nslocaleservice"].createInstance();
|
||||
if (!localeService) {
|
||||
dump("\n--** localeService createInstance 1 failed **--\n");
|
||||
return null;
|
||||
}
|
||||
|
||||
localeService = localeService.QueryInterface(Components.interfaces.nsILocaleService);
|
||||
if (!localeService) {
|
||||
dump("\n--** localeService createInstance 2 failed **--\n");
|
||||
return null;
|
||||
}
|
||||
applicationLocale = localeService.GetApplicationLocale();
|
||||
if (!applicationLocale) {
|
||||
dump("\n--** localeService.GetApplicationLocale failed **--\n");
|
||||
}
|
||||
return applicationLocale;
|
||||
}
|
||||
|
||||
function srGetStrBundleWithLocale(path, locale)
|
||||
{
|
||||
var strBundle = null;
|
||||
|
||||
strBundleService =
|
||||
Components.classes["component://netscape/intl/stringbundle"].createInstance();
|
||||
|
||||
if (strBundleService) {
|
||||
strBundleService =
|
||||
strBundleService.QueryInterface(Components.interfaces.nsIStringBundleService);
|
||||
|
||||
if (strBundleService) {
|
||||
strBundle = strBundleService.CreateBundle(path, locale);
|
||||
if (!strBundle) {
|
||||
dump("\n--** strbundle createInstance failed **--\n");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
dump("\n--** strBundleService createInstance 2 **--\n");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!strBundleService) {
|
||||
dump("\n--** strBundleService createInstance 1 failed **--\n");
|
||||
return null;
|
||||
}
|
||||
|
||||
strBundleService =
|
||||
strBundleService.QueryInterface(Components.interfaces.nsIStringBundleService);
|
||||
|
||||
if (!strBundleService) {
|
||||
dump("\n--** strBundleService createInstance 2 failed **--\n");
|
||||
return null;
|
||||
}
|
||||
|
||||
strBundle = strBundleService.CreateBundle(path, locale);
|
||||
if (!strBundle) {
|
||||
dump("\n--** strBundle createInstance failed **--\n");
|
||||
}
|
||||
return strBundle;
|
||||
}
|
||||
|
||||
function srGetStrBundle(path)
|
||||
{
|
||||
var appLocale = srGetAppLocale();
|
||||
return srGetStrBundleWithLocale(path, null);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user