Olivier Sirven wrote:
> Rod Whiteley a �crit:
> 
>>var here = Components
>>   .classes["@mozilla.org/intl/nslocaleservice;1"]
>>   .getService(Components.interfaces.nsILocaleService)
>>   .getApplicationLocale()
>>   .getCategory("NSILOCALE_CTYPE");
> 
> 
> Correction: it works in javascript console of mozilla but when i am trying
> to use it in an installation script (install.js) it doesn't: the
> "Components" object is undefined.....any idea ?

I don't think there's currently a way to get the locale inside an install
script. You could set up your site to guess the locale (from the user
agent?) and pass it in as an argument:

  InstallTrigger.startSoftwareInstall("my.xpi?locale=" + localeFromUser);

I used startSoftwareInstall for simplicity, the same applies to the other
forms or even raw links. The string after the '?' is available to the script
in the variable "Install.arguments", or simply "arguments" since Install is
the global object.

This comes in as a string, not a String, so to take advantage of the useful
methods of the String class your script will have to do something like

  var args = new String(Install.arguments);

It's just a raw string, put anything you like there. The standard cgi arg
syntax is a good bet for familiarity, extensibility.

If you're hosted on a server that requires URL arguments to download the xpi
then hopefully you can still add extra arguments that the server will
ignore. The whole thing will still be available to the script as "arguments"
so you script should look for the values it's expecting but ignore extra params.

-Dan Veditz
_______________________________________________
Mozilla-xpinstall mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-xpinstall

Reply via email to