✨ ags(i18n): finally use i18n system!
This commit is contained in:
@@ -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),
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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; }"
|
||||
|
||||
Reference in New Issue
Block a user