Exemplo n.º 1
0
    def locale_combo_changed(self, index):
        selected_locale = self.locale_combo.currentData()
        locale_to_change = str(selected_locale)
        set_config_value('locale', locale_to_change)

        if selected_locale is None:
            preferred_locales = []

            system_locale = get_ui_locale()
            if system_locale is not None:
                preferred_locales.append(system_locale)

            negotiated_locale = Locale.negotiate(
                preferred_locales, get_available_locales(get_locale_path()))
            if negotiated_locale is None:
                locale_to_change = 'en'
            else:
                locale_to_change = str(negotiated_locale)

        self.app_locale = locale_to_change
        load_gettext_locale(get_locale_path(), locale_to_change)

        main_app = QApplication.instance()
        main_app.main_win.set_text()
        central_widget = main_app.main_win.central_widget
        main_tab = central_widget.main_tab
        game_dir_group_box = main_tab.game_dir_group_box
        update_group_box = main_tab.update_group_box

        game_dir_group_box.last_game_directory = None
        game_dir_group_box.game_directory_changed()

        update_group_box.refresh_builds()
Exemplo n.º 2
0
 def set_text(self):
     self.command_line_parameters_label.setText(
         _('Command line parameters:'))
     self.keep_launcher_open_checkbox.setText(
         _('Keep the launcher opened after launching the game'))
     self.locale_label.setText(_('Language:'))
     self.locale_combo.setItemText(
         0,
         _('System language or best match ({locale})').format(
             locale=get_ui_locale()))
     self.allow_mul_insts_checkbox.setText(
         _('Allow multiple instances of '
           'the launcher to be started'))
     self.no_launcher_version_check_checkbox.setText(
         _('Do not check '
           'for new version of the CDDA Game Launcher on launch'))
     self.setTitle(_('Launcher'))
Exemplo n.º 3
0
def get_preferred_locale(available_locales):
    preferred_locales = []

    selected_locale = get_config_value('locale', None)
    if selected_locale == 'None':
        selected_locale = None
    if selected_locale is not None:
        preferred_locales.append(selected_locale)

    system_locale = get_ui_locale()
    if system_locale is not None:
        preferred_locales.append(system_locale)

    app_locale = Locale.negotiate(preferred_locales, available_locales)
    if app_locale is None:
        app_locale = 'en'
    else:
        app_locale = str(app_locale)

    return app_locale
Exemplo n.º 4
0
def init_gettext():
    locale_dir = os.path.join(basedir, 'cddagl', 'locale')
    preferred_locales = []

    selected_locale = get_config_value('locale', None)
    if selected_locale == 'None':
        selected_locale = None
    if selected_locale is not None:
        preferred_locales.append(selected_locale)

    system_locale = get_ui_locale()
    if system_locale is not None:
        preferred_locales.append(system_locale)

    if os.path.isdir(locale_dir):
        entries = scandir(locale_dir)
        for entry in entries:
            if entry.is_dir():
                available_locales.append(entry.name)

    available_locales.sort(key=lambda x: 0 if x == 'en' else 1)

    app_locale = Locale.negotiate(preferred_locales, available_locales)
    if app_locale is None:
        app_locale = 'en'
    else:
        app_locale = str(app_locale)

    try:
        t = gettext.translation('cddagl',
                                localedir=locale_dir,
                                languages=[app_locale])
        global _
        _ = t.gettext
    except FileNotFoundError as e:
        pass

    return app_locale
Exemplo n.º 5
0
def init_gettext():
    locale_dir = os.path.join(basedir, 'cddagl', 'locale')
    preferred_locales = []

    selected_locale = get_config_value('locale', None)
    if selected_locale == 'None':
        selected_locale = None
    if selected_locale is not None:
        preferred_locales.append(selected_locale)

    system_locale = get_ui_locale()
    if system_locale is not None:
        preferred_locales.append(system_locale)

    if os.path.isdir(locale_dir):
        entries = scandir(locale_dir)
        for entry in entries:
            if entry.is_dir():
                available_locales.append(entry.name)

    available_locales.sort(key=lambda x: 0 if x == 'en' else 1)

    app_locale = Locale.negotiate(preferred_locales, available_locales)
    if app_locale is None:
        app_locale = 'en'
    else:
        app_locale = str(app_locale)

    try:
        t = gettext.translation('cddagl', localedir=locale_dir,
            languages=[app_locale])
        global _
        _ = t.gettext
    except FileNotFoundError as e:
        pass

    return app_locale
Exemplo n.º 6
0
    def __init__(self):
        super(LauncherSettingsGroupBox, self).__init__()

        layout = QGridLayout()

        command_line_parameters_label = QLabel()
        layout.addWidget(command_line_parameters_label, 0, 0, Qt.AlignRight)
        self.command_line_parameters_label = command_line_parameters_label

        command_line_parameters_edit = QLineEdit()
        command_line_parameters_edit.setText(
            get_config_value('command.params', ''))
        command_line_parameters_edit.editingFinished.connect(self.clp_changed)
        layout.addWidget(command_line_parameters_edit, 0, 1)
        self.command_line_parameters_edit = command_line_parameters_edit

        keep_launcher_open_checkbox = QCheckBox()
        check_state = (Qt.Checked if config_true(
            get_config_value('keep_launcher_open', 'False')) else Qt.Unchecked)
        keep_launcher_open_checkbox.setCheckState(check_state)
        keep_launcher_open_checkbox.stateChanged.connect(self.klo_changed)
        layout.addWidget(keep_launcher_open_checkbox, 1, 0, 1, 2)
        self.keep_launcher_open_checkbox = keep_launcher_open_checkbox

        locale_group = QWidget()
        locale_group.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
        locale_layout = QHBoxLayout()
        locale_layout.setContentsMargins(0, 0, 0, 0)

        locale_label = QLabel()
        locale_layout.addWidget(locale_label)
        self.locale_label = locale_label

        current_locale = get_config_value('locale', None)

        locale_combo = QComboBox()
        locale_combo.setSizeAdjustPolicy(QComboBox.AdjustToContents)
        locale_combo.addItem(
            _('System language or best match ({locale})').format(
                locale=get_ui_locale()), None)
        selected_index = 0
        for index, locale in enumerate(get_available_locales(
                get_locale_path())):
            if locale == current_locale:
                selected_index = index + 1
            locale = Locale.parse(locale)
            locale_name = locale.display_name
            english_name = locale.english_name
            if locale_name != english_name:
                formatted_name = f'{locale_name} - {english_name}'
            else:
                formatted_name = locale_name
            locale_combo.addItem(formatted_name, str(locale))
        locale_combo.setCurrentIndex(selected_index)
        locale_combo.currentIndexChanged.connect(self.locale_combo_changed)
        locale_layout.addWidget(locale_combo)
        self.locale_combo = locale_combo

        locale_group.setLayout(locale_layout)
        layout.addWidget(locale_group, 2, 0, 1, 2)
        self.locale_group = locale_group
        self.locale_layout = locale_layout

        allow_mul_insts_checkbox = QCheckBox()
        check_state = (Qt.Checked if config_true(
            get_config_value('allow_multiple_instances', 'False')) else
                       Qt.Unchecked)
        allow_mul_insts_checkbox.setCheckState(check_state)
        allow_mul_insts_checkbox.stateChanged.connect(self.ami_changed)
        layout.addWidget(allow_mul_insts_checkbox, 3, 0, 1, 2)
        self.allow_mul_insts_checkbox = allow_mul_insts_checkbox

        no_launcher_version_check_checkbox = QCheckBox()
        check_state = (Qt.Checked if config_true(
            get_config_value('prevent_version_check_launch', 'False')) else
                       Qt.Unchecked)
        no_launcher_version_check_checkbox.setCheckState(check_state)
        no_launcher_version_check_checkbox.stateChanged.connect(
            self.nlvcc_changed)
        layout.addWidget(no_launcher_version_check_checkbox, 4, 0, 1, 2)
        self.no_launcher_version_check_checkbox = (
            no_launcher_version_check_checkbox)

        self.setLayout(layout)
        self.set_text()