Skip to content
Merged
Changes from all commits
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
13 changes: 12 additions & 1 deletion packages/apple-llm/ios/utils/AppleUtils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,19 @@ + (NSString *)moduleName {
return std::make_shared<react::NativeAppleUtilsSpecJSI>(params);
}

// A BCP 47 code such as en-US or zh-Hans-CN. The locale identifier can carry
// keywords such as "@rg=plzzzz" (when language and region differ), which
// AVSpeechSynthesisVoice and other APIs taking a language code do not accept
- (NSString *)getCurrentLocale {
return [NSLocale currentLocale].localeIdentifier;
NSLocale *locale = [NSLocale currentLocale];
NSMutableArray<NSString *> *parts = [NSMutableArray arrayWithObject:locale.languageCode];
if (locale.scriptCode != nil) {
[parts addObject:locale.scriptCode];
}
if (locale.countryCode != nil) {
[parts addObject:locale.countryCode];
}
return [parts componentsJoinedByString:@"-"];
}

@end
Loading