-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
20 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,12 @@ | ||
//! Inspect macOS system for locale configuration | ||
extern crate objc_foundation; | ||
|
||
use super::{LanguageRange, Locale}; | ||
|
||
use objc::runtime::Object; | ||
use self::objc_foundation::{INSString, NSString}; | ||
use objc2_foundation::NSLocale; | ||
|
||
pub fn system_locale() -> Option<Locale> { | ||
let locale_identifier = unsafe { | ||
let nslocale = class!(NSLocale); | ||
let current_locale: *mut Object = msg_send![nslocale, currentLocale]; | ||
let locale_identifier: *const NSString = msg_send![current_locale, localeIdentifier]; | ||
locale_identifier.as_ref() | ||
}; | ||
Some(Locale::from(LanguageRange::from_unix(locale_identifier?.as_str()).ok()?)) | ||
let current_locale = unsafe { NSLocale::currentLocale() }; | ||
let locale_identifier = unsafe { current_locale.localeIdentifier() }; | ||
Some(Locale::from( | ||
LanguageRange::from_unix(&locale_identifier.to_string()).unwrap(), | ||
)) | ||
} |