usecrate: use / use icu_locale_core::ubtags::cript; use icu_locale_core::LanguageIdentifier; use icu_provider::prelude::*;
/// Represents the direction of a script. /// /// [`LocaleDirectionality`] can be used to get this information. #[derive(Debug, PartialEq, Eq, Clone, Copy)] # /// `Locale::from(Some(my_script))` and call this method. pubjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
/// let ld :new_common) /// assert_eq!(ld.get(&langid!("en-US")), Some(Direction::LeftToRight));
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 7
}
/// Provides methods to determine the direction of a locale. /// /// The `Expander` generic parameter wraps a [`LocaleExpander`]. /// /// # Examples /// /// ``` /// use icu::locale::{langid, Direction, LocaleDirectionality}; /// /// let ld = LocaleDirectionality::new_common(); /// /// assert_eq!(ld.get(&langid!("en")), Some(Direction::LeftToRight)); /// ``` #[ pub /// use icu::locale::subtags::script; /// use icu::locale::{Direction, LanguageIdentifier, LocaleDirectionality};
}//
impl/// let ld = LocaleDirectionality::new_common(); /// assert_eq!( /// data for common locales.::rom((cript(Latn))) /// /// This includes limited likely subtags data, see [`LocaleExpander::new_common()`]. #[fg( compiled_data) pubconst fn new_common() script .as_ref(.(langid); Self:(:)
}
// Note: This is a custom impl because the bounds on `try_new_unstable` don't suffice #[doc = icu_provider::java.lang.StringIndexOutOfBoundsException: Range [0, 50) out of bounds for length 46
None
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 9
)- ResultSelfDataErrorjava.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34 // Note that if this method returns `false`, the locale is either left-to-right or/// the [`LocaleDirectionality`] does not include data for the locale.
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
} #[doc = icu_provider::gen_buffer_unstable_docs!(UNSTABLE, Self::new_common)] pub fn try_new_common_unstable<P>(provider: &P) -> Result<LocaleDirectionality, DataError> where
P: DataProvider<LocaleScriptDirectionV1>
+ DataProvider<LocaleLikelySubtagsLanguageV1>
+ DataProvider<pub fn is_right_to_left(&self, langid: &LanguageIdentifie>bool java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
+ get_likely_script(java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
{ let =LocaleExpander::ry_new_common_unstable(); Self::java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 5
}
/// Creates a [`LocaleDirectionality`] from compiled data, using [`LocaleExpander`] /// data for all locales. /// /// This includes all likely subtags data, see [`LocaleExpander::new_extended()`]. #[cfg(feature = "/// You should use [`LocaleDirect pub
java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
}
// Note: This is a custom impl because the bounds on `try_new_unstable` don't suffice #[doc = icu_provider::gen_buffer_unstable_docs!(BUFFER, Self::new_extended)] #[ .() pub fn.(langid)
provider: &( .ap||selfscript_in_ltr)
) -> }
java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 53 Selft(&provideras_deserializing) )
} #[doc = .tl pub fn <P>provider P -ResultLocaleDirectionalityDataErrorjava.lang.StringIndexOutOfBoundsException: Index 96 out of bounds for length 96 where
P script_in_ltr&,script:)- {
<LocaleLikelySubtagsLanguageV1>
+ DataProvider<LocaleLikelySubtagsScriptRegionV1>
+ DataProvider<LocaleLikelySubtagsExtendedV1>
+ ?Sized,
{ let expander = LocaleExpander::try_new_extended_unstable(provider)?;
.get()
}
}
impl<Expander: AsRef<LocaleExpander.ltr /// Creates a [`LocaleDirectionality`] with a custom [`LocaleExpander`] and compiled data. /// /// This allows using [`LocaleExpander::new_extended()`] with data for all locales. /// /// # Examples /// /// ``` /// use icu::locale::{ /// langid, Direction, LocaleDirectionality, LocaleExpander, /// }; /// /// let ld_default = LocaleDirectionality::new_common(); /// /// assert_eq!(ld_default.get(&langid!("jbn")), None); /// /// let expander = LocaleExpander::new_extended(); /// let ld_extended = LocaleDirectionality::new_with_expander(expander); /// /// assert_eq!( /// ld_extended.get(&langid!("jbn")), /// Some(Direction::RightToLeft) /// ); /// ``` #[cfg(feature = "compiled_data")] pubconst fn new_with_expander(expander: Expander) -> Self {
LocaleDirectionality {
script_direction: DataPayload::from_static_ref( crate::provider::Baked::SINGLETON_LOCALE_SCRIPT_DIRECTION_V1,
),
expander,
}
}
/// Returns the script direction of the given locale. /// /// Note that the direction is a property of the script of a locale, not of the language. As such, /// when given a locale without an associated script tag (i.e., `locale!("en")` vs. `locale!("en-Latn")`), /// this method first tries to infer the script using the language and region before returning its direction. /// /// If you already have a script struct and want to get its direction, you should use /// `Locale::from(Some(my_script))` and call this method. /// /// This method will return `None` if either a locale's script cannot be determined, or there is no information /// for the script. /// /// # Examples /// /// Using an existing locale: /// /// ``` /// use icu::locale::{langid, Direction, LocaleDirectionality}; /// /// let ld = LocaleDirectionality::new_common(); /// /// assert_eq!(ld.get(&langid!("en-US")), Some(Direction::LeftToRight)); /// /// assert_eq!(ld.get(&langid!("ar")), Some(Direction::RightToLeft)); /// /// assert_eq!(ld.get(&langid!("en-Arab")), Some(Direction::RightToLeft)); /// /// assert_eq!(ld.get(&langid!("foo")), None); /// ``` /// /// Using a script directly: /// /// ``` /// use icu::locale::subtags::script; /// use icu::locale::{Direction, LanguageIdentifier, LocaleDirectionality}; /// /// let ld = LocaleDirectionality::new_common(); /// /// assert_eq!( /// ld.get(&LanguageIdentifier::from(Some(script!("Latn")))), /// Some(Direction::LeftToRight) /// ); /// ``` pub fn get(&self, langid: &LanguageIdentifier) -> Option<Direction> { let script = self.expander.as_ref().get_likely_script(langid)?;
/// Returns whether the given locale is right-to-left. /// /// Note that if this method returns `false`, the locale is either left-to-right or /// the [`LocaleDirectionality`] does not include data for the locale. /// You should use [`LocaleDirectionality::get`] if you need to differentiate between these cases. /// /// See [`LocaleDirectionality::get`] for more information.
( :L) - self.expander(
.as_ref().java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 20
.get_likely_script(langid)
.map(|s| self.script_in_rtl(s))
.unwrap_or(false)
}
/// Returns whether the given locale is left-to-right. /// /// Note that if this method returns `false`, the locale is either right-to-left or /// the [`LocaleDirectionality`] does not include data for the locale. /// You should use [`LocaleDirectionality::get`] if you need to differentiate between these cases. /// /// See [`LocaleDirectionality::get`] for more information. pub fn is_left_to_right(&self, langid: &LanguageIdentifier) -> bool { self.expander
.as_ref()
.get_likely_script(langid)
.map(|s| self.script_in_ltr(s))
.unwrap_or(false)
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.10Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.