mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 02:14:43 +00:00
Bug 1616999 - Move LocaleService::IsLocaleRTL to use unic_langid. r=jfkthame
Differential Revision: https://phabricator.services.mozilla.com/D63562 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
dcb4bfbaa7
commit
739a75a9f8
@ -20,8 +20,6 @@
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "nsZipArchive.h"
|
||||
|
||||
#include "unicode/uloc.h"
|
||||
|
||||
#define INTL_SYSTEM_LOCALES_CHANGED "intl:system-locales-changed"
|
||||
|
||||
#define REQUESTED_LOCALES_PREF "intl.locale.requested"
|
||||
@ -244,7 +242,7 @@ bool LocaleService::IsLocaleRTL(const nsACString& aLocale) {
|
||||
return (pref > 0);
|
||||
}
|
||||
|
||||
return uloc_isRightToLeft(PromiseFlatCString(aLocale).get());
|
||||
return unic_langid_is_rtl(&aLocale);
|
||||
}
|
||||
|
||||
bool LocaleService::IsAppLocaleRTL() {
|
||||
|
@ -5,7 +5,7 @@
|
||||
use nsstring::nsACString;
|
||||
use nsstring::nsCString;
|
||||
use thin_vec::ThinVec;
|
||||
pub use unic_langid::{LanguageIdentifier, LanguageIdentifierError};
|
||||
pub use unic_langid::{LanguageIdentifier, LanguageIdentifierError, CharacterDirection};
|
||||
|
||||
fn new_langid_for_mozilla(name: &nsACString) -> Result<LanguageIdentifier, LanguageIdentifierError> {
|
||||
if name.eq_ignore_ascii_case(b"ja-jp-mac") {
|
||||
@ -162,3 +162,11 @@ pub unsafe extern "C" fn unic_langid_matches(
|
||||
pub unsafe extern "C" fn unic_langid_maximize(langid: &mut LanguageIdentifier) -> bool {
|
||||
langid.maximize()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn unic_langid_is_rtl(name: &nsACString) -> bool {
|
||||
match new_langid_for_mozilla(name) {
|
||||
Ok(langid) => langid.character_direction() == CharacterDirection::RTL,
|
||||
Err(_) => false
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user