Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#541 closed enhancement (fixed)

Option to force use of English (or any arbitrary locale?) in bibliographies

Reported by: dstillman Owned by: dstillman
Priority: minor Milestone: 1.5 Beta 1
Component: export Version: 1.5
Keywords: localization Cc: simon, stakats

Description

From http://forums.zotero.org/discussion/441/:

I would like to generate my bibliography in english. At the moment, the bibliography contains the dutch expression 'en anderen' instead of the desired 'et al.'

I'm not totally clear on how the locale-handling works in cite.js, but along with a pref to force the locale, we presumably also need a way of accessing a specific locales.xml file. The easiest thing to do would probably be to just have the pref to force English and say to use a different localized Firefox to generate bibliographies in another language. Otherwise, I guess we could move the locales.xml file out of the locale directories and into a common directory and just include the locale in the filename, e.g. locales-en-US.xml. That would probably be the most flexible solution.

The other possibly involved issue here is that Zotero.locale, from getLocaleComponentForUserAgent(), seems to use the system locale, not the Firefox locale. I don't think we want to do anything based on the system locale (as it's returning en-US for me even if I use a German locale). Even getApplicationLocale().getCategory("NSILOCALE_MESSAGES") is returning 'en-US' for me, which seems totally wrong.

I can get the application locale with the following code:

var ph = Components.classes["@mozilla.org/network/protocol;1?name=http"].getService(Components.interfaces.nsIHttpProtocolHandler);
if (ph.language.length == 2) {
   this.locale = ph.language + '-' + ph.language.toUpperCase();
}
else {
   this.locale = ph.language;
}

nsIHTTPPH.language is the same as navigator.language. It returns a two-character code if the language and country code are the same ('de-DE' returns just 'de') and a five-character code otherwise (e.g. 'en-US').

So perhaps we should use that to set Zotero.locale, move the locales.xml files to a common directory and rename them based on their locales, put in the ability to override Zotero.locale with a pref, and grab the appropriate locales-*.xml file, falling back to English (locales-en-US.xml) if a string isn't available.

Simon, if that all seems reasonable, I can take care of the pref/Zotero.locale/locales*.xml part if you want, leaving you the cite.js part.

Change History (4)

comment:1 Changed 10 years ago by dstillman

(In [1337]) Addresses #541, Option to force use of English (or any arbitrary locale?) in bibliographies

Set Zotero.locale based on the locale of the Firefox build rather than the system locale

comment:2 Changed 9 years ago by dstillman

  • Cc simon stakats added
  • Milestone set to 1.5 Alpha 1
  • Owner changed from simon to dstillman
  • Status changed from new to assigned
  • Version changed from 1.0 to 1.5

I'll take care of the locales*.xml part and pass this back to you for cite.js (if it's non-obvious), Simon.

comment:3 Changed 9 years ago by dstillman

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [1781]) Closes #541, Option to force use of English (or any arbitrary locale?) in bibliographies

For now, via hidden pref, extensions.zotero.export.bibliographyLocale -- we'll add it to the UI in 1.5

comment:4 Changed 9 years ago by dstillman

UI front-end is #800

Note: See TracTickets for help on using tickets.