-
-
Notifications
You must be signed in to change notification settings - Fork 4
Only show relevant fields as audio dialog context #1986
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
base: develop
Are you sure you want to change the base?
Changes from all commits
4b367c9
00a2e58
60bebc3
bcb638c
416bf55
6695840
00c66bd
ee539f1
3104d0b
814973b
f233f5e
0fd4ad1
8610d28
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
using SIL.WritingSystems; | ||
|
@@ -35,6 +34,7 @@ public override void WriteAsPropertyName(Utf8JsonWriter writer, WritingSystemId | |
{ | ||
public string Code { get => field ?? "default"; init; } | ||
public bool IsAudio { get; } = false; | ||
public string? CodeWithoutScriptOrAudio { get; } | ||
|
||
public static readonly WritingSystemId Default = "default"; | ||
|
||
|
@@ -62,6 +62,19 @@ public WritingSystemId(string code) | |
Code = code; | ||
IsAudio = script?.Equals(WellKnownSubtags.AudioScript, StringComparison.OrdinalIgnoreCase) == true && | ||
variants?.Split('-').Any(v => v == WellKnownSubtags.AudioPrivateUse) == true; | ||
|
||
if ((script is not null || IsAudio) && IetfLanguageTag.TryGetSubtags(code, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TryGetSubtags appears to be expensive in some cases perhaps that's, because in some cases it requires the SLDR to be initialized. I'm not sure when that's the case, but it's not the case for any of the test cases I wrote. So, perhaps it's never the case for codes that have a script 🙃 |
||
out var langSubtag, | ||
out var scriptSubtag, | ||
out var regionSubtag, | ||
out var variantsSubtags)) | ||
{ | ||
CodeWithoutScriptOrAudio = IetfLanguageTag.Create( | ||
langSubtag, | ||
null, // remove script (e.g. Zxxxx (unwritten/audio), Latn, etc.) | ||
regionSubtag, | ||
variantsSubtags.Where(v => v.Code != WellKnownSubtags.AudioPrivateUse)); | ||
} | ||
} | ||
else | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script is only relevant to text WS's. So, if there are multiple WSs where only the script differs we show all of them.