Introduce way to dynamically map the languages, helps reduce the typing and also should "just work" if there's any new languages added
This commit is contained in:
10
db_update.py
10
db_update.py
@@ -28,6 +28,8 @@ import sqlite3
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
# todo: need to set the EOS language to en, becasuse this assumes it's being run within an English context
|
||||||
|
# Need to know what that would do if called from pyfa
|
||||||
ROOT_DIR = os.path.realpath(os.path.dirname(__file__))
|
ROOT_DIR = os.path.realpath(os.path.dirname(__file__))
|
||||||
DB_PATH = os.path.join(ROOT_DIR, 'eve.db')
|
DB_PATH = os.path.join(ROOT_DIR, 'eve.db')
|
||||||
JSON_DIR = os.path.join(ROOT_DIR, 'staticdata')
|
JSON_DIR = os.path.join(ROOT_DIR, 'staticdata')
|
||||||
@@ -85,6 +87,7 @@ def update_db():
|
|||||||
|
|
||||||
import eos.db
|
import eos.db
|
||||||
import eos.gamedata
|
import eos.gamedata
|
||||||
|
import eos.config
|
||||||
|
|
||||||
# Create the database tables
|
# Create the database tables
|
||||||
eos.db.gamedata_meta.create_all()
|
eos.db.gamedata_meta.create_all()
|
||||||
@@ -159,10 +162,9 @@ def update_db():
|
|||||||
def processEveCategories():
|
def processEveCategories():
|
||||||
print('processing evecategories')
|
print('processing evecategories')
|
||||||
data = _readData('fsd_lite', 'evecategories', keyIdName='categoryID')
|
data = _readData('fsd_lite', 'evecategories', keyIdName='categoryID')
|
||||||
_addRows(data, eos.gamedata.Category, fieldMap={
|
map = { 'categoryName_en-us': 'displayName' }
|
||||||
'categoryName_en-us': 'displayName',
|
map.update({'categoryName'+v: 'name'+v for (k, v) in eos.config.translation_mapping.items() if k != 'en_US'})
|
||||||
'categoryName_zh': 'name_zh'
|
_addRows(data, eos.gamedata.Category, fieldMap=map)
|
||||||
})
|
|
||||||
|
|
||||||
def processDogmaAttributes():
|
def processDogmaAttributes():
|
||||||
print('processing dogmaattributes')
|
print('processing dogmaattributes')
|
||||||
|
|||||||
@@ -19,7 +19,12 @@ lang = ""
|
|||||||
# Maps supported langauges to their suffix in the database
|
# Maps supported langauges to their suffix in the database
|
||||||
translation_mapping = {
|
translation_mapping = {
|
||||||
"en_US": "",
|
"en_US": "",
|
||||||
"zh_CN": "_zh"
|
"fr": "_fr",
|
||||||
|
"it": "_it",
|
||||||
|
"ja": "_ja",
|
||||||
|
"ko": "_ko",
|
||||||
|
"ru": "_ru",
|
||||||
|
"zh_CN": "_zh",
|
||||||
}
|
}
|
||||||
|
|
||||||
def set_lang(i18n_lang):
|
def set_lang(i18n_lang):
|
||||||
|
|||||||
@@ -26,8 +26,7 @@ import eos.config
|
|||||||
|
|
||||||
categories_table = Table("invcategories", gamedata_meta,
|
categories_table = Table("invcategories", gamedata_meta,
|
||||||
Column("categoryID", Integer, primary_key=True),
|
Column("categoryID", Integer, primary_key=True),
|
||||||
Column("name", String),
|
*[Column("name{}".format(lang), String) for lang in eos.config.translation_mapping.values()],
|
||||||
Column("name_zh", String),
|
|
||||||
Column("description", String), # deprecated
|
Column("description", String), # deprecated
|
||||||
Column("published", Boolean),
|
Column("published", Boolean),
|
||||||
Column("iconID", Integer))
|
Column("iconID", Integer))
|
||||||
|
|||||||
Reference in New Issue
Block a user