mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-01 02:36:14 -05:00
Reorder imports, remove p
, use ext
, use json.load(f)
This commit is contained in:
parent
52d16d21f7
commit
301465a49a
@ -17,17 +17,19 @@ GNU General Public License for more details.
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
"""
|
"""
|
||||||
import json, locale, os
|
import json
|
||||||
|
import locale
|
||||||
|
import os
|
||||||
|
|
||||||
strings = {}
|
strings = {}
|
||||||
|
|
||||||
|
|
||||||
def load_strings(common, default="en"):
|
def load_strings(common, default="en"):
|
||||||
"""
|
"""
|
||||||
Loads translated strings and fallback to English
|
Loads translated strings and fallback to English
|
||||||
if the translation does not exist.
|
if the translation does not exist.
|
||||||
"""
|
"""
|
||||||
global strings
|
global strings
|
||||||
p = common.get_platform()
|
|
||||||
|
|
||||||
# find locale dir
|
# find locale dir
|
||||||
locale_dir = common.get_resource_path('locale')
|
locale_dir = common.get_resource_path('locale')
|
||||||
@ -37,10 +39,9 @@ def load_strings(common, default="en"):
|
|||||||
for filename in os.listdir(locale_dir):
|
for filename in os.listdir(locale_dir):
|
||||||
abs_filename = os.path.join(locale_dir, filename)
|
abs_filename = os.path.join(locale_dir, filename)
|
||||||
lang, ext = os.path.splitext(filename)
|
lang, ext = os.path.splitext(filename)
|
||||||
if abs_filename.endswith('.json'):
|
if ext == '.json':
|
||||||
with open(abs_filename, encoding='utf-8') as f:
|
with open(abs_filename, encoding='utf-8') as f:
|
||||||
lang_json = f.read()
|
translations[lang] = json.load(f)
|
||||||
translations[lang] = json.loads(lang_json)
|
|
||||||
|
|
||||||
strings = translations[default]
|
strings = translations[default]
|
||||||
lc, enc = locale.getdefaultlocale()
|
lc, enc = locale.getdefaultlocale()
|
||||||
|
Loading…
Reference in New Issue
Block a user