Add left sidebar translation

This commit is contained in:
月月
2024-09-15 16:10:30 +08:00
parent 1e3f49a3f8
commit 73334862c6
13 changed files with 132 additions and 100 deletions
+1 -1
View File
@@ -145,7 +145,7 @@ export default () => {
if (mpris)
label.label = `${trimTrackTitle(mpris.trackTitle)}${mpris.trackArtists.join(', ')}`;
else
label.label = 'No media';
label.label = getString('No media');
}),
})
const musicStuff = Box({
+8 -12
View File
@@ -11,6 +11,7 @@ import BooruService from '../../../services/booru.js';
import { chatEntry } from '../apiwidgets.js';
import { ConfigToggle } from '../../.commonwidgets/configwidgets.js';
import { SystemMessage } from './ai_chatmessage.js';
import { getString } from '../../../i18n/i18n.js';
const IMAGE_REVEAL_DELAY = 13; // Some wait for inits n other weird stuff
const USER_CACHE_DIR = GLib.get_user_cache_dir();
@@ -67,12 +68,12 @@ const BooruInfo = () => {
className: 'txt-smallie txt-subtext',
wrap: true,
justify: Gtk.Justification.CENTER,
label: 'Powered by yande.re and konachan',
label: getString('Powered by yande.re and konachan'),
}),
Button({
className: 'txt-subtext txt-norm icon-material',
label: 'info',
tooltipText: 'An image booru. May contain NSFW content.\nWatch your back.\n\nDisclaimer: Not affiliated with the provider\nnor responsible for any of its content.',
tooltipText: getString('An image booru. May contain NSFW content.\nWatch your back.\n\nDisclaimer: Not affiliated with the provider\nnor responsible for any of its content.'),
setup: setupCursorHoverInfo,
}),
]
@@ -95,13 +96,8 @@ export const BooruSettings = () => MarginRevealer({
children: [
ConfigToggle({
icon: 'menstrual_health',
name: 'Lewds',
desc: `Shows naughty stuff when enabled.\nYa like those? Add this to user_options.js:
'sidebar': {
'image': {
'allowNsfw': true,
}
},`,
name: getString('Lewds'),
desc: getString("Shows naughty stuff when enabled.\nYa like those? Add this to user_options.js:\n\t'sidebar': {\n\t'image': {\n\t\t'allowNsfw': true,\n\t}\n}"),
initValue: BooruService.nsfw,
onChange: (self, newValue) => {
BooruService.nsfw = newValue;
@@ -112,8 +108,8 @@ export const BooruSettings = () => MarginRevealer({
}),
ConfigToggle({
icon: 'sell',
name: 'Save in folder by tags',
desc: 'Saves images in folders by their tags',
name: getString('Save in folder by tags'),
desc: getString('Saves images in folders by their tags'),
initValue: userOptions.sidebar.image.saveInFolderByTags,
onChange: (self, newValue) => {
userOptions.sidebar.image.saveInFolderByTags = newValue;
@@ -469,7 +465,7 @@ export const booruCommands = Box({
self.pack_start(Button({
className: 'sidebar-chat-chip-toggle',
setup: setupCursorHover,
label: 'Tags →',
label: getString('Tags →'),
onClicked: () => {
booruTags.revealChild = !booruTags.revealChild;
}
+17 -16
View File
@@ -12,6 +12,7 @@ import { markdownTest } from '../../.miscutils/md2pango.js';
import { MarginRevealer } from '../../.widgethacks/advancedrevealers.js';
import { MaterialIcon } from '../../.commonwidgets/materialicon.js';
import { chatEntry } from '../apiwidgets.js';
import { getString } from '../../../i18n/i18n.js';
export const chatGPTTabIcon = Icon({
hpack: 'center',
@@ -53,7 +54,7 @@ const ProviderSwitcher = () => {
}
const indicatorChevron = MaterialIcon('expand_more', 'norm');
const indicatorButton = Button({
tooltipText: 'Select ChatGPT-compatible API provider',
tooltipText: getString('Select ChatGPT-compatible API provider'),
child: Box({
className: 'spacing-h-10 txt',
children: [
@@ -121,7 +122,7 @@ const GPTInfo = () => {
className: 'txt txt-title-small sidebar-chat-welcome-txt',
wrap: true,
justify: Gtk.Justification.CENTER,
label: 'Assistant (GPTs)',
label: `${getString("Assistant")} (GPTs)`,
}),
Box({
className: 'spacing-h-5',
@@ -131,12 +132,12 @@ const GPTInfo = () => {
className: 'txt-smallie txt-subtext',
wrap: true,
justify: Gtk.Justification.CENTER,
label: 'Provider shown above',
label: getString('Provider shown above'),
}),
Button({
className: 'txt-subtext txt-norm icon-material',
label: 'info',
tooltipText: 'Uses gpt-3.5-turbo.\nNot affiliated, endorsed, or sponsored by OpenAI.\n\nPrivacy: OpenAI claims they do not use your data\nwhen you use their API. Idk about others.',
tooltipText: getString('Uses gpt-3.5-turbo.\nNot affiliated, endorsed, or sponsored by OpenAI.\n\nPrivacy: OpenAI claims they do not use your data\nwhen you use their API. Idk about others.'),
setup: setupCursorHoverInfo,
}),
]
@@ -164,11 +165,11 @@ const GPTSettings = () => MarginRevealer({
hpack: 'center',
icon: 'casino',
name: 'Randomness',
desc: 'The model\'s temperature value.\n Precise = 0\n Balanced = 0.5\n Creative = 1',
desc: getString('The model\'s temperature value.\n Precise = 0\n Balanced = 0.5\n Creative = 1'),
options: [
{ value: 0.00, name: 'Precise', },
{ value: 0.50, name: 'Balanced', },
{ value: 1.00, name: 'Creative', },
{ value: 0.00, name: getString('Precise'), },
{ value: 0.50, name: getString('Balanced'), },
{ value: 1.00, name: getString('Creative'), },
],
initIndex: 2,
onChange: (value, name) => {
@@ -183,8 +184,8 @@ const GPTSettings = () => MarginRevealer({
children: [
ConfigToggle({
icon: 'model_training',
name: 'Enhancements',
desc: 'Tells the model:\n- It\'s a Linux sidebar assistant\n- Be brief and use bullet points',
name: getString('Enhancements'),
desc: getString('Tells the model:\n- It\'s a Linux sidebar assistant\n- Be brief and use bullet points'),
initValue: GPTService.assistantPrompt,
onChange: (self, newValue) => {
GPTService.assistantPrompt = newValue;
@@ -212,7 +213,7 @@ export const OpenaiApiKeyInstructions = () => Box({
wrap: true,
className: 'txt sidebar-chat-welcome-txt',
justify: Gtk.Justification.CENTER,
label: 'An API key is required\nYou can grab one <u>here</u>, then enter it below'
label: getString('An API key is required\nYou can grab one <u>here</u>, then enter it below')
}),
setup: setupCursorHover,
onClicked: () => {
@@ -287,7 +288,7 @@ export const sendMessage = (text) => {
// Commands
if (text.startsWith('/')) {
if (text.startsWith('/clear')) clearChat();
else if (text.startsWith('/model')) chatContent.add(SystemMessage(`Currently using \`${GPTService.modelName}\``, '/model', chatGPTView))
else if (text.startsWith('/model')) chatContent.add(SystemMessage(`${getString("Currently using")} \`${GPTService.modelName}\``, '/model', chatGPTView))
else if (text.startsWith('/prompt')) {
const firstSpaceIndex = text.indexOf(' ');
const prompt = text.slice(firstSpaceIndex + 1);
@@ -301,18 +302,18 @@ export const sendMessage = (text) => {
else if (text.startsWith('/key')) {
const parts = text.split(' ');
if (parts.length == 1) chatContent.add(SystemMessage(
`Key stored in:\n\`${GPTService.keyPath}\`\nTo update this key, type \`/key YOUR_API_KEY\``,
`${getString("Key stored in:")}\n\`${GPTService.keyPath}\`\n${getString("To update this key, type")} \`/key YOUR_API_KEY\``,
'/key',
chatGPTView));
else {
GPTService.key = parts[1];
chatContent.add(SystemMessage(`Updated API Key at\n\`${GPTService.keyPath}\``, '/key', chatGPTView));
chatContent.add(SystemMessage(`${getString("Updated API Key at")}\n\`${GPTService.keyPath}\``, '/key', chatGPTView));
}
}
else if (text.startsWith('/test'))
chatContent.add(SystemMessage(markdownTest, `Markdown test`, chatGPTView));
else
chatContent.add(SystemMessage(`Invalid command.`, 'Error', chatGPTView))
chatContent.add(SystemMessage(getString("Invalid command."), 'Error', chatGPTView))
}
else {
GPTService.send(text);
@@ -346,7 +347,7 @@ export const chatGPTView = Box({
// Always scroll to bottom with new content
const adjustment = scrolledWindow.get_vadjustment();
adjustment.connect("changed", () => {
if(!chatEntry.hasFocus) return;
if (!chatEntry.hasFocus) return;
adjustment.set_value(adjustment.get_upper() - adjustment.get_page_size());
})
}
+19 -18
View File
@@ -11,6 +11,7 @@ import { ConfigToggle, ConfigSegmentedSelection, ConfigGap } from '../../.common
import { markdownTest } from '../../.miscutils/md2pango.js';
import { MarginRevealer } from '../../.widgethacks/advancedrevealers.js';
import { chatEntry } from '../apiwidgets.js';
import { getString } from '../../../i18n/i18n.js';
const MODEL_NAME = `Gemini`;
@@ -34,7 +35,7 @@ const GeminiInfo = () => {
className: 'txt txt-title-small sidebar-chat-welcome-txt',
wrap: true,
justify: Gtk.Justification.CENTER,
label: 'Assistant (Gemini)',
label: `${getString('Assistant')} (Gemini)`,
}),
Box({
className: 'spacing-h-5',
@@ -44,12 +45,12 @@ const GeminiInfo = () => {
className: 'txt-smallie txt-subtext',
wrap: true,
justify: Gtk.Justification.CENTER,
label: 'Powered by Google',
label: getString('Powered by Google'),
}),
Button({
className: 'txt-subtext txt-norm icon-material',
label: 'info',
tooltipText: 'Uses gemini-pro.\nNot affiliated, endorsed, or sponsored by Google.\n\nPrivacy: Chat messages aren\'t linked to your account,\n but will be read by human reviewers to improve the model.',
tooltipText: getString("Uses gemini-pro.\nNot affiliated, endorsed, or sponsored by Google.\n\nPrivacy: Chat messages aren't linked to your account,\n but will be read by human reviewers to improve the model."),
setup: setupCursorHoverInfo,
}),
]
@@ -77,11 +78,11 @@ export const GeminiSettings = () => MarginRevealer({
hpack: 'center',
icon: 'casino',
name: 'Randomness',
desc: 'Gemini\'s temperature value.\n Precise = 0\n Balanced = 0.5\n Creative = 1',
desc: getString("Gemini's temperature value.\n Precise = 0\n Balanced = 0.5\n Creative = 1"),
options: [
{ value: 0.00, name: 'Precise', },
{ value: 0.50, name: 'Balanced', },
{ value: 1.00, name: 'Creative', },
{ value: 0.00, name: getString('Precise'), },
{ value: 0.50, name: getString('Balanced'), },
{ value: 1.00, name: getString('Creative'), },
],
initIndex: 2,
onChange: (value, name) => {
@@ -96,8 +97,8 @@ export const GeminiSettings = () => MarginRevealer({
children: [
ConfigToggle({
icon: 'model_training',
name: 'Enhancements',
desc: 'Tells Gemini:\n- It\'s a Linux sidebar assistant\n- Be brief and use bullet points',
name: getString('Enhancements'),
desc: getString("Tells Gemini:\n- It's a Linux sidebar assistant\n- Be brief and use bullet points"),
initValue: GeminiService.assistantPrompt,
onChange: (self, newValue) => {
GeminiService.assistantPrompt = newValue;
@@ -105,8 +106,8 @@ export const GeminiSettings = () => MarginRevealer({
}),
ConfigToggle({
icon: 'shield',
name: 'Safety',
desc: 'When turned off, tells the API (not the model) \nto not block harmful/explicit content',
name: getString('Safety'),
desc: getString("When turned off, tells the API (not the model) \nto not block harmful/explicit content"),
initValue: GeminiService.safe,
onChange: (self, newValue) => {
GeminiService.safe = newValue;
@@ -114,8 +115,8 @@ export const GeminiSettings = () => MarginRevealer({
}),
ConfigToggle({
icon: 'history',
name: 'History',
desc: 'Saves chat history\nMessages in previous chats won\'t show automatically, but they are there',
name: getString('History'),
desc: getString("Saves chat history\nMessages in previous chats won't show automatically, but they are there"),
initValue: GeminiService.useHistory,
onChange: (self, newValue) => {
GeminiService.useHistory = newValue;
@@ -223,7 +224,7 @@ export const sendMessage = (text) => {
clearChat();
GeminiService.loadHistory();
}
else if (text.startsWith('/model')) chatContent.add(SystemMessage(`Currently using \`${GeminiService.modelName}\``, '/model', geminiView))
else if (text.startsWith('/model')) chatContent.add(SystemMessage(`${getString("Currently using")} \`${GeminiService.modelName}\``, '/model', geminiView))
else if (text.startsWith('/prompt')) {
const firstSpaceIndex = text.indexOf(' ');
const prompt = text.slice(firstSpaceIndex + 1);
@@ -237,18 +238,18 @@ export const sendMessage = (text) => {
else if (text.startsWith('/key')) {
const parts = text.split(' ');
if (parts.length == 1) chatContent.add(SystemMessage(
`Key stored in:\n\`${GeminiService.keyPath}\`\nTo update this key, type \`/key YOUR_API_KEY\``,
`${getString("Key stored in:")} \n\`${GeminiService.keyPath}\`\n${getString("To update this key, type")} \`/key YOUR_API_KEY\``,
'/key',
geminiView));
else {
GeminiService.key = parts[1];
chatContent.add(SystemMessage(`Updated API Key at\n\`${GeminiService.keyPath}\``, '/key', geminiView));
chatContent.add(SystemMessage(`${getString("Updated API Key at")}\n\`${GeminiService.keyPath}\``, '/key', geminiView));
}
}
else if (text.startsWith('/test'))
chatContent.add(SystemMessage(markdownTest, `Markdown test`, geminiView));
else
chatContent.add(SystemMessage(`Invalid command.`, 'Error', geminiView))
chatContent.add(SystemMessage(getString(`Invalid command.`), 'Error', geminiView))
}
else {
GeminiService.send(text);
@@ -280,7 +281,7 @@ export const geminiView = Box({
// Always scroll to bottom with new content
const adjustment = scrolledWindow.get_vadjustment();
adjustment.connect("changed", () => Utils.timeout(1, () => {
if(!chatEntry.hasFocus) return;
if (!chatEntry.hasFocus) return;
adjustment.set_value(adjustment.get_upper() - adjustment.get_page_size());
}))
}
+4 -3
View File
@@ -13,6 +13,7 @@ import { setupCursorHover, setupCursorHoverInfo } from '../../.widgetutils/curso
import WaifuService from '../../../services/waifus.js';
import { darkMode } from '../../.miscutils/system.js';
import { chatEntry } from '../apiwidgets.js';
import { getString } from '../../../i18n/i18n.js';
async function getImageViewerApp(preferredApp) {
Utils.execAsync(['bash', '-c', `command -v ${preferredApp}`])
@@ -71,12 +72,12 @@ const WaifuInfo = () => {
className: 'txt-smallie txt-subtext',
wrap: true,
justify: Gtk.Justification.CENTER,
label: 'Powered by waifu.im + other APIs',
label: getString('Powered by waifu.im + other APIs'),
}),
Button({
className: 'txt-subtext txt-norm icon-material',
label: 'info',
tooltipText: 'Type tags for a random pic.\nNSFW content will not be returned unless\nyou explicitly request such a tag.\n\nDisclaimer: Not affiliated with the providers\nnor responsible for any of their content.',
tooltipText: getString('Type tags for a random pic.\nNSFW content will not be returned unless\nyou explicitly request such a tag.\n\nDisclaimer: Not affiliated with the providers\nnor responsible for any of their content.'),
setup: setupCursorHoverInfo,
}),
]
@@ -368,7 +369,7 @@ export const waifuCommands = Box({
self.pack_start(Button({
className: 'sidebar-chat-chip-toggle',
setup: setupCursorHover,
label: 'Tags →',
label: getString('Tags →'),
onClicked: () => {
waifuTags.revealChild = !waifuTags.revealChild;
}
+7 -6
View File
@@ -17,6 +17,7 @@ const TextView = Widget.subclass(Gtk.TextView, "AgsTextView");
import { widgetContent } from './sideleft.js';
import { IconTabContainer } from '../.commonwidgets/tabcontainer.js';
import { getString } from '../../i18n/i18n.js';
const EXPAND_INPUT_THRESHOLD = 30;
const APILIST = {
@@ -26,7 +27,7 @@ const APILIST = {
contentWidget: geminiView,
commandBar: geminiCommands,
tabIcon: geminiTabIcon,
placeholderText: 'Message Gemini...',
placeholderText: getString('Message Gemini...'),
},
'gpt': {
name: 'Assistant (GPTs)',
@@ -34,7 +35,7 @@ const APILIST = {
contentWidget: chatGPTView,
commandBar: chatGPTCommands,
tabIcon: chatGPTTabIcon,
placeholderText: 'Message the model...',
placeholderText: getString('Message the model...'),
},
'waifu': {
name: 'Waifus',
@@ -42,7 +43,7 @@ const APILIST = {
contentWidget: waifuView,
commandBar: waifuCommands,
tabIcon: waifuTabIcon,
placeholderText: 'Enter tags',
placeholderText: getString('Enter tags'),
},
'booru': {
name: 'Booru',
@@ -50,7 +51,7 @@ const APILIST = {
contentWidget: booruView,
commandBar: booruCommands,
tabIcon: booruTabIcon,
placeholderText: 'Enter tags',
placeholderText: getString('Enter tags'),
},
}
const APIS = userOptions.sidebar.pages.apis.order.map((apiName) => APILIST[apiName]);
@@ -83,11 +84,11 @@ export const chatEntry = TextView({
})
.hook(GPTService, (self) => {
if (APIS[currentApiId].name != 'Assistant (GPTs)') return;
self.placeholderText = (GPTService.key.length > 0 ? 'Message the model...' : 'Enter API Key...');
self.placeholderText = (GPTService.key.length > 0 ? getString('Message the model...') : getString('Enter API Key...'));
}, 'hasKey')
.hook(Gemini, (self) => {
if (APIS[currentApiId].name != 'Assistant (Gemini Pro)') return;
self.placeholderText = (Gemini.key.length > 0 ? 'Message Gemini...' : 'Enter Google AI API Key...');
self.placeholderText = (Gemini.key.length > 0 ? getString('Message Gemini...') : getString('Enter Google AI API Key...'));
}, 'hasKey')
.on("key-press-event", (widget, event) => {
// Don't send when Shift+Enter
@@ -12,6 +12,7 @@ import { setupCursorHover } from '../../.widgetutils/cursorhover.js';
import { ColorPickerSelection, hslToHex, hslToRgbValues, hexToHSL } from './color.js';
import { clamp } from '../../.miscutils/mathfuncs.js';
import { getString } from '../../../i18n/i18n.js';
export default () => {
const selectedColor = new ColorPickerSelection();
@@ -174,7 +175,7 @@ export default () => {
css: `background-color: ${hslToHex(selectedColor.hue, selectedColor.xAxis, selectedColor.yAxis / (1 + selectedColor.xAxis / 100))};`,
children: [Label({
className: 'txt txt-small',
label: 'Result',
label: getString('Result'),
}),],
attribute: {
update: (self) => {
@@ -269,7 +270,7 @@ export default () => {
})
return SidebarModule({
icon: MaterialIcon('colorize', 'norm'),
name: '<span strikethrough="true">Inaccurate</span> Color picker',
name: getString('<span strikethrough="true">Inaccurate</span> Color picker'),
revealChild: false,
child: Box({
className: 'spacing-h-5',
+2 -1
View File
@@ -3,6 +3,7 @@ import App from 'resource:///com/github/Aylur/ags/app.js';
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
import { setupCursorHover } from '../../.widgetutils/cursorhover.js';
import { getString } from '../../../i18n/i18n.js';
const { execAsync, exec } = Utils;
const { Box, Button, CenterBox, EventBox, Icon, Label, Scrollable } = Widget;
@@ -10,7 +11,7 @@ export default () => Box({
className: 'txt sidebar-module techfont',
children: [
Label({
label: 'illogical-impulse'
label: getString('illogical-impulse')
}),
Box({ hexpand: true }),
Button({
@@ -9,53 +9,54 @@ import { MaterialIcon } from '../../.commonwidgets/materialicon.js';
import { setupCursorHover } from '../../.widgetutils/cursorhover.js';
import { distroID, isArchDistro, isDebianDistro, hasFlatpak } from '../../.miscutils/system.js';
import { getString } from '../../../i18n/i18n.js';
const scripts = [
{
icon: 'desktop-symbolic',
name: 'Change screen resolution',
command: `bash ${App.configDir}/modules/sideleft/tools/changeres.sh`,
enabled: true,
},
icon: 'desktop-symbolic',
name: getString('Change screen resolution'),
command: `bash ${App.configDir}/modules/sideleft/tools/changeres.sh`,
enabled: true,
},
{
icon: 'nixos-symbolic',
name: 'Trim system generations to 5',
name: getString('Trim system generations to 5'),
command: `sudo ${App.configDir}/scripts/quickscripts/nixos-trim-generations.sh 5 0 system`,
enabled: distroID == 'nixos',
},
{
icon: 'nixos-symbolic',
name: 'Trim home manager generations to 5',
name: getString('Trim home manager generations to 5'),
command: `${App.configDir}/scripts/quickscripts/nixos-trim-generations.sh 5 0 home-manager`,
enabled: distroID == 'nixos',
},
{
icon: 'ubuntu-symbolic',
name: 'Update packages',
name: getString('Update packages'),
command: `sudo apt update && sudo apt upgrade -y`,
enabled: isDebianDistro,
},
{
icon: 'fedora-symbolic',
name: 'Update packages',
name: getString('Update packages'),
command: `sudo dnf upgrade -y`,
enabled: distroID == 'fedora',
},
{
icon: 'arch-symbolic',
name: 'Update packages',
name: getString('Update packages'),
command: `sudo pacman -Syyu`,
enabled: isArchDistro,
},
{
icon: 'arch-symbolic',
name: 'Remove orphan packages',
name: getString('Remove orphan packages'),
command: `sudo pacman -R $(pacman -Qdtq)`,
enabled: isArchDistro,
},
{
icon: 'flatpak-symbolic',
name: 'Uninstall unused flatpak packages',
name: getString('Uninstall unused flatpak packages'),
command: `flatpak uninstall --unused`,
enabled: hasFlatpak,
},
@@ -63,7 +64,7 @@ const scripts = [
export default () => SidebarModule({
icon: MaterialIcon('code', 'norm'),
name: 'Quick scripts',
name: getString('Quick scripts'),
child: Box({
vertical: true,
className: 'spacing-v-5',