Skip to content

Commit 0dfe227

Browse files
SERVCUBEDgolf1052
authored andcommitted
Get country/region code from current culture name
Using the last 2 letters from the culture name to get the country/region code.
1 parent ca75c89 commit 0dfe227

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

Signal-Windows/Utils.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,10 @@ public static PageStyle GetViewStyle(Size s)
143143
}
144144
}
145145

146-
public static string GetCountryCode()
146+
public static string GetCountryISO()
147147
{
148-
var c = CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
149-
return GetCountryCode(c.ToUpper());
148+
var c = CultureInfo.CurrentCulture.Name;
149+
return c.Substring(c.Length - 2);
150150
}
151151

152152
public static bool ContainsCaseInsensitive(this string str, string value)

Signal-Windows/ViewModels/AddContactPageViewModel.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public async Task RefreshContacts(CancellationToken? cancellationToken = null)
130130
{
131131
contactAnnotationList = contactAnnotationLists[0];
132132
}
133-
133+
134134
foreach (var contact in contacts)
135135
{
136136
var phones = contact.Phones;
@@ -333,9 +333,7 @@ await Task.Run(() =>
333333
/// <returns>A number in E164 format</returns>
334334
private string ParsePhoneNumber(string number)
335335
{
336-
// on phone we should try to get their SIM country code
337-
// otherwise we should try to use the user's location?
338-
PhoneNumber phoneNumber = phoneNumberUtil.Parse(number, "US");
336+
PhoneNumber phoneNumber = phoneNumberUtil.Parse(number, Utils.GetCountryISO());
339337
return phoneNumberUtil.Format(phoneNumber, PhoneNumberFormat.E164);
340338
}
341339
}

0 commit comments

Comments
 (0)