Skip to content

Commit

Permalink
improvements: Use translated strings for filters
Browse files Browse the repository at this point in the history
Static maps for all category and Language filter strings
style change for "No results" label
  • Loading branch information
BharatAtbrat committed Jul 28, 2024
1 parent 84afab8 commit 9bd062b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/Library/Library.blp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@ Adw.Window window {
margin-top: 46;
margin-bottom: 70;
label: _("No results");

styles [
"title-4"
]
}

Label {
Expand Down
25 changes: 23 additions & 2 deletions src/Library/Library.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { createSessionFromDemo } from "../sessions.js";
import EntryRow from "./EntryRow.js";

import illustration from "./library.svg";
import { gettext as _ } from "gettext";

import { build } from "../../troll/src/builder.js";

Expand Down Expand Up @@ -54,17 +55,37 @@ export default function Library({ application }) {
const language_check = ["All Languages"];
const category_check = ["All Categories"];

const language_labels = {
javascript: _("JavaScript"),
python: _("Python"),
rust: _("Rust"),
vala: _("Vala"),
typescript: _("TypeScript"),
};

const category_labels = {
user_interface: _("User Interface"),
platform: _("Platform APIs"),
controls: _("Controls"),
feedback: _("Feedback"),
layout: _("Layout"),
network: _("Network"),
navigation: _("Navigation"),
tools: _("Tools"),
uncategorized: _("Uncategorized"),
};

demos.forEach((demo) => {
demo.languages.forEach((lang) => {
if (!language_check.includes(lang)) {
language_check.push(lang);
language_model.append(lang);
language_model.append(language_labels[lang]);
}
});

if (!category_check.includes(demo.category)) {
category_check.push(demo.category);
category_model.append(demo.category);
category_model.append(category_labels[demo.category]);
}

const entry_row = new EntryRow({ demo: demo });
Expand Down

0 comments on commit 9bd062b

Please sign in to comment.