Add translation

This commit is contained in:
月月
2024-09-16 16:40:54 +08:00
parent 73334862c6
commit 69adcbbda5
20 changed files with 312 additions and 123 deletions
@@ -6,6 +6,7 @@ const { Box, EventBox, Icon, Overlay, Label, Button, Revealer } = Widget;
import { MaterialIcon } from './materialicon.js';
import { setupCursorHover } from "../.widgetutils/cursorhover.js";
import { AnimatedCircProg } from "./cairo_circularprogress.js";
import { getString } from '../../i18n/i18n.js';
function guessMessageType(summary) {
const str = summary.toLowerCase();
@@ -29,11 +30,11 @@ const getFriendlyNotifTimeString = (timeObject) => {
const messageTime = GLib.DateTime.new_from_unix_local(timeObject);
const oneMinuteAgo = GLib.DateTime.new_now_local().add_seconds(-60);
if (messageTime.compare(oneMinuteAgo) > 0)
return 'Now';
return getString('Now');
else if (messageTime.get_day_of_year() == GLib.DateTime.new_now_local().get_day_of_year())
return messageTime.format(userOptions.time.format);
else if (messageTime.get_day_of_year() == GLib.DateTime.new_now_local().get_day_of_year() - 1)
return 'Yesterday';
return getString('Yesterday');
else
return messageTime.format(userOptions.time.dateFormat);
}
@@ -198,7 +199,7 @@ export default ({
onClicked: () => destroyWithAnims(),
setup: setupCursorHover,
child: Label({
label: 'Close',
label: getString('Close'),
}),
}),
...notifObject.actions.map(action => Widget.Button({
+3 -3
View File
@@ -183,7 +183,7 @@ export default () => {
} else return BarGroup({
child: Box({
children: [
BarResource('RAM Usage', 'memory', `LANG=C free | awk '/^Mem/ {printf("%.2f\\n", ($3/$2) * 100)}'`,
BarResource(getString('RAM Usage'), 'memory', `LANG=C free | awk '/^Mem/ {printf("%.2f\\n", ($3/$2) * 100)}'`,
'bar-ram-circprog', 'bar-ram-txt', 'bar-ram-icon'),
Revealer({
revealChild: true,
@@ -192,9 +192,9 @@ export default () => {
child: Box({
className: 'spacing-h-10 margin-left-10',
children: [
BarResource('Swap Usage', 'swap_horiz', `LANG=C free | awk '/^Swap/ {if ($2 > 0) printf("%.2f\\n", ($3/$2) * 100); else print "0";}'`,
BarResource(getString('Swap Usage'), 'swap_horiz', `LANG=C free | awk '/^Swap/ {if ($2 > 0) printf("%.2f\\n", ($3/$2) * 100); else print "0";}'`,
'bar-swap-circprog', 'bar-swap-txt', 'bar-swap-icon'),
BarResource('CPU Usage', 'settings_motion_mode', `LANG=C top -bn1 | grep Cpu | sed 's/\\,/\\./g' | awk '{print $2}'`,
BarResource(getString('CPU Usage'), 'settings_motion_mode', `LANG=C top -bn1 | grep Cpu | sed 's/\\,/\\./g' | awk '{print $2}'`,
'bar-cpu-circprog', 'bar-cpu-txt', 'bar-cpu-icon'),
]
}),
+4 -3
View File
@@ -8,6 +8,7 @@ import Battery from 'resource:///com/github/Aylur/ags/service/battery.js';
import { MaterialIcon } from '../../.commonwidgets/materialicon.js';
import { AnimatedCircProg } from "../../.commonwidgets/cairo_circularprogress.js";
import { WWO_CODE, WEATHER_SYMBOL, NIGHT_WEATHER_SYMBOL } from '../../.commondata/weather.js';
import { getString } from '../../../i18n/i18n.js';
const WEATHER_CACHE_FOLDER = `${GLib.get_user_cache_dir()}/ags/weather`;
Utils.exec(`mkdir -p ${WEATHER_CACHE_FOLDER}`);
@@ -74,18 +75,18 @@ const Utilities = () => Box({
className: 'spacing-h-4',
children: [
UtilButton({
name: 'Screen snip', icon: 'screenshot_region', onClicked: () => {
name: getString('Screen snip'), icon: 'screenshot_region', onClicked: () => {
Utils.execAsync(`${App.configDir}/scripts/grimblast.sh copy area`)
.catch(print)
}
}),
UtilButton({
name: 'Color picker', icon: 'colorize', onClicked: () => {
name: getString('Color picker'), icon: 'colorize', onClicked: () => {
Utils.execAsync(['hyprpicker', '-a']).catch(print)
}
}),
UtilButton({
name: 'Toggle on-screen keyboard', icon: 'keyboard', onClicked: () => {
name: getString('Toggle on-screen keyboard'), icon: 'keyboard', onClicked: () => {
toggleWindowOnAllMonitors('osk');
}
}),
+4 -4
View File
@@ -12,8 +12,8 @@ const getKeybindList = () => {
let data = Utils.exec(`${App.configDir}/scripts/hyprland/get_keybinds.py --path ${HYPRLAND_KEYBIND_CONFIG_FILE}`);
if (data == "\"error\"") {
Utils.timeout(2000, () => Utils.execAsync(['notify-send',
'Update path to keybinds',
'Keybinds hyprland config file not found. Check your user options.',
'Update path to keybinds',
'Keybinds hyprland config file not found. Check your user options.',
'-a', 'ags',
]).catch(print))
return { children: [] };
@@ -45,7 +45,7 @@ const Keybind = (keybindData, type) => { // type: either "keys" or "actions"
});
const Action = (text) => Label({ // Binds
xalign: 0,
label: text,
label: getString(text),
className: "txt txt-small cheatsheet-action",
})
return Widget.Box({
@@ -74,7 +74,7 @@ const Section = (sectionData, scope) => {
const name = Label({
xalign: 0,
className: "cheatsheet-category-title txt margin-bottom-10",
label: sectionData.name,
label: getString(sectionData.name),
})
const binds = Box({
className: 'spacing-h-10',
+3 -3
View File
@@ -9,12 +9,12 @@ import clickCloseRegion from '../.commonwidgets/clickcloseregion.js';
const cheatsheets = [
{
name: 'Keybinds',
name: getString('Keybinds'),
materialIcon: 'keyboard',
contentWidget: Keybinds,
},
{
name: 'Periodic table',
name: getString('Periodic table'),
materialIcon: 'experiment',
contentWidget: PeriodicTable,
},
@@ -35,7 +35,7 @@ const CheatsheetHeader = () => Widget.CenterBox({
hpack: 'center',
css: 'margin-right: 0.682rem;',
className: 'txt-title',
label: 'Cheat sheet',
label: getString('Cheat sheet'),
}),
Widget.Label({
vpack: 'center',
+19 -19
View File
@@ -78,22 +78,22 @@ function calculateSchemeInitIndex(optionsArr, searchValue = 'vibrant') {
const schemeOptionsArr = [
[
{ name: 'Tonal Spot', value: 'tonalspot' },
{ name: 'Fruit Salad', value: 'fruitsalad' },
{ name: 'Fidelity', value: 'fidelity' },
{ name: 'Rainbow', value: 'rainbow' },
{ name: getString('Tonal Spot'), value: 'tonalspot' },
{ name: getString('Fruit Salad'), value: 'fruitsalad' },
{ name: getString('Fidelity'), value: 'fidelity' },
{ name: getString('Rainbow'), value: 'rainbow' },
],
[
{ name: 'Neutral', value: 'neutral' },
{ name: 'Monochrome', value: 'monochrome' },
{ name: 'Expressive', value: 'expressive' },
{ name: 'Vibrant', value: 'vibrant' },
{ name: getString('Neutral'), value: 'neutral' },
{ name: getString('Monochrome'), value: 'monochrome' },
{ name: getString('Expressive'), value: 'expressive' },
{ name: getString('Vibrant'), value: 'vibrant' },
],
[
{ name: 'Vibrant+', value: 'morevibrant' },
{ name: getString('Vibrant+'), value: 'morevibrant' },
],
//[
// { name: 'Content', value: 'content' },
// { name: getString('Content'), value: 'content' },
//]
];
@@ -114,14 +114,14 @@ const ColorSchemeSettings = () => Widget.Box({
Widget.Label({
xalign: 0,
className: 'txt-norm titlefont txt',
label: 'Options',
label: getString('Options'),
hpack: 'center',
}),
//////////////////
ConfigToggle({
icon: 'dark_mode',
name: 'Dark Mode',
desc: 'Ya should go to sleep!',
name: getString('Dark Mode'),
desc: getString('Ya should go to sleep!'),
initValue: darkMode.value,
onChange: (_, newValue) => {
darkMode.value = !!newValue;
@@ -132,8 +132,8 @@ const ColorSchemeSettings = () => Widget.Box({
}),
ConfigToggle({
icon: 'border_clear',
name: 'Transparency',
desc: 'Make shell elements transparent',
name: getString('Transparency'),
desc: getString('Make shell elements transparent'),
initValue: initTransparencyVal,
onChange: (self, newValue) => {
let transparency = newValue == 0 ? "opaque" : "transparent";
@@ -143,13 +143,13 @@ const ColorSchemeSettings = () => Widget.Box({
},
}),
Widget.Box({
tooltipText: 'Theme GTK apps using accent color\n(drawback: dark/light mode switching requires restart)',
tooltipText: getString('Theme GTK apps using accent color\n(drawback: dark/light mode switching requires restart)'),
className: 'txt spacing-h-5 configtoggle-box',
children: [
MaterialIcon('imagesearch_roller', 'norm'),
Widget.Label({
className: 'txt txt-small',
label: 'Use Gradience',
label: getString('Use Gradience'),
}),
Widget.Box({ hexpand: true }),
ConfigMulipleSelection({
@@ -179,7 +179,7 @@ const ColorSchemeSettings = () => Widget.Box({
Widget.Label({
xalign: 0,
className: 'txt-norm titlefont txt margin-top-5',
label: 'Scheme styles',
label: getString('Scheme styles'),
hpack: 'center',
}),
//////////////////
@@ -207,7 +207,7 @@ const ColorschemeContent = () => Widget.Box({
Widget.Label({
xalign: 0,
className: 'txt-norm titlefont txt',
label: 'Color scheme',
label: getString('Color scheme'),
hpack: 'center',
}),
Widget.Box({
@@ -70,7 +70,7 @@ export const SearchAndWindows = () => {
hpack: 'center',
child: Widget.Label({
className: 'overview-search-prompt txt-small txt',
label: 'Type to search'
label: getString('Type to search')
}),
});
+9 -9
View File
@@ -61,14 +61,14 @@ const SessionButton = (name, icon, command, props = {}, colorid = 0) => {
export default ({ id = 0 }) => {
// lock, logout, sleep
const lockButton = SessionButton('Lock', 'lock', () => { closeWindowOnAllMonitors('session'); execAsync(['loginctl', 'lock-session']).catch(print) }, {}, 1);
const logoutButton = SessionButton('Logout', 'logout', () => { closeWindowOnAllMonitors('session'); execAsync(['bash', '-c', 'pkill Hyprland || pkill sway || pkill niri || loginctl terminate-user $USER']).catch(print) }, {}, 2);
const sleepButton = SessionButton('Sleep', 'sleep', () => { closeWindowOnAllMonitors('session'); execAsync(['bash', '-c', 'systemctl suspend || loginctl suspend']).catch(print) }, {}, 3);
const lockButton = SessionButton(getString('Lock'), 'lock', () => { closeWindowOnAllMonitors('session'); execAsync(['loginctl', 'lock-session']).catch(print) }, {}, 1);
const logoutButton = SessionButton(getString('Logout'), 'logout', () => { closeWindowOnAllMonitors('session'); execAsync(['bash', '-c', 'pkill Hyprland || pkill sway || pkill niri || loginctl terminate-user $USER']).catch(print) }, {}, 2);
const sleepButton = SessionButton(getString('Sleep'), 'sleep', () => { closeWindowOnAllMonitors('session'); execAsync(['bash', '-c', 'systemctl suspend || loginctl suspend']).catch(print) }, {}, 3);
// hibernate, shutdown, reboot
const hibernateButton = SessionButton('Hibernate', 'downloading', () => { closeWindowOnAllMonitors('session'); execAsync(['bash', '-c', 'systemctl hibernate || loginctl hibernate']).catch(print) }, {}, 4);
const shutdownButton = SessionButton('Shutdown', 'power_settings_new', () => { closeWindowOnAllMonitors('session'); execAsync(['bash', '-c', 'systemctl poweroff || loginctl poweroff']).catch(print) }, {}, 5);
const rebootButton = SessionButton('Reboot', 'restart_alt', () => { closeWindowOnAllMonitors('session'); execAsync(['bash', '-c', 'systemctl reboot || loginctl reboot']).catch(print) }, {}, 6);
const cancelButton = SessionButton('Cancel', 'close', () => closeWindowOnAllMonitors('session'), { className: 'session-button-cancel' }, 7);
const hibernateButton = SessionButton(getString('Hibernate'), 'downloading', () => { closeWindowOnAllMonitors('session'); execAsync(['bash', '-c', 'systemctl hibernate || loginctl hibernate']).catch(print) }, {}, 4);
const shutdownButton = SessionButton(getString('Shutdown'), 'power_settings_new', () => { closeWindowOnAllMonitors('session'); execAsync(['bash', '-c', 'systemctl poweroff || loginctl poweroff']).catch(print) }, {}, 5);
const rebootButton = SessionButton(getString('Reboot'), 'restart_alt', () => { closeWindowOnAllMonitors('session'); execAsync(['bash', '-c', 'systemctl reboot || loginctl reboot']).catch(print) }, {}, 6);
const cancelButton = SessionButton(getString('Cancel'), 'close', () => closeWindowOnAllMonitors('session'), { className: 'session-button-cancel' }, 7);
const sessionDescription = Widget.Box({
vertical: true,
@@ -76,12 +76,12 @@ export default ({ id = 0 }) => {
children: [
Widget.Label({
className: 'txt-title txt',
label: 'Session',
label: getString('Session'),
}),
Widget.Label({
justify: Gtk.Justification.CENTER,
className: 'txt-small txt',
label: 'Use arrow keys to navigate.\nEnter to select, Esc to cancel.'
label: getString('Use arrow keys to navigate.\nEnter to select, Esc to cancel.')
}),
]
});
+10 -9
View File
@@ -7,6 +7,7 @@ import { setupCursorHover } from '../.widgetutils/cursorhover.js';
import { TodoWidget } from "./todolist.js";
import { getCalendarLayout } from "./calendar_layout.js";
import { getString } from '../../i18n/i18n.js';
let calendarJson = getCalendarLayout(undefined, true);
let monthshift = 0;
@@ -30,13 +31,13 @@ function getDateInXMonthsTime(x) {
}
const weekDays = [ // MONDAY IS THE FIRST DAY OF THE WEEK :HESRIGHTYOUKNOW:
{ day: 'Mo', today: 0 },
{ day: 'Tu', today: 0 },
{ day: 'We', today: 0 },
{ day: 'Th', today: 0 },
{ day: 'Fr', today: 0 },
{ day: 'Sa', today: 0 },
{ day: 'Su', today: 0 },
{ day: getString('Mo'), today: 0 },
{ day: getString('Tu'), today: 0 },
{ day: getString('We'), today: 0 },
{ day: getString('Th'), today: 0 },
{ day: getString('Fr'), today: 0 },
{ day: getString('Sa'), today: 0 },
{ day: getString('Su'), today: 0 },
]
const CalendarDay = (day, today) => Widget.Button({
@@ -192,8 +193,8 @@ export const ModuleCalendar = () => Box({
vertical: true,
className: 'sidebar-navrail spacing-v-10',
children: [
StackButton('calendar', 'calendar_month', 'Calendar'),
StackButton('todo', 'done_outline', 'To Do'),
StackButton('calendar', 'calendar_month', getString('Calendar')),
StackButton('todo', 'done_outline', getString('To Do')),
// StackButton(box, 'stars', 'star', 'GitHub'),
]
}), false, false, 0);
@@ -5,6 +5,7 @@ const { Box, Button, Icon, Label, Revealer, Scrollable, Slider, Stack } = Widget
import { MaterialIcon } from '../../.commonwidgets/materialicon.js';
import { setupCursorHover } from '../../.widgetutils/cursorhover.js';
import { iconExists } from '../../.miscutils/icons.js';
import { getString } from '../../../i18n/i18n.js';
const AppVolume = (stream) => Box({
className: 'sidebar-volmixer-stream spacing-h-10',
@@ -165,7 +166,7 @@ export default (props) => {
className: 'spacing-v-5 txt-subtext',
children: [
MaterialIcon('brand_awareness', 'gigantic'),
Label({ label: 'No audio source', className: 'txt-small' }),
Label({ label: getString('No audio source'), className: 'txt-small' }),
]
}),
]
@@ -6,6 +6,7 @@ const { execAsync, exec } = Utils;
import { MaterialIcon } from '../../.commonwidgets/materialicon.js';
import { setupCursorHover } from '../../.widgetutils/cursorhover.js';
import { ConfigToggle } from '../../.commonwidgets/configwidgets.js';
import { getString } from '../../../i18n/i18n.js';
// can't connect: sync_problem
@@ -43,7 +44,7 @@ const BluetoothDevice = (device) => {
label: device.connected ? 'Connected' : (device.paired ? 'Paired' : ''),
className: 'txt-subtext',
setup: (self) => self.hook(device, (self) => {
self.label = device.connected ? 'Connected' : (device.paired ? 'Paired' : '');
self.label = device.connected ? getString('Connected') : (device.paired ? getString('Paired') : '');
}),
}),
]
@@ -64,7 +65,7 @@ const BluetoothDevice = (device) => {
vpack: 'center',
className: 'sidebar-bluetooth-device-remove',
child: MaterialIcon('delete', 'norm'),
tooltipText: 'Remove device',
tooltipText: getString('Remove device'),
setup: setupCursorHover,
onClicked: () => execAsync(['bluetoothctl', 'remove', device.address]).catch(print),
});
@@ -144,7 +145,7 @@ export default (props) => {
execAsync(['bash', '-c', userOptions.apps.bluetooth]).catch(print);
closeEverything();
},
label: 'More',
label: getString('More'),
setup: setupCursorHover,
})],
})
@@ -7,6 +7,7 @@ const { execAsync, exec } = Utils;
import { MaterialIcon } from '../../.commonwidgets/materialicon.js';
import { setupCursorHover } from '../../.widgetutils/cursorhover.js';
import { ConfigGap, ConfigSpinButton, ConfigToggle } from '../../.commonwidgets/configwidgets.js';
import { getString } from '../../../i18n/i18n.js';
const HyprlandToggle = ({ icon, name, desc = null, option, enableValue = 1, disableValue = 0, extraOnChange = () => { } }) => ConfigToggle({
icon: icon,
@@ -60,11 +61,11 @@ export default (props) => {
className: 'spacing-v-10',
children: [
ConfigSection({
name: 'Effects', children: [
name: getString('Effects'), children: [
ConfigToggle({
icon: 'border_clear',
name: 'Transparency',
desc: '[AGS]\nMake shell elements transparent\nBlur is also recommended if you enable this',
name: getString('Transparency'),
desc: getString('[AGS]\nMake shell elements transparent\nBlur is also recommended if you enable this'),
initValue: exec(`bash -c "sed -n \'2p\' ${GLib.get_user_state_dir()}/ags/user/colormode.txt"`) == "transparent",
onChange: (self, newValue) => {
const transparency = newValue == 0 ? "opaque" : "transparent";
@@ -74,22 +75,22 @@ export default (props) => {
.catch(print);
},
}),
HyprlandToggle({ icon: 'blur_on', name: 'Blur', desc: "[Hyprland]\nEnable blur on transparent elements\nDoesn't affect performance/power consumption unless you have transparent windows.", option: "decoration:blur:enabled" }),
HyprlandToggle({ icon: 'blur_on', name: getString('Blur'), desc: getString("[Hyprland]\nEnable blur on transparent elements\nDoesn't affect performance/power consumption unless you have transparent windows."), option: "decoration:blur:enabled" }),
Subcategory([
HyprlandToggle({ icon: 'stack_off', name: 'X-ray', desc: "[Hyprland]\nMake everything behind a window/layer except the wallpaper not rendered on its blurred surface\nRecommended to improve performance (if you don't abuse transparency/blur) ", option: "decoration:blur:xray" }),
HyprlandSpinButton({ icon: 'target', name: 'Size', desc: '[Hyprland]\nAdjust the blur radius. Generally doesn\'t affect performance\nHigher = more color spread', option: 'decoration:blur:size', minValue: 1, maxValue: 1000 }),
HyprlandSpinButton({ icon: 'repeat', name: 'Passes', desc: '[Hyprland] Adjust the number of runs of the blur algorithm\nMore passes = more spread and power consumption\n4 is recommended\n2- would look weird and 6+ would look lame.', option: 'decoration:blur:passes', minValue: 1, maxValue: 10 }),
HyprlandToggle({ icon: 'stack_off', name: getString('X-ray'), desc: getString("[Hyprland]\nMake everything behind a window/layer except the wallpaper not rendered on its blurred surface\nRecommended to improve performance (if you don't abuse transparency/blur) "), option: "decoration:blur:xray" }),
HyprlandSpinButton({ icon: 'target', name: getString('Size'), desc: getString('[Hyprland]\nAdjust the blur radius. Generally doesn\'t affect performance\nHigher = more color spread'), option: 'decoration:blur:size', minValue: 1, maxValue: 1000 }),
HyprlandSpinButton({ icon: 'repeat', name: getString('Passes'), desc: getString('[Hyprland] Adjust the number of runs of the blur algorithm\nMore passes = more spread and power consumption\n4 is recommended\n2- would look weird and 6+ would look lame.'), option: 'decoration:blur:passes', minValue: 1, maxValue: 10 }),
]),
ConfigGap({}),
HyprlandToggle({
icon: 'animation', name: 'Animations', desc: '[Hyprland] [GTK]\nEnable animations', option: 'animations:enabled',
icon: 'animation', name: getString('Animations'), desc: getString('[Hyprland] [GTK]\nEnable animations'), option: 'animations:enabled',
extraOnChange: (self, newValue) => execAsync(['gsettings', 'set', 'org.gnome.desktop.interface', 'enable-animations', `${newValue}`])
}),
Subcategory([
ConfigSpinButton({
icon: 'clear_all',
name: 'Choreography delay',
desc: 'In milliseconds, the delay between animations of a series',
name: getString('Choreography delay'),
desc: getString('In milliseconds, the delay between animations of a series'),
initValue: userOptions.animations.choreographyDelay,
step: 10, minValue: 0, maxValue: 1000,
onChange: (self, newValue) => {
@@ -100,11 +101,11 @@ export default (props) => {
]
}),
ConfigSection({
name: 'Developer', children: [
HyprlandToggle({ icon: 'speed', name: 'Show FPS', desc: "[Hyprland]\nShow FPS overlay on top-left corner", option: "debug:overlay" }),
HyprlandToggle({ icon: 'sort', name: 'Log to stdout', desc: "[Hyprland]\nPrint LOG, ERR, WARN, etc. messages to the console", option: "debug:enable_stdout_logs" }),
HyprlandToggle({ icon: 'motion_sensor_active', name: 'Damage tracking', desc: "[Hyprland]\nEnable damage tracking\nGenerally, leave it on.\nTurn off only when a shader doesn't work", option: "debug:damage_tracking", enableValue: 2 }),
HyprlandToggle({ icon: 'destruction', name: 'Damage blink', desc: "[Hyprland] [Epilepsy warning!]\nShow screen damage flashes", option: "debug:damage_blink" }),
name: getString('Developer'), children: [
HyprlandToggle({ icon: 'speed', name: getString('Show FPS'), desc: getString("[Hyprland]\nShow FPS overlay on top-left corner"), option: "debug:overlay" }),
HyprlandToggle({ icon: 'sort', name: getString('Log to stdout'), desc: getString("[Hyprland]\nPrint LOG, ERR, WARN, etc. messages to the console"), option: "debug:enable_stdout_logs" }),
HyprlandToggle({ icon: 'motion_sensor_active', name: getString('Damage tracking'), desc: getString("[Hyprland]\nEnable damage tracking\nGenerally, leave it on.\nTurn off only when a shader doesn't work"), option: "debug:damage_tracking", enableValue: 2 }),
HyprlandToggle({ icon: 'destruction', name: getString('Damage blink'), desc: getString("[Hyprland] [Epilepsy warning!]\nShow screen damage flashes"), option: "debug:damage_blink" }),
]
}),
]
@@ -115,7 +116,7 @@ export default (props) => {
children: [Label({
hpack: 'center',
className: 'txt txt-italic txt-subtext margin-5',
label: 'Not all changes are saved',
label: getString('Not all changes are saved'),
})]
})
return Box({
@@ -8,6 +8,7 @@ import { MaterialIcon } from '../../.commonwidgets/materialicon.js';
import { setupCursorHover } from '../../.widgetutils/cursorhover.js';
import Notification from '../../.commonwidgets/notification.js';
import { ConfigToggle } from '../../.commonwidgets/configwidgets.js';
import { getString } from '../../../i18n/i18n.js';
export default (props) => {
const notifEmptyContent = Box({
@@ -22,7 +23,7 @@ export default (props) => {
className: 'spacing-v-5 txt-subtext',
children: [
MaterialIcon('notifications_active', 'gigantic'),
Label({ label: 'No notifications', className: 'txt-small' }),
Label({ label: getString('No notifications'), className: 'txt-small' }),
]
}),
]
@@ -82,7 +83,7 @@ export default (props) => {
}),
setup: setupCursorHover,
});
const silenceButton = ListActionButton('notifications_paused', 'Silence', (self) => {
const silenceButton = ListActionButton('notifications_paused', getString('Silence'), (self) => {
Notifications.dnd = !Notifications.dnd;
self.toggleClassName('notif-listaction-btn-enabled', Notifications.dnd);
});
@@ -101,7 +102,7 @@ export default (props) => {
setup: (self) => self.hook(Notifications, (self) => {
self.revealChild = Notifications.notifications.length > 0;
}),
child: ListActionButton('clear_all', 'Clear', () => {
child: ListActionButton('clear_all', getString('Clear'), () => {
Notifications.clear();
const kids = notificationList.get_children();
for (let i = 0; i < kids.length; i++) {
@@ -114,7 +115,7 @@ export default (props) => {
attribute: {
updateCount: (self) => {
const count = Notifications.notifications.length;
if (count > 0) self.label = `${count} notifications`;
if (count > 0) self.label = `${count} ${getString("notifications")}`;
else self.label = '';
},
},
@@ -6,6 +6,7 @@ const { execAsync, exec } = Utils;
import { MaterialIcon } from '../../.commonwidgets/materialicon.js';
import { setupCursorHover } from '../../.widgetutils/cursorhover.js';
import { ConfigToggle } from '../../.commonwidgets/configwidgets.js';
import { getString } from '../../../i18n/i18n.js';
const MATERIAL_SYMBOL_SIGNAL_STRENGTH = {
'network-wireless-signal-excellent-symbolic': "signal_wifi_4_bar",
@@ -29,7 +30,7 @@ const WifiNetwork = (accessPoint) => {
accessPoint.active ? Label({
hpack: 'start',
className: 'txt-smaller txt-subtext',
label: "Selected",
label: getString("Selected"),
}) : null,
]
});
@@ -69,7 +70,7 @@ const CurrentNetwork = () => {
Label({
hpack: 'start',
className: 'txt-smaller txt-subtext',
label: "Current network",
label: getString("Current network"),
}),
Label({
hpack: 'start',
@@ -101,7 +102,7 @@ const CurrentNetwork = () => {
Label({
className: 'margin-left-5',
hpack: 'start',
label: "Authentication",
label: getString("Authentication"),
}),
Entry({
className: 'sidebar-wifinetworks-auth-entry',
@@ -199,7 +200,7 @@ export default (props) => {
execAsync(['bash', '-c', userOptions.apps.network]).catch(print);
closeEverything();
},
label: 'More',
label: getString('More'),
setup: setupCursorHover,
})],
})
+11 -10
View File
@@ -10,10 +10,11 @@ import { BluetoothIndicator, NetworkIndicator } from '../.commonwidgets/statusic
import { setupCursorHover } from '../.widgetutils/cursorhover.js';
import { MaterialIcon } from '../.commonwidgets/materialicon.js';
import { sidebarOptionsStack } from './sideright.js';
import { getString } from '../../i18n/i18n.js';
export const ToggleIconWifi = (props = {}) => Widget.Button({
className: 'txt-small sidebar-iconbutton',
tooltipText: 'Wifi | Right-click to configure',
tooltipText: getString('Wifi | Right-click to configure'),
onClicked: () => Network.toggleWifi(),
onSecondaryClickRelease: () => {
execAsync(['bash', '-c', `${userOptions.apps.network}`]).catch(print);
@@ -24,7 +25,7 @@ export const ToggleIconWifi = (props = {}) => Widget.Button({
setupCursorHover(self);
self.hook(Network, button => {
button.toggleClassName('sidebar-button-active', [Network.wifi?.internet, Network.wired?.internet].includes('connected'))
button.tooltipText = (`${Network.wifi?.ssid} | Right-click to configure` || 'Unknown');
button.tooltipText = (`${Network.wifi?.ssid} | ${getString("Right-click to configure")}` || getString('Unknown'));
});
},
...props,
@@ -32,7 +33,7 @@ export const ToggleIconWifi = (props = {}) => Widget.Button({
export const ToggleIconBluetooth = (props = {}) => Widget.Button({
className: 'txt-small sidebar-iconbutton',
tooltipText: 'Bluetooth | Right-click to configure',
tooltipText: getString('Bluetooth | Right-click to configure'),
onClicked: () => {
const status = Bluetooth?.enabled;
if (status)
@@ -86,7 +87,7 @@ export const ModuleNightLight = async (props = {}) => {
enabled: false,
},
className: 'txt-small sidebar-iconbutton',
tooltipText: 'Night Light',
tooltipText: getString('Night Light'),
onClicked: (self) => {
self.attribute.enabled = !self.attribute.enabled;
self.toggleClassName('sidebar-button-active', self.attribute.enabled);
@@ -122,7 +123,7 @@ export const ModuleCloudflareWarp = async (props = {}) => {
enabled: false,
},
className: 'txt-small sidebar-iconbutton',
tooltipText: 'Cloudflare WARP',
tooltipText: getString('Cloudflare WARP'),
onClicked: (self) => {
self.attribute.enabled = !self.attribute.enabled;
self.toggleClassName('sidebar-button-active', self.attribute.enabled);
@@ -147,7 +148,7 @@ export const ModuleInvertColors = async (props = {}) => {
const Hyprland = (await import('resource:///com/github/Aylur/ags/service/hyprland.js')).default;
return Widget.Button({
className: 'txt-small sidebar-iconbutton',
tooltipText: 'Color inversion',
tooltipText: getString('Color inversion'),
onClicked: (button) => {
// const shaderPath = JSON.parse(exec('hyprctl -j getoption decoration:screen_shader')).str;
Hyprland.messageAsync('j/getoption decoration:screen_shader')
@@ -208,7 +209,7 @@ export const ModuleIdleInhibitor = (props = {}) => Widget.Button({ // TODO: Make
enabled: false,
},
className: 'txt-small sidebar-iconbutton',
tooltipText: 'Keep system awake',
tooltipText: getString('Keep system awake'),
onClicked: (self) => {
self.attribute.enabled = !self.attribute.enabled;
self.toggleClassName('sidebar-button-active', self.attribute.enabled);
@@ -227,7 +228,7 @@ export const ModuleIdleInhibitor = (props = {}) => Widget.Button({ // TODO: Make
export const ModuleReloadIcon = (props = {}) => Widget.Button({
...props,
className: 'txt-small sidebar-iconbutton',
tooltipText: 'Reload Environment config',
tooltipText: getString('Reload Environment config'),
onClicked: () => {
execAsync(['bash', '-c', 'hyprctl reload || swaymsg reload &']);
App.closeWindow('sideright');
@@ -241,7 +242,7 @@ export const ModuleReloadIcon = (props = {}) => Widget.Button({
export const ModuleSettingsIcon = (props = {}) => Widget.Button({
...props,
className: 'txt-small sidebar-iconbutton',
tooltipText: 'Open Settings',
tooltipText: getString('Open Settings'),
onClicked: () => {
execAsync(['bash', '-c', `${userOptions.apps.settings}`, '&']);
App.closeWindow('sideright');
@@ -255,7 +256,7 @@ export const ModuleSettingsIcon = (props = {}) => Widget.Button({
export const ModulePowerIcon = (props = {}) => Widget.Button({
...props,
className: 'txt-small sidebar-iconbutton',
tooltipText: 'Session',
tooltipText: getString('Session'),
onClicked: () => {
closeEverything();
Utils.timeout(1, () => openWindowOnAllMonitors('session'));
+19 -17
View File
@@ -25,31 +25,32 @@ import { getDistroIcon } from '../.miscutils/system.js';
import { MaterialIcon } from '../.commonwidgets/materialicon.js';
import { ExpandingIconTabContainer } from '../.commonwidgets/tabcontainer.js';
import { checkKeybind } from '../.widgetutils/keybind.js';
import { getString } from '../../i18n/i18n.js';
const centerWidgets = [
{
name: 'Notifications',
name: getString('Notifications'),
materialIcon: 'notifications',
contentWidget: ModuleNotificationList,
},
{
name: 'Audio controls',
name: getString('Audio controls'),
materialIcon: 'volume_up',
contentWidget: ModuleAudioControls,
},
{
name: 'Bluetooth',
name: getString('Bluetooth'),
materialIcon: 'bluetooth',
contentWidget: ModuleBluetooth,
},
{
name: 'Wifi networks',
name: getString('Wifi networks'),
materialIcon: 'wifi',
contentWidget: ModuleWifiNetworks,
onFocus: () => execAsync('nmcli dev wifi list').catch(print),
},
{
name: 'Live config',
name: getString('Live config'),
materialIcon: 'tune',
contentWidget: ModuleConfigure,
},
@@ -66,43 +67,44 @@ const timeRow = Box({
hpack: 'center',
className: 'txt-small txt',
setup: (self) => {
const getUptime = async () => {
try {
await execAsync(['bash', '-c', 'uptime -p']);
const getUptime = async () => {
try {
await execAsync(['bash', '-c', 'uptime -p']);
return execAsync(['bash', '-c', `uptime -p | sed -e 's/...//;s/ day\\| days/d/;s/ hour\\| hours/h/;s/ minute\\| minutes/m/;s/,[^,]*//2'`]);
} catch {
return execAsync(['bash', '-c', 'uptime']).then(output => {
const uptimeRegex = /up\s+((\d+)\s+days?,\s+)?((\d+):(\d+)),/;
const matches = uptimeRegex.exec(output);
const uptimeRegex = /up\s+((\d+)\s+days?,\s+)?((\d+):(\d+)),/;
const matches = uptimeRegex.exec(output);
if (matches) {
const days = matches[2] ? parseInt(matches[2]) : 0;
const days = matches[2] ? parseInt(matches[2]) : 0;
const hours = matches[4] ? parseInt(matches[4]) : 0;
const minutes = matches[5] ? parseInt(matches[5]) : 0;
let formattedUptime = '';
if (days > 0) {
formattedUptime += `${days} d `;
formattedUptime += `${days} d `;
}
if (hours > 0) {
formattedUptime += `${hours} h `;
formattedUptime += `${hours} h `;
}
formattedUptime += `${minutes} m`;
return formattedUptime;
} else {
throw new Error('Failed to parse uptime output');
throw new Error('Failed to parse uptime output');
}
});
}
};
self.poll(5000, label => {
getUptime().then(upTimeString => {
label.label = `Uptime: ${upTimeString}`;
getUptime().then(upTimeString => {
label.label = `${getString("Uptime:"
)} ${upTimeString}`;
}).catch(err => {
console.error(`Failed to fetch uptime: ${err}`);
console.error(`Failed to fetch uptime: ${err}`);
});
});
},
+5 -4
View File
@@ -5,6 +5,7 @@ import { MaterialIcon } from '../.commonwidgets/materialicon.js';
import { TabContainer } from '../.commonwidgets/tabcontainer.js';
import Todo from "../../services/todo.js";
import { setupCursorHover } from '../.widgetutils/cursorhover.js';
import { getString } from '../../i18n/i18n.js';
const TodoListItem = (task, id, isDone, isEven = false) => {
const taskName = Widget.Label({
@@ -108,7 +109,7 @@ const todoItems = (isDone) => Widget.Scrollable({
className: 'txt txt-subtext',
children: [
MaterialIcon(`${isDone ? 'checklist' : 'check_circle'}`, 'gigantic'),
Label({ label: `${isDone ? 'Finished tasks will go here' : 'Nothing here!'}` })
Label({ label: `${isDone ? getString('Finished tasks will go here') : getString('Nothing here!')}` })
]
})
]
@@ -132,7 +133,7 @@ const UndoneTodoList = () => {
className: 'txt-small sidebar-todo-new',
halign: 'end',
vpack: 'center',
label: '+ New task',
label: getString('+ New task'),
setup: setupCursorHover,
onClicked: (self) => {
newTaskButton.revealChild = false;
@@ -166,7 +167,7 @@ const UndoneTodoList = () => {
// hexpand: true,
vpack: 'center',
className: 'txt-small sidebar-todo-entry',
placeholderText: 'Add a task...',
placeholderText: getString('Add a task...'),
onAccept: ({ text }) => {
if (text == '') return;
Todo.add(text)
@@ -216,7 +217,7 @@ const UndoneTodoList = () => {
export const TodoWidget = () => TabContainer({
icons: ['format_list_bulleted', 'task_alt'],
names: ['Unfinished', 'Done'],
names: [getString('Unfinished'), getString('Done')],
children: [
UndoneTodoList(),
todoItems(true),