|
|
|
@ -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()
|
|
|
|
|