yoshiask / CopticChanter

2 stars 0 forks source link

Add method to get just Primary from LanguageInfo #7

Closed yoshiask closed 1 year ago

yoshiask commented 1 year ago

LanguageInfo has a property for getting the Secondary info, but no way to get just the primary info. So far, the best way to get the primary info (without mutating the original) is as follows:

  1. Copy the combined LanguageInfo using LanguageInfo.Parse(lang.Tag)
  2. Set Secondary to null on the copy

While this works, it's super clunky, and the lack of a copy constructor exacerbates the issue by requiring the LanguageInfo to be parsed again.

Proposal

Add the following to LanguageInfo:

public LanguageInfo(string language, string? region, string? variant, LanguageInfo? secondary = null);

public LanguageInfo GetPrimary();