mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Merge branch 'charlesmchen/l10nVoiceCodes'
This commit is contained in:
commit
11b8819274
|
@ -247,9 +247,39 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
phoneNumber];
|
phoneNumber];
|
||||||
TSRequest *request = [TSRequest requestWithUrl:[NSURL URLWithString:path] method:@"GET" parameters:@{}];
|
TSRequest *request = [TSRequest requestWithUrl:[NSURL URLWithString:path] method:@"GET" parameters:@{}];
|
||||||
request.shouldHaveAuthorizationHeaders = NO;
|
request.shouldHaveAuthorizationHeaders = NO;
|
||||||
|
|
||||||
|
if (transport == TSVerificationTransportVoice) {
|
||||||
|
NSString *_Nullable localizationHeader = [self voiceCodeLocalizationHeader];
|
||||||
|
if (localizationHeader.length > 0) {
|
||||||
|
[request setValue:localizationHeader forHTTPHeaderField:@"Accept-Language"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (nullable NSString *)voiceCodeLocalizationHeader
|
||||||
|
{
|
||||||
|
NSLocale *locale = [NSLocale currentLocale];
|
||||||
|
NSString *_Nullable languageCode = [locale objectForKey:NSLocaleLanguageCode];
|
||||||
|
NSString *_Nullable countryCode = [locale objectForKey:NSLocaleCountryCode];
|
||||||
|
|
||||||
|
if (!languageCode) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
OWSAssertDebug([languageCode rangeOfString:@"-"].location == NSNotFound);
|
||||||
|
|
||||||
|
if (!countryCode) {
|
||||||
|
// In the absence of a country code, just send a language code.
|
||||||
|
return languageCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
OWSAssertDebug(languageCode.length == 2);
|
||||||
|
OWSAssertDebug(countryCode.length == 2);
|
||||||
|
return [NSString stringWithFormat:@"%@-%@", languageCode, countryCode];
|
||||||
|
}
|
||||||
|
|
||||||
+ (NSString *)stringForTransport:(TSVerificationTransport)transport
|
+ (NSString *)stringForTransport:(TSVerificationTransport)transport
|
||||||
{
|
{
|
||||||
switch (transport) {
|
switch (transport) {
|
||||||
|
|
Loading…
Reference in a new issue