improv: support localization

This commit is contained in:
Eduardo Flores 2024-11-09 20:54:51 +01:00
parent 861ae6545f
commit 7d1c3bdcd5
2 changed files with 22 additions and 24 deletions

View file

@ -72,7 +72,7 @@ impl cosmic::Application for App {
.developers([("Michael Murphy", "mmstick@system76.com")]) .developers([("Michael Murphy", "mmstick@system76.com")])
.links([ .links([
("Website", "https://system76.com/cosmic"), ("Website", "https://system76.com/cosmic"),
("Repository", "https://github.com/pop-os/libcosmic)"), ("Repository", "https://github.com/pop-os/libcosmic"),
("Support", "https://github.com/pop-os/libcosmic/issues"), ("Support", "https://github.com/pop-os/libcosmic/issues"),
]); ]);

View file

@ -1,5 +1,3 @@
use iced_widget::tooltip::Position;
use license::License;
#[cfg(feature = "desktop")] #[cfg(feature = "desktop")]
use { use {
crate::{ crate::{
@ -7,7 +5,7 @@ use {
widget::{self, horizontal_space}, widget::{self, horizontal_space},
Element, Element,
}, },
std::collections::BTreeMap, license::License,
}; };
#[derive(Debug, Default, Clone, derive_setters::Setters)] #[derive(Debug, Default, Clone, derive_setters::Setters)]
@ -30,28 +28,28 @@ pub struct About {
license: Option<String>, license: Option<String>,
/// Artists who contributed to the application. /// Artists who contributed to the application.
#[setters(skip)] #[setters(skip)]
artists: BTreeMap<String, String>, artists: Vec<(String, String)>,
/// Designers who contributed to the application. /// Designers who contributed to the application.
#[setters(skip)] #[setters(skip)]
designers: BTreeMap<String, String>, designers: Vec<(String, String)>,
/// Developers who contributed to the application. /// Developers who contributed to the application.
#[setters(skip)] #[setters(skip)]
developers: BTreeMap<String, String>, developers: Vec<(String, String)>,
/// Documenters who contributed to the application. /// Documenters who contributed to the application.
#[setters(skip)] #[setters(skip)]
documenters: BTreeMap<String, String>, documenters: Vec<(String, String)>,
/// Translators who contributed to the application. /// Translators who contributed to the application.
#[setters(skip)] #[setters(skip)]
translators: BTreeMap<String, String>, translators: Vec<(String, String)>,
/// Links associated with the application. /// Links associated with the application.
#[setters(skip)] #[setters(skip)]
links: BTreeMap<String, String>, links: Vec<(String, String)>,
} }
impl<'a> About { impl<'a> About {
/// Artists who contributed to the application. /// Artists who contributed to the application.
pub fn artists(mut self, artists: impl Into<BTreeMap<&'a str, &'a str>>) -> Self { pub fn artists(mut self, artists: impl Into<Vec<(&'a str, &'a str)>>) -> Self {
let artists: BTreeMap<&'a str, &'a str> = artists.into(); let artists: Vec<(&'a str, &'a str)> = artists.into();
self.artists = artists self.artists = artists
.into_iter() .into_iter()
.map(|(k, v)| (k.to_string(), format!("mailto:{v}"))) .map(|(k, v)| (k.to_string(), format!("mailto:{v}")))
@ -60,8 +58,8 @@ impl<'a> About {
} }
/// Designers who contributed to the application. /// Designers who contributed to the application.
pub fn designers(mut self, designers: impl Into<BTreeMap<&'a str, &'a str>>) -> Self { pub fn designers(mut self, designers: impl Into<Vec<(&'a str, &'a str)>>) -> Self {
let designers: BTreeMap<&'a str, &'a str> = designers.into(); let designers: Vec<(&'a str, &'a str)> = designers.into();
self.designers = designers self.designers = designers
.into_iter() .into_iter()
.map(|(k, v)| (k.to_string(), format!("mailto:{v}"))) .map(|(k, v)| (k.to_string(), format!("mailto:{v}")))
@ -70,8 +68,8 @@ impl<'a> About {
} }
/// Developers who contributed to the application. /// Developers who contributed to the application.
pub fn developers(mut self, developers: impl Into<BTreeMap<&'a str, &'a str>>) -> Self { pub fn developers(mut self, developers: impl Into<Vec<(&'a str, &'a str)>>) -> Self {
let developers: BTreeMap<&'a str, &'a str> = developers.into(); let developers: Vec<(&'a str, &'a str)> = developers.into();
self.developers = developers self.developers = developers
.into_iter() .into_iter()
.map(|(k, v)| (k.to_string(), format!("mailto:{v}"))) .map(|(k, v)| (k.to_string(), format!("mailto:{v}")))
@ -80,8 +78,8 @@ impl<'a> About {
} }
/// Documenters who contributed to the application. /// Documenters who contributed to the application.
pub fn documenters(mut self, documenters: impl Into<BTreeMap<&'a str, &'a str>>) -> Self { pub fn documenters(mut self, documenters: impl Into<Vec<(&'a str, &'a str)>>) -> Self {
let documenters: BTreeMap<&'a str, &'a str> = documenters.into(); let documenters: Vec<(&'a str, &'a str)> = documenters.into();
self.documenters = documenters self.documenters = documenters
.into_iter() .into_iter()
.map(|(k, v)| (k.to_string(), format!("mailto:{v}"))) .map(|(k, v)| (k.to_string(), format!("mailto:{v}")))
@ -90,8 +88,8 @@ impl<'a> About {
} }
/// Translators who contributed to the application. /// Translators who contributed to the application.
pub fn translators(mut self, translators: impl Into<BTreeMap<&'a str, &'a str>>) -> Self { pub fn translators(mut self, translators: impl Into<Vec<(&'a str, &'a str)>>) -> Self {
let translators: BTreeMap<&'a str, &'a str> = translators.into(); let translators: Vec<(&'a str, &'a str)> = translators.into();
self.translators = translators self.translators = translators
.into_iter() .into_iter()
.map(|(k, v)| (k.to_string(), format!("mailto:{v}"))) .map(|(k, v)| (k.to_string(), format!("mailto:{v}")))
@ -100,11 +98,11 @@ impl<'a> About {
} }
/// Links associated with the application. /// Links associated with the application.
pub fn links(mut self, links: impl Into<BTreeMap<&'a str, &'a str>>) -> Self { pub fn links<T: Into<String>>(mut self, links: impl Into<Vec<(T, &'a str)>>) -> Self {
let links: BTreeMap<&'a str, &'a str> = links.into(); let links: Vec<(T, &'a str)> = links.into();
self.links = links self.links = links
.into_iter() .into_iter()
.map(|(k, v)| (k.to_string(), v.to_string())) .map(|(k, v)| (k.into(), v.to_string()))
.collect(); .collect();
self self
} }
@ -128,7 +126,7 @@ pub fn about<'a, Message: Clone + 'static>(
) -> Element<'a, Message> { ) -> Element<'a, Message> {
let spacing = crate::theme::active().cosmic().spacing; let spacing = crate::theme::active().cosmic().spacing;
let section = |list: &'a BTreeMap<String, String>, title: &'a str| { let section = |list: &'a Vec<(String, String)>, title: &'a str| {
(!list.is_empty()).then_some({ (!list.is_empty()).then_some({
let developers: Vec<Element<Message>> = let developers: Vec<Element<Message>> =
list.iter() list.iter()