~ubuntu-branches/ubuntu/karmic/calibre/karmic

« back to all changes in this revision

Viewing changes to src/calibre/ebooks/mobi/langcodes.py

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-30 12:49:41 UTC
  • mfrom: (1.3.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090730124941-qjdsmri25zt8zocn
Tags: 0.6.3+dfsg-0ubuntu1
* New upstream release. Please see http://calibre.kovidgoyal.net/new_in_6/
  for the list of new features and changes.
* remove_postinstall.patch: Update for new version.
* build_debug.patch: Does not apply any more, disable for now. Might not be
  necessary any more.
* debian/copyright: Fix reference to versionless GPL.
* debian/rules: Drop obsolete dh_desktop call.
* debian/rules: Add workaround for weird Python 2.6 setuptools behaviour of
  putting compiled .so files into src/calibre/plugins/calibre/plugins
  instead of src/calibre/plugins.
* debian/rules: Drop hal fdi moving, new upstream version does not use hal
  any more. Drop hal dependency, too.
* debian/rules: Install udev rules into /lib/udev/rules.d.
* Add debian/calibre.preinst: Remove unmodified
  /etc/udev/rules.d/95-calibre.rules on upgrade.
* debian/control: Bump Python dependencies to 2.6, since upstream needs
  it now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 
6
6
from struct import pack
7
7
 
 
8
lang_codes = {
 
9
        }
 
10
 
8
11
main_language = {
9
12
         0 : "NEUTRAL",
10
13
         54 : "AFRIKAANS",
314
317
            if lang in IANA_MOBI:
315
318
                langdict = IANA_MOBI[lang]
316
319
                break
317
 
            
 
320
 
318
321
    mcode = langdict[None]
319
322
    while len(subtags) > 0:
320
323
        subtag = subtags.pop(0)
326
329
            mcode = langdict[subtag]
327
330
            break
328
331
    return pack('>HBB', 0, mcode[1], mcode[0])
 
332
 
 
333
def mobi2iana(langcode, sublangcode):
 
334
    prefix = suffix = None
 
335
    for code, d in IANA_MOBI.items():
 
336
        for subcode, t in d.items():
 
337
            cc, cl = t
 
338
            if cc == langcode:
 
339
                prefix = code
 
340
            if cl == sublangcode:
 
341
                suffix = subcode.lower() if subcode else None
 
342
                break
 
343
        if prefix is not None:
 
344
            break
 
345
    if prefix is None:
 
346
        return 'und'
 
347
    if suffix is None:
 
348
        return prefix
 
349
    return prefix + '-' + suffix