Skip to content

Commit

Permalink
[QuickAccent]Add support for Serbian Cyrillic (#35500)
Browse files Browse the repository at this point in the history
* **Languages.cs**
  - Add `GetDefaultLetterKeySRCyrillic` method for Serbian Cyrillic letters.
  - Add `SR_CYRL` entry to `Language` enum.
  - Update `GetDefaultLetterKey` method to include `Language.SR_CYRL`.

* **PowerAccentPage.xaml**
  - Add `ComboBoxItem` for Serbian Cyrillic in `SelectedLanguage` `ComboBox`.

* **Resources.resw**
  - Add entry for Serbian Cyrillic.

* **PowerAccentViewModel.cs**
  - Add `SR_CYRL` to the list of supported languages.
  • Loading branch information
Sirozha1337 authored and crutkas committed Oct 22, 2024
1 parent dc7c7ef commit e88b229
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/modules/poweraccent/PowerAccent.Core/Languages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public enum Language
SL,
SP,
SR,
SR_CYRL,
SV,
TK,
}
Expand Down Expand Up @@ -94,6 +95,7 @@ public static string[] GetDefaultLetterKey(LetterKey letter, Language lang)
Language.SL => GetDefaultLetterKeySL(letter), // Slovenian
Language.SP => GetDefaultLetterKeySP(letter), // Spain
Language.SR => GetDefaultLetterKeySR(letter), // Serbian
Language.SR_CYRL => GetDefaultLetterKeySRCyrillic(letter), // Serbian Cyrillic
Language.SV => GetDefaultLetterKeySV(letter), // Swedish
Language.TK => GetDefaultLetterKeyTK(letter), // Turkish
_ => throw new ArgumentException("The language {0} is not known in this context", lang.ToString()),
Expand Down Expand Up @@ -144,6 +146,7 @@ private static string[] GetDefaultLetterKeyALL(LetterKey letter)
.Union(GetDefaultLetterKeySL(letter))
.Union(GetDefaultLetterKeySP(letter))
.Union(GetDefaultLetterKeySR(letter))
.Union(GetDefaultLetterKeySRCyrillic(letter))
.Union(GetDefaultLetterKeySV(letter))
.Union(GetDefaultLetterKeyTK(letter))
.Union(GetDefaultLetterKeyAllLanguagesOnly(letter))
Expand Down Expand Up @@ -771,6 +774,19 @@ private static string[] GetDefaultLetterKeySR(LetterKey letter)
};
}

// Serbian Cyrillic
private static string[] GetDefaultLetterKeySRCyrillic(LetterKey letter)
{
return letter switch
{
LetterKey.VK_D => new[] { "ђ", "џ" },
LetterKey.VK_L => new[] { "љ" },
LetterKey.VK_N => new[] { "њ" },
LetterKey.VK_C => new[] { "ћ" },
_ => Array.Empty<string>(),
};
}

// Macedonian
private static string[] GetDefaultLetterKeyMK(LetterKey letter)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Page
<Page
x:Class="Microsoft.PowerToys.Settings.UI.Views.PowerAccentPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Expand Down Expand Up @@ -88,6 +88,7 @@
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Slovenian" />
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Spanish" />
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Serbian" />
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Serbian_Cyrillic" />
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Swedish" />
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Turkish" />
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Welsh" />
Expand Down
5 changes: 4 additions & 1 deletion src/settings-ui/Settings.UI/Strings/en-us/Resources.resw
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Expand Down Expand Up @@ -3648,6 +3648,9 @@ Activate by holding the key for the character you want to add an accent to, then
<data name="QuickAccent_SelectedLanguage_Serbian.Content" xml:space="preserve">
<value>Serbian</value>
</data>
<data name="QuickAccent_SelectedLanguage_Serbian_Cyrillic.Content" xml:space="preserve">
<value>Serbian Cyrillic</value>
</data>
<data name="QuickAccent_SelectedLanguage_Hungarian.Content" xml:space="preserve">
<value>Hungarian</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public class PowerAccentViewModel : Observable
"SL",
"SP",
"SR",
"SR_CYRL",
"SV",
"TK",
"CY",
Expand Down

0 comments on commit e88b229

Please sign in to comment.