def save_keyboard_settings(locale_code, variant):
    continent, country = locale.locale_to_layout_keys(locale_code)
    continent_idx, country_idx = locale.layout_keys_to_indexes(
        continent, country
    )

    country_code = keyboard_layouts.layouts.get(continent, {}).get(country, '')
    variants = find_keyboard_variants(country_code) or []

    found = False
    idx = 0

    for idx, (variant_desc, variant_id) in enumerate(variants):
        if variant_desc == variant or variant_id == variant:
            found = True
            break

    variant_idx = idx if found else 0

    update_settings_keyboard_conf(
        continent_idx,
        country_idx,
        variant_idx,
        continent,
        country,
        variant
    )
Exemplo n.º 2
0
def save_keyboard_settings(locale_code, variant):
    continent, country = locale.locale_to_layout_keys(locale_code)
    continent_idx, country_idx = locale.layout_keys_to_indexes(
        continent, country)

    country_code = keyboard_layouts.layouts.get(continent, {}).get(country, '')
    variants = find_keyboard_variants(country_code) or []

    found = False
    idx = 0

    for idx, (variant_desc, variant_id) in enumerate(variants):
        if variant_desc == variant or variant_id == variant:
            found = True
            break

    variant_idx = idx if found else 0

    update_settings_keyboard_conf(continent_idx, country_idx, variant_idx,
                                  continent, country, variant)
Exemplo n.º 3
0
    def test_invalid_locale(self):
        continent, country = locale.locale_to_layout_keys('XXX_XX')
        self.verify_layout_keys_exist(continent, country)

        self.assertEqual(continent, self.DEFAULT_CONTINENT)
        self.assertEqual(country, self.DEFAULT_COUNTRY)
Exemplo n.º 4
0
    def test_valid_locale_europe(self):
        continent, country = locale.locale_to_layout_keys('en_GB')
        self.verify_layout_keys_exist(continent, country)

        self.assertEqual(country, 'United Kingdom')
        self.assertEqual(continent, 'europe')
Exemplo n.º 5
0
    def test_valid_locale_americas(self):
        continent, country = locale.locale_to_layout_keys('es_AR')
        self.verify_layout_keys_exist(continent, country)

        self.assertEqual(country, 'Argentina')
        self.assertEqual(continent, 'america')
Exemplo n.º 6
0
    def test_invalid_locale(self):
        continent, country = locale.locale_to_layout_keys('XXX_XX')
        self.verify_layout_keys_exist(continent, country)

        self.assertEqual(continent, self.DEFAULT_CONTINENT)
        self.assertEqual(country, self.DEFAULT_COUNTRY)
Exemplo n.º 7
0
    def test_valid_locale_europe(self):
        continent, country = locale.locale_to_layout_keys('en_GB')
        self.verify_layout_keys_exist(continent, country)

        self.assertEqual(country, 'United Kingdom')
        self.assertEqual(continent, 'europe')
Exemplo n.º 8
0
    def test_valid_locale_americas(self):
        continent, country = locale.locale_to_layout_keys('es_AR')
        self.verify_layout_keys_exist(continent, country)

        self.assertEqual(country, 'Argentina')
        self.assertEqual(continent, 'america')