+ //! Implementations of `Localize` for various string types
+
+ use crate::Localize;
+ use std::borrow::Cow;
+
+ use duplicate::duplicate_item;
+ use icu_locid::{langid, LanguageIdentifier};
+
+ #[duplicate_item(
+ type_name;
+ [String];
+ [&str];
+ [Box<str>];
+ [Cow<'_, str>];
+ )]
+ impl<W: std::io::Write> Localize<W> for type_name {
+ const CANONICAL_LOCALE: LanguageIdentifier = langid!("en-US");
+
+ fn available_locales(&self) -> Vec<LanguageIdentifier> {
+ // TODO: keep track of all locales with Fluent data, and return only those
+ vec![<Self as Localize<W>>::CANONICAL_LOCALE]
+ }
+
+ fn message_for_locale(
+ &self,
+ writer: &mut W,
+ _locale: &LanguageIdentifier,
+ ) -> Result<(), crate::LocalizationError> {
+ writer.write_all(self.as_bytes())?;
+ Ok(())
+ }
+ }