mirror of
https://github.com/sean1832/GPT-Brain
synced 2024-11-18 21:25:53 +00:00
fix: no language detected first launch app
This commit is contained in:
parent
23843ba979
commit
4c1794da0e
@ -3,7 +3,7 @@ import streamlit as st
|
||||
import modules.utilities as util
|
||||
|
||||
|
||||
languages = util.read_json('.locals/languages.json')
|
||||
languages = util.read_json('.locals/languages.json', default_value={'SESSION_LANGUAGE': 'en_US'})
|
||||
|
||||
|
||||
def select_language():
|
||||
|
@ -137,12 +137,12 @@ def write_json(content, filepath, mode='w', encoding='UTF-8'):
|
||||
json.dump(content, file, indent=2)
|
||||
|
||||
|
||||
def read_json(filepath):
|
||||
def read_json(filepath, encoding='UTF-8', default_value={}):
|
||||
try:
|
||||
with open(filepath, 'r', encoding='UTF-8') as file:
|
||||
with open(filepath, 'r', encoding=encoding) as file:
|
||||
return json.load(file)
|
||||
except FileNotFoundError:
|
||||
create_json_not_exist(filepath)
|
||||
create_json_not_exist(filepath, default_value)
|
||||
return {}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user