mirror of https://github.com/morpheus65535/bazarr
commit
b2141f4bd0
|
@ -22,6 +22,7 @@ CREATE TABLE "table_settings_providers" (
|
|||
);
|
||||
CREATE TABLE "table_settings_languages" (
|
||||
`code3` TEXT NOT NULL UNIQUE,
|
||||
`code3b` TEXT,
|
||||
`code2` TEXT,
|
||||
`name` TEXT NOT NULL,
|
||||
`enabled` INTEGER,
|
||||
|
|
|
@ -18,6 +18,13 @@ def load_language_in_db():
|
|||
c.executemany('''INSERT OR IGNORE INTO table_settings_languages(code3, code2, name) VALUES(?, ?, ?)''', langs)
|
||||
c.execute('''INSERT OR IGNORE INTO table_settings_languages(code3, code2, name) VALUES(?, ?, ?)''', ('pob','pb','Brazilian Portuguese'))
|
||||
|
||||
langs = [[lang.bibliographic,lang.alpha_3]
|
||||
for lang in pycountry.languages
|
||||
if hasattr(lang, 'alpha_2') and hasattr(lang, 'bibliographic')]
|
||||
|
||||
# Update languages in database table
|
||||
c.executemany('''UPDATE table_settings_languages SET code3b = ? WHERE code3 = ?''', langs)
|
||||
|
||||
# Commit changes to database table
|
||||
db.commit()
|
||||
|
||||
|
@ -40,7 +47,7 @@ def language_from_alpha3(lang):
|
|||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
try:
|
||||
result = c.execute('''SELECT name FROM table_settings_languages WHERE code3 = ?''', (lang,)).fetchone()[0]
|
||||
result = c.execute('''SELECT name FROM table_settings_languages WHERE code3 = ? OR code3b = ?''', (lang,lang)).fetchone()[0]
|
||||
except:
|
||||
result = None
|
||||
db.close()
|
||||
|
@ -52,7 +59,7 @@ def alpha2_from_alpha3(lang):
|
|||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
try:
|
||||
result = c.execute('''SELECT code2 FROM table_settings_languages WHERE code3 = ?''', (lang,)).fetchone()[0]
|
||||
result = c.execute('''SELECT code2 FROM table_settings_languages WHERE code3 = ? OR code3b = ?''', (lang,lang)).fetchone()[0]
|
||||
except:
|
||||
result = None
|
||||
db.close()
|
||||
|
|
|
@ -75,6 +75,11 @@ if os.path.exists(os.path.join(config_dir, 'db/bazarr.db')) == True:
|
|||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
c.execute('alter table table_settings_languages add column "code3b" "text"')
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
# Commit change to db
|
||||
db.commit()
|
||||
|
|
Loading…
Reference in New Issue