[sword-devel] swlocale question
ransom1982 at gmail.com
Fri Sep 4 18:16:35 MST 2009
On Fri, Sep 4, 2009 at 5:59 PM, Jonathan Marsden<jmarsden at fastmail.fm> wrote:
> Matthew Talbert wrote:
>> That is, if we have 5 applications, and each has a 1-line way of doing
>> this, then that's less code than trying to do this ourselves.
> So... how does diatheke do it in one line? :)
I think you're confusing some of the issues here. With diatheke, you
have to specifically tell it which locale to use. That's fine, but
what we're after from a frontend perspective is to automatically set
the SWORD locale to match the users' environment. So the code we're
talking about will parse a locale in the format typically seen in the
LANG variable, as well as the one used for Macs, and find the closest
matching SWORD locale. The 1 line I referenced above is the amount of
code it takes us to convert from Windows-style locale variables to
something more closely matching LANG-style. glib provides this for us,
so there's no need to duplicate it.
>>> (2) Rather than only looking at LANG, ...
>> Currently, SWORD doesn't try to read any environment variables at all
>> to determine locale.
> Ah, then I misunderstood your earlier comment about "This is based off
> the environment variable LANG". If SWORD just expects the application to
> tell it what locale to use, then how the app determines the current locale
> is not directly relevant to the SWORD library itself.
Right. But what is relevant is somehow matching the user's locale with
a locale available in SWORD. That is what this code does.
> But overall I think what SWORD calls a "locale" and what the Unix/POSIX
> world calls a "locale" are not exactly the same thing anyway -- system
> locales deal with display of financial and date/time info, for example, but
> SWORD ones deal primarily (or even only?) with Bible book names and
> abbreviations :)
SWORD locales deal with displaying Bible book names and abbreviations
and also parsing the references that users enter. I'm not sure why
it's confusing. This and the Unix meaning both mean locale-specific
data, it's just that for SWORD we need more locale-specific data just
for parsing Bible references. I don't believe that's included in the
standard locales :)
> I suspect I am still slightly confused on the relationship between the two
> "locale"s. I think a wiki page about SWORD locales and how/whether they
> relate to system locales would be a good thing to have, if someone knows
> enough about both kinds of locales to write such a page. Any volunteers?
> My best guess so far is that in theory we could have:
Well, I'm still learning here as well, but I understand quite a bit
more than I did a couple of days ago. There is already some
information on the wiki for creating locale files, which could
probably be extended to explain how they work, or it could be done in
another location. You aren't the only one who has been confused about
how this all works.
> (1) A default system or OS locale
We're not really talking about this at all, at least if I understand
what you mean.
> (2) A session or Desktop environment locale
This isn't directly applicable to SWORD, but the idea is to make it
easier to find a SWORD locale to match the users' locale, by adding
code to SWORD to match up locales in the ar_EG format, or any format
where the first two characters represent a language name.
> (3) An application UI locale (could be switched on the fly by the user)
For Xiphos, GTK takes care of setting the user locale. We don't
currently offer a way to change it manually (you can do it with
environment variables if you like). What we're trying to do is find
the locale the user is in, then find a matching SWORD locale.
> (4) Multiple simultaneous module locales, one per displayed module
Xiphos doesn't do this, and I doubt we will. It might not be all that
hard, but we have lots of other feature requests outstanding, and none
so far for this. In most cases, the user will want all book names in
the same language, and will want to enter references in the same
language. I'm not saying that some wouldn't appreciate this, it's just
not on the list at the moment. Patches welcome :)
Hope that makes it clearer.
More information about the sword-devel