#!/usr/bin/python3

# /*
#  * Copyright (C) 2020, KylinSoft Co., Ltd.
#  *
#  * This program is free software: you can redistribute it and/or modify
#  * it under the terms of the GNU General Public License as published by
#  * the Free Software Foundation, either version 3 of the License, or
#  * (at your option) any later version.
#  *
#  * This program is distributed in the hope that it will be useful,
#  * but WITHOUT ANY WARRANTY; without even the implied warranty of
#  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  * GNU General Public License for more details.
#  *
#  * You should have received a copy of the GNU General Public License
#  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
#  */

import os
import gettext

if os.path.isdir("/opt/update-module/current/usr/share/kylin-system-updater/locale"):
    LOCALE_LANGUAGE_PATH = "/opt/update-module/current/usr/share/kylin-system-updater/locale"
else:
    LOCALE_LANGUAGE_PATH = "/usr/share/kylin-system-updater/locale"

if "LANGUAGE" not in os.environ:
    os.environ["LANGUAGE"] = "zh_CN.UTF-8"

#当不存在语言变量时 默认显示中文
if "LANG" not in os.environ:
    os.environ["LANG"] = "zh_CN.UTF-8"

#做一些规范处理
if os.environ["LANGUAGE"] == "en":
    os.environ["LANGUAGE"] = "en_US.UTF-8"
if os.environ["LANGUAGE"] == "zh_CN:en" or os.environ["LANGUAGE"] == "zh_CN:zh":
    os.environ["LANGUAGE"] = "zh_CN.UTF-8"

gettext.bindtextdomain('kylin-system-updater', '/usr/share/kylin-system-updater/locale')
gettext.textdomain('kylin-system-updater')
_ = gettext.gettext