🌐 ags(i18n): translate control-center pages

This commit is contained in:
retrozinndev
2025-04-23 19:30:37 -03:00
parent cd96236878
commit e28e2c7c2f
9 changed files with 139 additions and 46 deletions
+2 -5
View File
@@ -1,12 +1,9 @@
import { GLib } from "astal"; import { GLib } from "astal";
import en_US from "./lang/en_US";
import pt_BR from "./lang/pt_BR";
const i18nKeys = { const i18nKeys = {
"en_US": en_US, "en_US": (await import("./lang/en_US")).default,
"pt_BR": pt_BR "pt_BR": (await import("./lang/pt_BR")).default
}; };
const languages: Array<string> = Object.keys(i18nKeys); const languages: Array<string> = Object.keys(i18nKeys);
+33 -4
View File
@@ -5,6 +5,13 @@ export default {
cancel: "Cancel", cancel: "Cancel",
accept: "Ok", accept: "Ok",
devices: "Devices",
others: "Others",
connected: "Connected",
disconnected: "Disconnected",
unknown: "Unknown",
connecting: "Connecting",
bar: { bar: {
apps: { apps: {
@@ -19,10 +26,6 @@ export default {
network: { network: {
network: "Network", network: "Network",
connected: "Connected",
disconnected: "Disconnected",
unknown: "Unknown",
connecting: "Connecting",
wireless: "Wireless", wireless: "Wireless",
wired: "Wired" wired: "Wired"
}, },
@@ -38,6 +41,32 @@ export default {
title: "Night Light", title: "Night Light",
default_desc: "Fidelity" default_desc: "Fidelity"
} }
},
pages: {
more_settings: "More settings",
mixer: {
title: "Mixer",
description: "Control per-application volume"
},
night_light: {
title: "Night Light",
description: "Control Night Light and Gamma filters",
gamma: "Gamma",
temperature: "Temperature"
},
bluetooth: {
title: "Bluetooth",
description: "Manage Bluetooth devices",
new_devices: "New devices",
adapters: "Adapters",
paired_devices: "Paired Devices",
start_discovering: "Start discovering",
stop_discovering: "Stop discovering"
},
network: {
title: "Network",
interface: "Interface"
}
} }
}, },
ask_popup: { ask_popup: {
+33 -4
View File
@@ -5,6 +5,13 @@ export default {
cancel: "Cancelar", cancel: "Cancelar",
accept: "Ok", accept: "Ok",
devices: "Dispositivos",
others: "Outros",
connected: "Conectado",
disconnected: "Desconectado",
unknown: "Desconhecido",
connecting: "Conectando",
bar: { bar: {
apps: { apps: {
@@ -19,10 +26,6 @@ export default {
network: { network: {
network: "Rede", network: "Rede",
connected: "Conectado",
disconnected: "Desconectado",
unknown: "Desconhecido",
connecting: "Conectando",
wireless: "Wi-Fi", wireless: "Wi-Fi",
wired: "Cabeada" wired: "Cabeada"
}, },
@@ -38,6 +41,32 @@ export default {
title: "Luz Noturna", title: "Luz Noturna",
default_desc: "Fidelidade" default_desc: "Fidelidade"
} }
},
pages: {
more_settings: "Mais configurações",
mixer: {
title: "Mixer de Volume",
description: "Controle o volume dos aplicativos"
},
night_light: {
title: "Luz Noturna",
description: "Controle os filtros de Luz Noturna e Gama",
temperature: "Temperatura",
gamma: "Gama"
},
bluetooth: {
title: "Bluetooth",
description: "Gerencie dispositivos Bluetooth",
new_devices: "Novos Dispositivos",
adapters: "Adaptadores",
paired_devices: "Dispositivos Pareados",
start_discovering: "Começar a procurar dispositivos",
stop_discovering: "Parar de procurar dispositivos"
},
network: {
title: "Rede",
interface: "Interface"
}
} }
}, },
ask_popup: { ask_popup: {
+37 -6
View File
@@ -2,7 +2,15 @@ export type i18nStruct = {
language: string, language: string,
cancel: string, cancel: string,
accept: string accept: string,
connected: string,
disconnected: string,
connecting: string,
unknown: string,
devices: string,
others: string,
bar: { bar: {
apps: { apps: {
@@ -17,17 +25,13 @@ export type i18nStruct = {
network: { network: {
network: string, network: string,
connected: string,
disconnected: string,
unknown: string,
connecting: string,
wireless: string, wireless: string,
wired: string wired: string
}, },
recording: { recording: {
title: string, title: string,
disabled_desc: string, disabled_desc: string,
enabled_desc: string, enabled_desc: string
}, },
dnd: { dnd: {
title: string title: string
@@ -36,6 +40,33 @@ export type i18nStruct = {
title: string, title: string,
default_desc: string default_desc: string
} }
},
pages: {
more_settings: string,
mixer: {
title: string,
description: string
},
network: {
title: string,
interface: string
},
bluetooth: {
title: string,
description: string,
adapters: string,
new_devices: string,
paired_devices: string,
start_discovering: string,
stop_discovering: string
},
night_light: {
title: string,
description: string,
temperature: string,
gamma: string
}
} }
}, },
ask_popup: { ask_popup: {
+10 -7
View File
@@ -3,12 +3,13 @@ import { Gtk, Widget } from "astal/gtk3";
import AstalBluetooth from "gi://AstalBluetooth"; import AstalBluetooth from "gi://AstalBluetooth";
import { Page, PageButton } from "./Page"; import { Page, PageButton } from "./Page";
import { Separator, SeparatorProps } from "../../Separator"; import { Separator, SeparatorProps } from "../../Separator";
import { tr } from "../../../i18n/intl";
export const BluetoothPage: (() => Page) = () => new Page({ export const BluetoothPage: (() => Page) = () => new Page({
id: "bluetooth", id: "bluetooth",
title: "Bluetooth", title: tr("control_center.pages.bluetooth.title"),
description: "Manage your Bluetooth devices and add new ones.", description: tr("control_center.pages.bluetooth.description"),
className: "bluetooth", className: "bluetooth",
headerButtons: [ headerButtons: [
new Widget.Button({ new Widget.Button({
@@ -16,7 +17,9 @@ export const BluetoothPage: (() => Page) = () => new Page({
label: bind(AstalBluetooth.get_default().adapter, "discovering").as((discovering) => label: bind(AstalBluetooth.get_default().adapter, "discovering").as((discovering) =>
!discovering ? '󰑓' : '󰙦'), !discovering ? '󰑓' : '󰙦'),
tooltipText: bind(AstalBluetooth.get_default().adapter, "discovering").as((discovering) => tooltipText: bind(AstalBluetooth.get_default().adapter, "discovering").as((discovering) =>
!discovering ? "Start discovering" : "Stop discovery"), !discovering ?
tr("control_center.pages.bluetooth.start_discovering")
: tr("control_center.pages.bluetooth.stop_discovering")),
onClick: () => { onClick: () => {
if(AstalBluetooth.get_default().adapter.discovering) { if(AstalBluetooth.get_default().adapter.discovering) {
stopBluetoothDevicesWatch(); stopBluetoothDevicesWatch();
@@ -36,7 +39,7 @@ export const BluetoothPage: (() => Page) = () => new Page({
children: bind(AstalBluetooth.get_default(), "adapters").as((adapters) => [ children: bind(AstalBluetooth.get_default(), "adapters").as((adapters) => [
new Widget.Label({ new Widget.Label({
className: "sub-header", className: "sub-header",
label: "Adapters" label: tr("control_center.pages.bluetooth.adapters")
} as Widget.LabelProps), } as Widget.LabelProps),
...adapters.map(adapter => ...adapters.map(adapter =>
PageButton({ PageButton({
@@ -64,7 +67,7 @@ export const BluetoothPage: (() => Page) = () => new Page({
return [ return [
new Widget.Label({ new Widget.Label({
className: "sub-header", className: "sub-header",
label: "Paired Devices", label: tr("control_center.pages.bluetooth.paired_devices"),
xalign: 0, xalign: 0,
} as Widget.LabelProps), } as Widget.LabelProps),
...connectedDevices.map((dev: AstalBluetooth.Device) => DeviceWidget(dev)) ...connectedDevices.map((dev: AstalBluetooth.Device) => DeviceWidget(dev))
@@ -82,7 +85,7 @@ export const BluetoothPage: (() => Page) = () => new Page({
return [ return [
new Widget.Label({ new Widget.Label({
className: "sub-header", className: "sub-header",
label: "Others", label: tr("control_center.pages.bluetooth.new_devices"),
xalign: 0 xalign: 0
} as Widget.LabelProps), } as Widget.LabelProps),
...discoveredDevices.map((dev: AstalBluetooth.Device) => DeviceWidget(dev)) ...discoveredDevices.map((dev: AstalBluetooth.Device) => DeviceWidget(dev))
@@ -96,7 +99,7 @@ export const BluetoothPage: (() => Page) = () => new Page({
} as SeparatorProps), } as SeparatorProps),
new Widget.Button({ new Widget.Button({
className: "more", className: "more",
label: "More settings", label: tr("control_center.pages.more_settings"),
setup: (self) => self.set_alignment(0, 0.5) setup: (self) => self.set_alignment(0, 0.5)
} as Widget.ButtonProps) } as Widget.ButtonProps)
] ]
+3 -2
View File
@@ -4,12 +4,13 @@ import { Gtk, Widget } from "astal/gtk3";
import AstalWp from "gi://AstalWp"; import AstalWp from "gi://AstalWp";
import { getAppIcon } from "../../../scripts/apps"; import { getAppIcon } from "../../../scripts/apps";
import { Wireplumber } from "../../../scripts/volume"; import { Wireplumber } from "../../../scripts/volume";
import { tr } from "../../../i18n/intl";
export function PageMixer(): Page { export function PageMixer(): Page {
return new Page({ return new Page({
id: "mixer", id: "mixer",
title: "Mixer", title: tr("control_center.pages.mixer.title"),
description: "Control per-application volume!", description: tr("control_center.pages.mixer.description"),
children: bind(Wireplumber.getWireplumber(), "endpoints").as((endpoints) => [ children: bind(Wireplumber.getWireplumber(), "endpoints").as((endpoints) => [
...endpoints.filter((ep) => ep.mediaClass === AstalWp.MediaClass.AUDIO_STREAM || ...endpoints.filter((ep) => ep.mediaClass === AstalWp.MediaClass.AUDIO_STREAM ||
ep.mediaClass === AstalWp.MediaClass.VIDEO_STREAM).map((ep) => ep.mediaClass === AstalWp.MediaClass.VIDEO_STREAM).map((ep) =>
+7 -5
View File
@@ -6,10 +6,11 @@ import NM from "gi://NM";
import { Separator, SeparatorProps } from "../../Separator"; import { Separator, SeparatorProps } from "../../Separator";
import { Windows } from "../../../windows"; import { Windows } from "../../../windows";
import AstalHyprland from "gi://AstalHyprland?version=0.1"; import AstalHyprland from "gi://AstalHyprland?version=0.1";
import { tr } from "../../../i18n/intl";
export const PageNetwork: (() => Page) = () => new Page({ export const PageNetwork: (() => Page) = () => new Page({
id: "network", id: "network",
title: "Network", title: tr("control_center.pages.network.title"),
className: "network", className: "network",
headerButtons: [ headerButtons: [
new Widget.Button({ new Widget.Button({
@@ -33,7 +34,7 @@ export const PageNetwork: (() => Page) = () => new Page({
return [ return [
new Widget.Label({ new Widget.Label({
label: "Devices", label: tr("devices"),
xalign: 0, xalign: 0,
className: "sub-header", className: "sub-header",
} as Widget.LabelProps), } as Widget.LabelProps),
@@ -43,7 +44,8 @@ export const PageNetwork: (() => Page) = () => new Page({
deviceType === NM.DeviceType.WIFI ? deviceType === NM.DeviceType.WIFI ?
"network-wireless-symbolic" "network-wireless-symbolic"
: "network-wired-symbolic"), : "network-wired-symbolic"),
title: bind(dev, "interface").as(iface => iface ?? "Interface"), title: bind(dev, "interface").as(iface => iface ??
tr("control_center.pages.network.interface")),
extraButtons: [ extraButtons: [
new Widget.Button({ new Widget.Button({
image: new Widget.Icon({ image: new Widget.Icon({
@@ -83,7 +85,7 @@ export const PageNetwork: (() => Page) = () => new Page({
new Widget.Label({ new Widget.Label({
className: "ssid", className: "ssid",
halign: Gtk.Align.START, halign: Gtk.Align.START,
label: ap.ssid.toArray().toString() label: ap.ssid.get_data()?.toString() ?? "Wi-Fi"
} as Widget.LabelProps), } as Widget.LabelProps),
new Widget.Label({ new Widget.Label({
className: "status", className: "status",
@@ -98,7 +100,7 @@ export const PageNetwork: (() => Page) = () => new Page({
size: .2 size: .2
} as SeparatorProps), } as SeparatorProps),
new Widget.Button({ new Widget.Button({
label: "More settings", label: tr("control_center.pages.more_settings"),
setup: (self) => self.set_alignment(0, 0.5), setup: (self) => self.set_alignment(0, 0.5),
onClick: () => { onClick: () => {
Windows.close("control-center"); Windows.close("control-center");
@@ -3,16 +3,17 @@ import { Page, PageProps } from "./Page";
import { bind } from "astal"; import { bind } from "astal";
import { NightLight } from "../../../scripts/nightlight"; import { NightLight } from "../../../scripts/nightlight";
import { addSliderMarksFromMinMax } from "../../../scripts/widget-utils"; import { addSliderMarksFromMinMax } from "../../../scripts/widget-utils";
import { tr } from "../../../i18n/intl";
export const PageNightLight: (() => Page) = () => new Page({ export const PageNightLight: (() => Page) = () => new Page({
id: "night-light", id: "night-light",
title: "Night Light", title: tr("control_center.pages.night_light.title"),
description: "Control night light and gamma filters", description: tr("control_center.pages.night_light.description"),
className: "night-light", className: "night-light",
children: [ children: [
new Widget.Label({ new Widget.Label({
className: "sub-header", className: "sub-header",
label: "Temperature (blue-light filter)", label: tr("control_center.pages.night_light.temperature"),
xalign: 0 xalign: 0
} as Widget.LabelProps), } as Widget.LabelProps),
new Widget.Slider({ new Widget.Slider({
@@ -30,7 +31,7 @@ export const PageNightLight: (() => Page) = () => new Page({
} as Widget.SliderProps), } as Widget.SliderProps),
new Widget.Label({ new Widget.Label({
className: "sub-header", className: "sub-header",
label: "Gamma (light filter)", label: tr("control_center.pages.night_light.gamma"),
css: "margin-top: 6px;", css: "margin-top: 6px;",
xalign: 0 xalign: 0
} as Widget.LabelProps), } as Widget.LabelProps),
+9 -9
View File
@@ -15,18 +15,18 @@ export const TileNetwork = () => new Widget.Box({
(primary: AstalNetwork.Primary, wired: AstalNetwork.Wired, wifi: AstalNetwork.Wifi) => { (primary: AstalNetwork.Primary, wired: AstalNetwork.Wired, wifi: AstalNetwork.Wifi) => {
if(primary === AstalNetwork.Primary.WIFI) { if(primary === AstalNetwork.Primary.WIFI) {
return Tile({ return Tile({
title: tr("control_center.tiles.network.wireless") || "Wireless", title: tr("control_center.tiles.network.wireless"),
description: Variable.derive( description: Variable.derive(
[ bind(wifi, "ssid"), bind(wifi, "internet") ], [ bind(wifi, "ssid"), bind(wifi, "internet") ],
(ssid: string, internet: AstalNetwork.Internet) => (ssid: string, internet: AstalNetwork.Internet) =>
ssid ? ssid : (() => { ssid ? ssid : (() => {
switch(internet) { switch(internet) {
case AstalNetwork.Internet.CONNECTED: case AstalNetwork.Internet.CONNECTED:
return tr("control_center.tiles.network.connected") || "Connected"; return tr("connected");
case AstalNetwork.Internet.DISCONNECTED: case AstalNetwork.Internet.DISCONNECTED:
return tr("control_center.tiles.network.disconnected") || "Disconnected"; return tr("disconnected");
case AstalNetwork.Internet.CONNECTING: case AstalNetwork.Internet.CONNECTING:
return tr("control_center.tiles.network.connecting") + "..." || "Connecting..."; return tr("connecting") + "...";
} }
})() })()
)(), )(),
@@ -44,11 +44,11 @@ export const TileNetwork = () => new Widget.Box({
description: bind(wired, "internet").as((internet: AstalNetwork.Internet) => { description: bind(wired, "internet").as((internet: AstalNetwork.Internet) => {
switch(internet) { switch(internet) {
case AstalNetwork.Internet.CONNECTED: case AstalNetwork.Internet.CONNECTED:
return tr("control_center.tiles.network.connected") || "Connected"; return tr("connected");
case AstalNetwork.Internet.DISCONNECTED: case AstalNetwork.Internet.DISCONNECTED:
return tr("control_center.tiles.network.disconnected") || "Disconnected"; return tr("disconnected");
case AstalNetwork.Internet.CONNECTING: case AstalNetwork.Internet.CONNECTING:
return tr("control_center.tiles.network.connecting") + "..." || "Connecting..."; return tr("connecting") + "...";
} }
}), }),
onToggledOn: () => execAsync("nmcli n on"), onToggledOn: () => execAsync("nmcli n on"),
@@ -73,8 +73,8 @@ export const TileNetwork = () => new Widget.Box({
} }
return Tile({ return Tile({
title: tr("control_center.tiles.network.network") || "Network", title: tr("control_center.tiles.network.network"),
description: tr("control_center.tiles.network.disconnected") || "Disconnected", description: tr("disconnected"),
onToggledOn: () => execAsync("nmcli n on"), onToggledOn: () => execAsync("nmcli n on"),
onToggledOff: () => execAsync("nmcli n off"), onToggledOff: () => execAsync("nmcli n off"),
onClickMore: () => TilesPages?.toggle(PageNetwork()), onClickMore: () => TilesPages?.toggle(PageNetwork()),