Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Quick Accent] Add new language - Math #34428

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 64 additions & 30 deletions src/modules/poweraccent/PowerAccent.Core/Languages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public enum Language
LT,
MK,
MI,
MATH,
NL,
NO,
PI,
Expand Down Expand Up @@ -81,6 +82,7 @@ public static string[] GetDefaultLetterKey(LetterKey letter, Language lang)
Language.LT => GetDefaultLetterKeyLT(letter), // Lithuanian
Language.MK => GetDefaultLetterKeyMK(letter), // Macedonian
Language.MI => GetDefaultLetterKeyMI(letter), // Maori
Language.MATH => GetDefaultLetterKeyMATH(letter), // Mathematics
Language.NL => GetDefaultLetterKeyNL(letter), // Dutch
Language.NO => GetDefaultLetterKeyNO(letter), // Norwegian
Language.PI => GetDefaultLetterKeyPI(letter), // Pinyin
Expand Down Expand Up @@ -130,6 +132,7 @@ private static string[] GetDefaultLetterKeyALL(LetterKey letter)
.Union(GetDefaultLetterKeyLT(letter))
.Union(GetDefaultLetterKeyMK(letter))
.Union(GetDefaultLetterKeyMI(letter))
.Union(GetDefaultLetterKeyMATH(letter))
.Union(GetDefaultLetterKeyNL(letter))
.Union(GetDefaultLetterKeyNO(letter))
.Union(GetDefaultLetterKeyPI(letter))
Expand Down Expand Up @@ -157,48 +160,81 @@ private static string[] GetDefaultLetterKeyAllLanguagesOnly(LetterKey letter)
{
return letter switch
{
LetterKey.VK_0 => new[] { "₀", "⁰", "↉" },
LetterKey.VK_1 => new[] { "₁", "¹", "½", "⅓", "¼", "⅕", "⅙", "⅐", "⅛", "⅑", "⅒" },
LetterKey.VK_2 => new[] { "₂", "²", "⅔", "⅖" },
LetterKey.VK_3 => new[] { "₃", "³", "¾", "⅗", "⅜" },
LetterKey.VK_4 => new[] { "₄", "⁴", "⅘" },
LetterKey.VK_5 => new[] { "₅", "⁵", "⅚", "⅝" },
LetterKey.VK_6 => new[] { "₆", "⁶" },
LetterKey.VK_7 => new[] { "₇", "⁷", "⅞" },
LetterKey.VK_8 => new[] { "₈", "⁸", "∞" },
LetterKey.VK_9 => new[] { "₉", "⁹" },
LetterKey.VK_A => new[] { "ȧ", "ǽ", "∀" },
LetterKey.VK_A => new[] { "ȧ", "ǽ" },
LetterKey.VK_B => new[] { "ḃ" },
LetterKey.VK_C => new[] { "ċ", "°C", "©", "ℂ", "∁" },
LetterKey.VK_D => new[] { "ḍ", "ḋ", "∂" },
LetterKey.VK_E => new[] { "∈", "∃", "∄", "∉", "ĕ" },
LetterKey.VK_C => new[] { "ċ", "°C", "©" },
LetterKey.VK_D => new[] { "ḍ", "ḋ" },
LetterKey.VK_E => new[] { "ĕ" },
LetterKey.VK_F => new[] { "ḟ", "°F" },
LetterKey.VK_G => new[] { "ģ", "ǧ", "ġ", "ĝ", "ǥ" },
LetterKey.VK_H => new[] { "ḣ", "ĥ", "ħ" },
LetterKey.VK_J => new[] { "ĵ" },
LetterKey.VK_K => new[] { "ķ", "ǩ" },
LetterKey.VK_L => new[] { "ļ", "₺" }, // ₺ is in VK_T for other languages, but not VK_L, so we add it here.
LetterKey.VK_M => new[] { "ṁ" },
LetterKey.VK_N => new[] { "ņ", "ṅ", "ⁿ", "ℕ", "№" },
LetterKey.VK_O => new[] { "ȯ", "∅" },
LetterKey.VK_P => new[] { "ṗ", "℗", "∏", "¶" },
LetterKey.VK_Q => new[] { "ℚ" },
LetterKey.VK_R => new[] { "ṙ", "®", "ℝ" },
LetterKey.VK_S => new[] { "ṡ", "§", "∑" },
LetterKey.VK_N => new[] { "ņ", "ṅ", "№" },
LetterKey.VK_O => new[] { "ȯ" },
LetterKey.VK_P => new[] { "ṗ", "℗", "¶" },
LetterKey.VK_R => new[] { "ṙ", "®" },
LetterKey.VK_S => new[] { "ṡ", "§" },
LetterKey.VK_T => new[] { "ţ", "ṫ", "ŧ", "™" },
LetterKey.VK_U => new[] { "ŭ" },
LetterKey.VK_V => new[] { "V̇" },
LetterKey.VK_W => new[] { "ẇ" },
LetterKey.VK_X => new[] { "ẋ", "×" },
LetterKey.VK_X => new[] { "ẋ" },
LetterKey.VK_Y => new[] { "ẏ", "ꝡ" },
LetterKey.VK_Z => new[] { "ʒ", "ǯ", "ℤ" },
LetterKey.VK_COMMA => new[] { "∙", "₋", "⁻", "–", "√" }, // – is in VK_MINUS for other languages, but not VK_COMMA, so we add it here.
LetterKey.VK_Z => new[] { "ʒ", "ǯ" },
LetterKey.VK_COMMA => new[] { "₋", "⁻", "–" }, // – is in VK_MINUS for other languages, but not VK_COMMA, so we add it here.
LetterKey.VK_PERIOD => new[] { "…", "\u0300", "\u0301", "\u0302", "\u0303", "\u0304", "\u0308", "\u030B", "\u030C" },
LetterKey.VK_MINUS => new[] { "~", "‐", "‑", "‒", "—", "―", "⁓", "−", "⸺", "⸻", "∓" },
LetterKey.VK_SLASH_ => new[] { "÷", "√" },
LetterKey.VK_DIVIDE_ => new[] { "÷", "√" },
LetterKey.VK_MULTIPLY_ => new[] { "×", "⋅" },
LetterKey.VK_PLUS => new[] { "≤", "≥", "≠", "≈", "≙", "⊕", "⊗", "∓", "≅", "≡" },
LetterKey.VK_MINUS => new[] { "‐", "‑", "‒", "—", "―", "⁓", "−", "⸺", "⸻" },
_ => Array.Empty<string>(),
};
}

// Mathematics
private static string[] GetDefaultLetterKeyMATH(LetterKey letter)
{
return letter switch
{
LetterKey.VK_0 => new[] { "₀", "⁰", "°", "∅", "↉" },
LetterKey.VK_1 => new[] { "₁", "¹", "½", "⅓", "¼", "⅕", "⅙", "⅐", "⅛", "⅑", "⅒" },
LetterKey.VK_2 => new[] { "₂", "²", "⅔", "⅖", "√" },
LetterKey.VK_3 => new[] { "₃", "³", "¾", "⅗", "⅜", "∛" },
LetterKey.VK_4 => new[] { "₄", "⁴", "⅘", "∜" },
LetterKey.VK_5 => new[] { "₅", "⁵", "⅚", "⅝" },
LetterKey.VK_6 => new[] { "₆", "⁶" },
LetterKey.VK_7 => new[] { "₇", "⁷", "⅞" },
LetterKey.VK_8 => new[] { "₈", "⁸", "∞", "∝" },
LetterKey.VK_9 => new[] { "₉", "⁹" },
LetterKey.VK_A => new[] { "α", "∀" },
LetterKey.VK_B => new[] { "β" },
LetterKey.VK_C => new[] { "χ", "ℂ", "∁" },
LetterKey.VK_D => new[] { "δ", "∂", "◇" },
LetterKey.VK_E => new[] { "ε", "η", "∃", "∄", "∈", "∉" },
LetterKey.VK_F => new[] { "φ", "ƒ" },
LetterKey.VK_G => new[] { "γ" },
LetterKey.VK_I => new[] { "ι" },
LetterKey.VK_K => new[] { "κ" },
LetterKey.VK_L => new[] { "λ" },
LetterKey.VK_M => new[] { "μ" },
LetterKey.VK_N => new[] { "ν", "ⁿ", "ℕ" },
LetterKey.VK_O => new[] { "ο", "ω" },
LetterKey.VK_P => new[] { "π", "ψ", "φ", "∏", "⊥", "⊢", "⊬" },
LetterKey.VK_Q => new[] { "ℚ" },
LetterKey.VK_R => new[] { "ρ", "ℝ" },
LetterKey.VK_S => new[] { "σ", "∑", "∫", "∮" },
LetterKey.VK_T => new[] { "θ", "τ", "⊨", "⊭" },
LetterKey.VK_U => new[] { "υ" },
LetterKey.VK_X => new[] { "ξ", "×", "⋅" },
LetterKey.VK_Y => new[] { "υ" },
LetterKey.VK_Z => new[] { "ζ", "ℤ" },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @octastylos-pseudodipteros, in the issue's comments, there were suggestions of not including the Greek alphabets as they are already included. Any reason for specifically including them here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greek letters are often used together with math symbols and even though there is a separate language for them, it is not possible to use both math and Greek letters language at the same time (if the user doesn't want to have symbols from all languages).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of issues with this understanding -

  1. The issue you're stating is open [Quick Accent] Select multiple languages #21261. It is only a matter of time before it gets implemented and this issue is resolved.
  2. If in the future, we have to change some symbols / add some (symbols/accents) in the Greek language, we would have to deal with it in two places (redundancy).

My suggestion would be to remove the Greek references from your function and pass the letter to the GetDefaultLetterKeyEL function to get the Greek references for that particular letter. You could then concatenate these in your string array and return the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a good idea, I will do it. Thank you

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @GhostVaibhav, in the new commit Math language uses Greek letters from the Greek letter alphabet, but because of this there are also letters with tonos (eg. ά, έ...), which aren't commonly used in math.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @octastylos-pseudodipteros, that should not be a major blocking issue since all the other characters would be legally used. I have other concerns with removing "π" from Portuguese.


@htcfreek the "π" symbol doesn't have any special meaning in Portuguese and this PR removes it from there. Is it allowed to change the base definitions of already defined languages?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@htcfreek thoughts?

LetterKey.VK_PLUS => new[] { "≤", "≥", "±", "⇔", "₊", "⁺", "≠", "≅", "≈", "≙", "≜", "≔", "≝", "≡", "⊕", "⊗", "⊙" },
LetterKey.VK_COMMA => new[] { "≤", "⇐", "⋃", "⋁", "⊆", "⊂", "⊄", "∌", "∋", "≪" },
LetterKey.VK_PERIOD => new[] { "≥", "⇒", "⋂", "⋀", "⊇", "⊃", "⊅", "∉", "∈", "≫" },
LetterKey.VK_SLASH_ => new[] { "÷", "‰", "½", "⅓", "⅔", "¼", "¾", "√" },
LetterKey.VK_MINUS => new[] { "∓", "~" },
LetterKey.VK_MULTIPLY_ => new[] { "×", "⋅", "^", "¬", "∴", "∵" },
LetterKey.VK_DIVIDE_ => new[] { "÷", "√", "∠", "∡", "∢", "⦝", "⦜" },
_ => Array.Empty<string>(),
};
}
Expand Down Expand Up @@ -485,10 +521,8 @@ private static string[] GetDefaultLetterKeyPT(LetterKey letter)
LetterKey.VK_E => new[] { "é", "ê", "€" },
LetterKey.VK_I => new[] { "í" },
LetterKey.VK_O => new[] { "ô", "ó", "õ", "º" },
LetterKey.VK_P => new[] { "π" },
LetterKey.VK_S => new[] { "$" },
LetterKey.VK_U => new[] { "ú" },
LetterKey.VK_COMMA => new[] { "≤", "≥", "≠", "≈", "≙", "±", "₊", "⁺" },
_ => Array.Empty<string>(),
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Lithuanian" />
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Macedonian" />
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Maori" />
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Mathematics" />
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Norwegian" />
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Pinyin" />
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Polish" />
Expand Down
3 changes: 3 additions & 0 deletions src/settings-ui/Settings.UI/Strings/en-us/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -3580,6 +3580,9 @@ Activate by holding the key for the character you want to add an accent to, then
<data name="QuickAccent_SelectedLanguage_Maori.Content" xml:space="preserve">
<value>Maori</value>
</data>
<data name="QuickAccent_SelectedLanguage_Mathematics.Content" xml:space="preserve">
<value>Mathematics</value>
</data>
<data name="QuickAccent_SelectedLanguage_Dutch.Content" xml:space="preserve">
<value>Dutch</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class PowerAccentViewModel : Observable
"LT",
"MK",
"MI",
"MATH",
"NO",
"PI",
"PL",
Expand Down
Loading