ags(i18n): finally use i18n system!

This commit is contained in:
retrozinndev
2025-03-09 16:04:48 -03:00
parent 59ef5e4aa7
commit 03813021a8
11 changed files with 113 additions and 44 deletions
+4 -3
View File
@@ -2,6 +2,7 @@ import { Binding } from "astal";
import { PopupWindow, PopupWindowProps } from "./PopupWindow";
import { Astal, Gtk, Widget } from "astal/gtk3";
import { Separator } from "./Separator";
import { tr } from "../i18n/intl";
export type AskPopupProps = {
title?: string | Binding<string | undefined>;
@@ -22,7 +23,7 @@ export function AskPopup(props: AskPopupProps) {
new Widget.Button({
className: "cancel",
hexpand: true,
label: props.cancelText || "Cancel",
label: props.cancelText || tr("ask_popup.options.cancel") || "Cancel",
onClick: (_) => {
window.destroy();
props.onCancel && props.onCancel();
@@ -31,7 +32,7 @@ export function AskPopup(props: AskPopupProps) {
new Widget.Button({
className: "accept",
hexpand: true,
label: props.acceptText || "Ok",
label: props.acceptText || tr("ask_popup.options.accept") || "Ok",
onClick: (_) => {
window.destroy();
props.onAccept && props.onAccept();
@@ -57,7 +58,7 @@ export function AskPopup(props: AskPopupProps) {
new Widget.Label({
className: "title",
visible: Boolean(props.title),
label: props.title || ""
label: props.title || tr("ask_popup.title") || "Question"
} as Widget.LabelProps),
Separator({
alpha: .2,
-4
View File
@@ -1,4 +0,0 @@
import { astalify, Gtk } from "astal/gtk3";
// TODO
export class FlowBox extends astalify(Gtk.FlowBox) {}
+5 -2
View File
@@ -1,6 +1,7 @@
import { Astal, Gtk, Widget } from "astal/gtk3";
import AstalNotifd from "gi://AstalNotifd";
import { Separator } from "./Separator";
import Pango from "gi://Pango";
export function getUrgencyString(notif: AstalNotifd.Notification) {
switch(notif.urgency) {
@@ -78,6 +79,7 @@ export function NotificationWidget(notification: AstalNotifd.Notification|number
new Widget.Box({
className: "text",
orientation: Gtk.Orientation.VERTICAL,
expand: true,
children: [
new Widget.Label({
className: "summary",
@@ -89,9 +91,10 @@ export function NotificationWidget(notification: AstalNotifd.Notification|number
new Widget.Label({
className: "body",
useMarkup: true,
xalign: 0,
expand: true,
halign: Gtk.Align.START,
truncate: false,
wrap: true,
wrapMode: Pango.WrapMode.WORD,
label: notification.body
} as Widget.LabelProps)
]
+2
View File
@@ -1,5 +1,6 @@
import { Gtk, Widget } from "astal/gtk3";
import AstalHyprland from "gi://AstalHyprland";
import { trGet } from "../../i18n/intl";
export function Logo(): Gtk.Widget {
return new Widget.EventBox({
@@ -8,6 +9,7 @@ export function Logo(): Gtk.Widget {
child: new Widget.Box({
child: new Widget.Label({
className: "nf",
tooltipText: trGet()["bar"]["apps"]["tooltip"],
label: ""
} as Widget.LabelProps)
} as Widget.BoxProps)
+12 -11
View File
@@ -2,8 +2,9 @@ import { bind, execAsync, Variable } from "astal";
import { Tile, TileProps } from "./Tile";
import AstalNetwork from "gi://AstalNetwork";
import { Widget } from "astal/gtk3";
import { showPages, togglePage } from "../Pages";
import { togglePage } from "../Pages";
import { PageNetwork } from "../pages/Network";
import { tr } from "../../../i18n/intl";
export const TileNetwork = new Widget.Box({
child: Variable.derive([
@@ -14,18 +15,18 @@ export const TileNetwork = new Widget.Box({
(primary: AstalNetwork.Primary, wired: AstalNetwork.Wired, wifi: AstalNetwork.Wifi) => {
if(primary === AstalNetwork.Primary.WIFI) {
return Tile({
title: "Wireless",
title: tr("control_center.tiles.network.wireless") || "Wireless",
description: Variable.derive(
[ bind(wifi, "ssid"), bind(wifi, "internet") ],
(ssid: string, internet: AstalNetwork.Internet) =>
ssid ? ssid : (() => {
switch(internet) {
case AstalNetwork.Internet.CONNECTED:
return "Connected";
return tr("control_center.tiles.network.connected") || "Connected";
case AstalNetwork.Internet.DISCONNECTED:
return "Disconnected";
return tr("control_center.tiles.network.disconnected") || "Disconnected";
case AstalNetwork.Internet.CONNECTING:
return "Connecting...";
return tr("control_center.tiles.network.connecting") + "..." || "Connecting...";
}
})()
)(),
@@ -39,15 +40,15 @@ export const TileNetwork = new Widget.Box({
} else if(primary === AstalNetwork.Primary.WIRED) {
return Tile({
title: "Wired",
title: tr("control_center.tiles.network.wired") || "Wired",
description: bind(wired, "internet").as((internet: AstalNetwork.Internet) => {
switch(internet) {
case AstalNetwork.Internet.CONNECTED:
return "Connected";
return tr("control_center.tiles.network.connected") || "Connected";
case AstalNetwork.Internet.DISCONNECTED:
return "Disconnected";
return tr("control_center.tiles.network.disconnected") || "Disconnected";
case AstalNetwork.Internet.CONNECTING:
return "Connecting...";
return tr("control_center.tiles.network.connecting") + "..." || "Connecting...";
}
}),
onToggledOn: () => execAsync("nmcli n on"),
@@ -72,8 +73,8 @@ export const TileNetwork = new Widget.Box({
}
return Tile({
title: "Network",
description: "Disconnected",
title: tr("control_center.tiles.network.network") || "Network",
description: tr("control_center.tiles.network.disconnected") || "Disconnected",
onToggledOn: () => execAsync("nmcli n on"),
onToggledOff: () => execAsync("nmcli n off"),
onClickMore: () => togglePage(PageNetwork),
+3 -2
View File
@@ -1,13 +1,14 @@
import { Tile, TileProps } from "./Tile";
import { Recording } from "../../../scripts/recording";
import { bind } from "astal";
import { tr } from "../../../i18n/intl";
export const TileRecording = Tile({
title: "Screen Recording",
title: tr("control_center.tiles.recording.title") || "Screen Recording",
description: bind(Recording.getDefault(), "recording").as(
(isRecording: boolean) => isRecording ?
"Recording {time}"
: "Start a Screen Record"
: tr("control_center.tiles.recording.disabled_description") || "Start recording"
),
icon: "󰻂",
onToggledOff: () => Recording.getDefault().stopRecording(),
+2
View File
@@ -1,5 +1,6 @@
import { Binding, Variable } from "astal";
import { Gtk, Widget } from "astal/gtk3";
import { tr } from "../../../i18n/intl";
export type TileProps = {
className?: string | Binding<string | undefined>;
@@ -99,6 +100,7 @@ export function Tile(props: TileProps): Widget.EventBox {
className: "more icon",
visible: props.onClickMore !== undefined,
halign: Gtk.Align.END,
tooltipText: tr("control_center.tiles.more") || "More",
image: new Widget.Icon({
icon: "go-next-symbolic",
css: "icon { font-size: 16px; }"