Generate translated desktop and metainfo files with xdgen

This commit is contained in:
Jeremy Soller 2026-02-12 15:10:18 -07:00
parent 314f11ab89
commit 36633540c2
18 changed files with 94 additions and 45 deletions

38
Cargo.lock generated
View file

@ -1471,6 +1471,7 @@ dependencies = [
"tokio", "tokio",
"two-face", "two-face",
"unicode-segmentation", "unicode-segmentation",
"xdgen",
] ]
[[package]] [[package]]
@ -2539,6 +2540,16 @@ dependencies = [
"xdg", "xdg",
] ]
[[package]]
name = "freedesktop_entry_parser"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc6d3a3635983a889f065aa9ce760384713f23a9b4a04f696f86c39a5d7a6a5a"
dependencies = [
"indexmap 2.13.0",
"nom 8.0.0",
]
[[package]] [[package]]
name = "fsevent-sys" name = "fsevent-sys"
version = "4.1.0" version = "4.1.0"
@ -8969,6 +8980,18 @@ dependencies = [
"unicase", "unicase",
] ]
[[package]]
name = "xdgen"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25af88f104f06d5aeb80c77e5eb85e6f6f355f86f6e34307a14befd716efe4bf"
dependencies = [
"fluent",
"freedesktop_entry_parser",
"unic-langid",
"xmltree",
]
[[package]] [[package]]
name = "xkbcommon" name = "xkbcommon"
version = "0.7.0" version = "0.7.0"
@ -9024,12 +9047,27 @@ dependencies = [
"bytemuck", "bytemuck",
] ]
[[package]]
name = "xml"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8aa498d22c9bbaf482329839bc5620c46be275a19a812e9a22a2b07529a642a"
[[package]] [[package]]
name = "xml-rs" name = "xml-rs"
version = "0.8.28" version = "0.8.28"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ae8337f8a065cfc972643663ea4279e04e7256de865aa66fe25cec5fb912d3f" checksum = "3ae8337f8a065cfc972643663ea4279e04e7256de865aa66fe25cec5fb912d3f"
[[package]]
name = "xmltree"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cbc04313cab124e498ab1724e739720807b6dc405b9ed0edc5860164d2e4ff70"
dependencies = [
"xml",
]
[[package]] [[package]]
name = "xmlwriter" name = "xmlwriter"
version = "0.1.0" version = "0.1.0"

View file

@ -52,6 +52,9 @@ features = ["about", "multi-window", "tokio", "winit", "surface-message"]
[target.'cfg(unix)'.dependencies] [target.'cfg(unix)'.dependencies]
fork = "0.2" fork = "0.2"
[build-dependencies]
xdgen = "0.1"
[features] [features]
default = ["dbus-config", "gvfs", "wgpu", "wayland"] default = ["dbus-config", "gvfs", "wgpu", "wayland"]
dbus-config = ["libcosmic/dbus-config"] dbus-config = ["libcosmic/dbus-config"]

24
build.rs Normal file
View file

@ -0,0 +1,24 @@
use std::{env, fs, path::PathBuf};
use xdgen::{App, Context, FluentString};
fn main() {
let id = "com.system76.CosmicEdit";
let ctx = Context::new("i18n", env::var("CARGO_PKG_NAME").unwrap()).unwrap();
let app = App::new(FluentString("cosmic-text-editor"))
.comment(FluentString("comment"))
.keywords(FluentString("keywords"));
let output = PathBuf::from("target/xdgen");
fs::create_dir_all(&output).unwrap();
fs::write(
output.join(format!("{}.desktop", id)),
app.expand_desktop(format!("res/{}.desktop", id), &ctx)
.unwrap(),
)
.unwrap();
fs::write(
output.join(format!("{}.metainfo.xml", id)),
app.expand_metainfo(format!("res/{}.metainfo.xml", id), &ctx)
.unwrap(),
)
.unwrap();
}

View file

@ -1,4 +1,6 @@
cosmic-text-editor = محرِّر نصوص COSMIC cosmic-text-editor = محرِّر نصوص COSMIC
comment = محرِّر نصوص لسطح مكتب COSMIC
keywords = نص;محرر;
new-document = مستند جديد new-document = مستند جديد
open-project = افتح مشروعًا open-project = افتح مشروعًا
todo = المهامّ todo = المهامّ

View file

@ -1,3 +1,5 @@
comment = Textový editor pro pracovní prostředí COSMIC
keywords = Text;Editor;Poznámky;
new-document = Nový dokument new-document = Nový dokument
open-project = Otevřít projekt open-project = Otevřít projekt

View file

@ -1,4 +1,5 @@
cosmic-text-editor = COSMIC Text Editor cosmic-text-editor = COSMIC Text Editor
comment = Text editor for the COSMIC desktop
new-document = New document new-document = New document
open-project = Open project open-project = Open project
todo = TODO todo = TODO

View file

@ -1,4 +1,6 @@
cosmic-text-editor = Editor de texto COSMIC cosmic-text-editor = Editor de texto COSMIC
comment = Editor de texto de escritorio COSMIC
keywords = Texto;Editor;Notas;
new-document = Nuevo documento new-document = Nuevo documento
open-project = Abrir proyecto open-project = Abrir proyecto
todo = TODO todo = TODO

View file

@ -1,4 +1,6 @@
cosmic-text-editor = COSMIC Szövegszerkesztő cosmic-text-editor = COSMIC Szövegszerkesztő
comment = Szövegszerkesztő a COSMIC asztali környezethez
keywords = szöveg;szerkesztő;
new-document = Új dokumentum new-document = Új dokumentum
open-project = Projekt megnyitása open-project = Projekt megnyitása
todo = Teendők todo = Teendők

View file

@ -1,4 +1,6 @@
cosmic-text-editor = COSMIC Text Editor cosmic-text-editor = COSMIC Text Editor
comment = Editor di testo di COSMIC
keywords = Testo;Editor;Note;Blocco;
new-document = Nuovo documento new-document = Nuovo documento
open-project = Apri progetto open-project = Apri progetto
todo = TODO todo = TODO

View file

@ -1,4 +1,6 @@
cosmic-text-editor = Edytor Tekstu COSMIC cosmic-text-editor = Edytor Tekstu COSMIC
comment = Edytor tekstu pulpitu COSMIC
keywords = Edytor;Tekstu;
new-document = Nowy dokument new-document = Nowy dokument
open-project = Otwórz projekt open-project = Otwórz projekt
todo = TODO todo = TODO

View file

@ -1,4 +1,6 @@
cosmic-text-editor = Editor de Texto COSMIC cosmic-text-editor = Editor de Texto COSMIC
comment = Editor de texto do desktop COSMIC
keywords = Texto;Editor;Notas;
new-document = Novo documento new-document = Novo documento
open-project = Abrir projeto open-project = Abrir projeto
todo = TODO todo = TODO

View file

@ -1,4 +1,5 @@
cosmic-text-editor = Текстовый редактор COSMIC cosmic-text-editor = Текстовый редактор COSMIC
comment = Текстовый редактор для оболочки COSMIC
new-document = Новый документ new-document = Новый документ
open-project = Открыть проект open-project = Открыть проект
todo = TODO todo = TODO

View file

@ -1,4 +1,6 @@
cosmic-text-editor = Textový editor COSMIC cosmic-text-editor = Textový editor COSMIC
comment = Textový editor pre pracovné prostredie COSMIC
keywords = Text;Editor;Poznámky;
new-document = Nový dokument new-document = Nový dokument
open-project = Otvoriť projekt open-project = Otvoriť projekt
todo = Úloha todo = Úloha

View file

@ -1,3 +1,5 @@
comment = Textredigerare för skrivbordsmiljön COSMIC
keywords = Text;Editor;Redigerare;
new-document = Nytt dokument new-document = Nytt dokument
open-project = Öppna projekt open-project = Öppna projekt
todo = TODO todo = TODO

View file

@ -13,11 +13,11 @@ bin-src := cargo-target-dir / 'release' / name
bin-dst := base-dir / 'bin' / name bin-dst := base-dir / 'bin' / name
desktop := APPID + '.desktop' desktop := APPID + '.desktop'
desktop-src := 'res' / desktop desktop-src := 'target/xdgen' / desktop
desktop-dst := clean(rootdir / prefix) / 'share' / 'applications' / desktop desktop-dst := clean(rootdir / prefix) / 'share' / 'applications' / desktop
metainfo := APPID + '.metainfo.xml' metainfo := APPID + '.metainfo.xml'
metainfo-src := 'res' / metainfo metainfo-src := 'target/xdgen' / metainfo
metainfo-dst := clean(rootdir / prefix) / 'share' / 'metainfo' / metainfo metainfo-dst := clean(rootdir / prefix) / 'share' / 'metainfo' / metainfo
icons-src := 'res' / 'icons' / 'hicolor' icons-src := 'res' / 'icons' / 'hicolor'

View file

@ -1,18 +1,6 @@
#TODO: more build-out, desktop actions, translations?
[Desktop Entry] [Desktop Entry]
Name=COSMIC Text Editor Name=COSMIC Text Editor
Name[ar]=محرِّر نصوص COSMIC Comment=Text editor for the COSMIC desktop
Name[cs]=Textový editor COSMIC
Name[zh_CN]=COSMIC
Name[pl]=Edytor Tekstu COSMIC
Name[pt_BR]=Editor de Texto
Name[hu]=COSMIC Szövegszerkesztő
Name[pt]=Editor de Texto
Name[ru]=Текстовый редактор COSMIC
Name[sk]=Textový editor COSMIC
Name[sv]=COSMIC Textredigerare
Name[es]=Editor de texto COSMIC
Name[it]=Editor di testo COSMIC
Exec=cosmic-edit %F Exec=cosmic-edit %F
Terminal=false Terminal=false
Type=Application Type=Application
@ -20,13 +8,4 @@ StartupNotify=true
MimeType=text/plain; MimeType=text/plain;
Icon=com.system76.CosmicEdit Icon=com.system76.CosmicEdit
Categories=COSMIC;Utility;TextEditor; Categories=COSMIC;Utility;TextEditor;
Keywords=Text;Editor; Keywords=Text;Editor;
Keywords[ar]=نص;محرر;
Keywords[cs]=Text;Editor;Poznámky;
Keywords[pl]=Edytor;Tekstu;
Keywords[pt_BR]=Texto;Editor;Notas;
Keywords[hu]=szöveg;szerkesztő;
Keywords[sk]=Text;Editor;Poznámky;
Keywords[sv]=Text;Editor;Redigerare;
Keywords[es]=Texto;Editor;Notas;
Keywords[it]=Testo;Editor;Note;Blocco;

View file

@ -9,27 +9,7 @@
<url type="homepage">https://github.com/pop-os/cosmic-edit</url> <url type="homepage">https://github.com/pop-os/cosmic-edit</url>
<url type="bugtracker">https://github.com/pop-os/cosmic-edit</url> <url type="bugtracker">https://github.com/pop-os/cosmic-edit</url>
<name>COSMIC Text Editor</name> <name>COSMIC Text Editor</name>
<name xml:lang="ar">محرِّر نصوص COSMIC</name>
<name xml:lang="cs">Textový editor COSMIC</name>
<name xml:lang="pl">Edytor tekstu COSMIC</name>
<name xml:lang="hu">COSMIC Szövegszerkesztő</name>
<name xml:lang="pt_BR">Editor de Texto</name>
<name xml:lang="ru">Текстовый редактор COSMIC</name>
<name xml:lang="sk">COSMIC Textový editor</name>
<name xml:lang="es">Editor de texto</name>
<name xml:lang="it">Editor di testo di COSMIC</name>
<name xml:lang="sv">COSMIC Textredigerare</name>
<summary>Text editor for the COSMIC desktop</summary> <summary>Text editor for the COSMIC desktop</summary>
<summary xml:lang="ar">محرِّر نصوص لسطح مكتب COSMIC</summary>
<summary xml:lang="cs">Textový editor pro pracovní prostředí COSMIC</summary>
<summary xml:lang="pl">Edytor tekstu pulpitu COSMIC</summary>
<summary xml:lang="hu">Szövegszerkesztő a COSMIC asztali környezethez</summary>
<summary xml:lang="pt_BR">Editor de texto do desktop COSMIC</summary>
<summary xml:lang="ru">Текстовый редактор для оболочки COSMIC</summary>
<summary xml:lang="sk">Textový editor pre pracovné prostredie COSMIC</summary>
<summary xml:lang="es">Editor de texto de escritorio COSMIC</summary>
<summary xml:lang="it">Editor di testo di COSMIC</summary>
<summary xml:lang="sv">Textredigerare för skrivbordsmiljön COSMIC</summary>
<description> <description>
<p>Text editor that provides advanced features with high performance</p> <p>Text editor that provides advanced features with high performance</p>
<p xml:lang="ar">محرِّر نصوص يوفر ميزات متقدمة بأداء عالٍ</p> <p xml:lang="ar">محرِّر نصوص يوفر ميزات متقدمة بأداء عالٍ</p>
@ -89,6 +69,10 @@
<li xml:lang="it">Gestione Git integrata</li> <li xml:lang="it">Gestione Git integrata</li>
</ul> </ul>
</description> </description>
<keywords>
<keyword>Text</keyword>
<keyword>Editor</keyword>
</keywords>
<launchable type="desktop-id">com.system76.CosmicEdit.desktop</launchable> <launchable type="desktop-id">com.system76.CosmicEdit.desktop</launchable>
<icon type="remote" height="256" width="256">https://raw.githubusercontent.com/pop-os/cosmic-edit/master/res/icons/hicolor/256x256/apps/com.system76.CosmicEdit.svg</icon> <icon type="remote" height="256" width="256">https://raw.githubusercontent.com/pop-os/cosmic-edit/master/res/icons/hicolor/256x256/apps/com.system76.CosmicEdit.svg</icon>
<screenshots> <screenshots>

View file

@ -1451,6 +1451,7 @@ impl Application for App {
.icon(icon::from_name(Self::APP_ID)) .icon(icon::from_name(Self::APP_ID))
.version(env!("CARGO_PKG_VERSION")) .version(env!("CARGO_PKG_VERSION"))
.author("System76") .author("System76")
.comments(fl!("comment"))
.license("GPL-3.0-only") .license("GPL-3.0-only")
.developers([("Jeremy Soller", "jeremy@system76.com")]) .developers([("Jeremy Soller", "jeremy@system76.com")])
.links([ .links([