Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions desktop/internal/i18n/shared.generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions desktop/internal/settingswindow/build_counts_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package settingswindow

import (
"testing"

"github.com/1lck/Lithe-IDEA/desktop/internal/i18n"
)

// TestBuildCountsUseTheSingularForOne checks the build settings texts that count
// pages, debuggers and tools: English says "1 page", not "1 pages", and other
// counts keep the plural with grouped digits.
func TestBuildCountsUseTheSingularForOne(t *testing.T) {
for _, test := range []struct {
name string
got string
want string
}{
{"one page", kindPageCount(i18n.English, 1), "1 page"},
{"pages", kindPageCount(i18n.English, 1200), "1,200 pages"},
{"no pages", kindPageCount(i18n.English, 0), "0 pages"},
{"one debugger", debuggerCount(i18n.English, 1), "1 debugger"},
{"debuggers", debuggerCount(i18n.English, 3), "3 debuggers"},
{"one stepping debugger", steppingTileDescription(i18n.English, 1, 0), "Stepping: 1 debugger supports filters"},
{"one customized stepping debugger", steppingTileDescription(i18n.English, 1, 1), "Stepping: 1 debugger supports filters · customized"},
{"stepping debuggers", steppingTileDescription(i18n.English, 2, 0), "Stepping: 2 debuggers support filters"},
{"customized stepping debuggers", steppingTileDescription(i18n.English, 2, 1), "Stepping: 2 debuggers support filters · 1 customized"},
{"one tool in the project", trustBannerText(i18n.English, 1, ".venv"), "1 tool comes from an environment inside the project (.venv). Lithe does not probe or run it until you trust the project."},
{"tools in the project", trustBannerText(i18n.English, 2, ".venv, .conda"), "2 tools come from environments inside the project (.venv, .conda). Lithe does not probe or run them until you trust the project."},
{"one issue", issuesTitle(i18n.English, 1), "1 needs attention"},
{"issues", issuesTitle(i18n.English, 2), "2 need attention"},
{"one tool from one plugin", toolchainsTileDescription(i18n.English, 1, 1, "global"), "1 tool · from 1 plugin · showing global"},
{"one tool from plugins", toolchainsTileDescription(i18n.English, 1, 2, "global"), "1 tool · from 2 plugins · showing global"},
{"tools from one plugin", toolchainsTileDescription(i18n.English, 4, 1, "global"), "4 tools · from 1 plugin · showing global"},
{"tools from plugins", toolchainsTileDescription(i18n.English, 4, 2, "global"), "4 tools · from 2 plugins · showing global"},
{"one tool listed", toolchainListCount(i18n.English, 1, 1), "1 / 1 tool"},
{"tools listed", toolchainListCount(i18n.English, 1, 3), "1 / 3 tools"},
{"one page in Chinese", kindPageCount(i18n.Chinese, 1), "1 个页面"},
{"one tool from one plugin in Chinese", toolchainsTileDescription(i18n.Chinese, 1, 1, "全局"), "1 个工具 · 来自 1 个插件 · 当前显示全局"},
{"one tool in Chinese", trustBannerText(i18n.Chinese, 1, ".venv"), "1 个工具来自项目内的环境(.venv)。信任项目之前不会探测或运行它。"},
} {
if test.got != test.want {
t.Errorf("%s = %q, want %q", test.name, test.got, test.want)
}
}
}
14 changes: 3 additions & 11 deletions desktop/internal/settingswindow/build_directory_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (w *window) buildIssues(c ui.C, language i18n.Language) {
all := false
ui.Column(c).FillWidth().MinWidth(0).Shrink(0).PadX(10).PadY(8).Radius(8).
Border(1, colors.border).Background(colors.background).Children(func() {
ui.Text(c, i18n.SharedFormat(language, "desktop.buildSettings.issuesTitle", map[string]string{"count": formatCount(view.Counts.Problems)})).
ui.Text(c, issuesTitle(language, view.Counts.Problems)).
FontSize(buildSmall).Weight(gfx.WeightSemibold).Color(colors.text).Ellipsis()
ui.Row(c).Height(4).Shrink(0)
for i := range view.Issues {
Expand Down Expand Up @@ -201,9 +201,7 @@ func (w *window) directoryEntries(language i18n.Language) []directoryEntry {
tools = t.view.view.Counts.Total
entry.problems = t.view.view.Counts.Problems
}
entry.desc = i18n.SharedFormat(language, "desktop.buildSettings.directoryToolchains", map[string]string{
"tools": formatCount(tools), "plugins": formatCount(plugins), "scope": shown,
})
entry.desc = toolchainsTileDescription(language, tools, plugins, shown)
}
entries = append(entries, entry)
}
Expand All @@ -220,13 +218,7 @@ func (w *window) directoryEntries(language i18n.Language) []directoryEntry {
customized++
}
}
if customized > 0 {
entry.desc = i18n.SharedFormat(language, "desktop.buildSettings.directoryDebuggersCustomized", map[string]string{
"count": formatCount(len(s.adapters)), "customized": formatCount(customized),
})
} else {
entry.desc = i18n.SharedFormat(language, "desktop.buildSettings.directoryDebuggers", map[string]string{"count": formatCount(len(s.adapters))})
}
entry.desc = steppingTileDescription(language, len(s.adapters), customized)
}
entries = append(entries, entry)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func TestBuildKindIsOneRowThatOpensItsPage(t *testing.T) {
t.Fatalf("the kind's page does not list %q", title)
}
}
if total := i18n.SharedFormat(i18n.English, "desktop.buildSettings.kindPageCount", map[string]string{"count": formatCount(count)}); !d.text(total) {
if total := kindPageCount(i18n.English, count); !d.text(total) {
t.Fatalf("the kind's page does not count its pages as %q", total)
}
if !d.has(i18n.Shared(i18n.English, "desktop.buildSettings.kindFilter")) {
Expand Down
2 changes: 1 addition & 1 deletion desktop/internal/settingswindow/build_kind_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (w *window) buildKindPage(c ui.C, kind string) {
w.kindList(c.Part("list"), language, kind, state)
ui.Row(c).FillWidth().Height(1).Shrink(0).Background(b.line)
ui.Row(c).FillWidth().Shrink(0).PadX(12).PadY(5).Children(func() {
ui.Text(c, i18n.SharedFormat(language, "desktop.buildSettings.kindPageCount", map[string]string{"count": formatCount(w.dynamic.kindCount(kind))})).
ui.Text(c, kindPageCount(language, w.dynamic.kindCount(kind))).
FontSize(11).Color(b.faint).Ellipsis()
})
})
Expand Down
Loading
Loading