mahiro233 on Discord (v0.1.3372, Kiro plugin 0.1.34): in a Chinese
window, the Kiro sheet's "Choose a sign-in method" and its choices read in
English, while the rest of the sheet is Chinese. magpie showed a plugin's
method labels, questions and choices only as the plugin wrote them, and no
plugin had a way to give them in another language.
A plugin may now give them by language, magpie's own fields beside
OpenCode's English, as a page gives its titles: a method's labels, a
question's messages, a select option's labels and hints, each
{"zh": "…", "zh-TW": "…", "ja": "…", "de": "…"}. host.js passes them on
(byLang: string values, codes of 1-16 characters, at most 16, empty ones
left out); plugin.Method and plugin.Prompt carry them; the app shows the
window's language, then its first part, else the English (inLang), on the
way picker, a question, its choices and their hints, a key's field and
the site step's other ways. `magpie plugin login` stays English. Kiro
0.1.35 gives its words in all four (plugins 588b3611).
Tests: TestPluginSignInWordsByLanguage (a plugin's words reach magpie as
given, bad ones left out, none for a plugin that gives none);
TestPluginOwnIconAndKeyHint compares a Method with reflect.DeepEqual now
that it holds a map. The GUI side is checked by plugin-ask-ways.test.cjs
in the next commit.
Run on mote at this tree: gofmt -l empty; go vet ./internal/plugin
./internal/provider ./internal/gui (darwin), linux -tags nogui, windows:
ok; go test -count=1 ./internal/plugin ./internal/provider ./internal/cli:
ok. Broken by hand: with origin/main's host.js the new test fails (no
labels, messages or hints reach magpie). Not tried: a real Kiro sign-in
(no keys or passwords entered anywhere); the full suite is queued on mote
under suite.lock after the push.
34 lines
1.3 KiB
JavaScript
34 lines
1.3 KiB
JavaScript
// A plugin giving its sign-in words in other languages, magpie's own
|
|
// fields beside OpenCode's English ones: a method's labels, a question's
|
|
// messages, a choice's labels and hints ({"zh": "…"}). Words that aren't
|
|
// strings, empty ones and a list are left out; Pear gives none.
|
|
export const Quince = async () => ({
|
|
auth: {
|
|
provider: "quince",
|
|
methods: [
|
|
{
|
|
type: "oauth",
|
|
label: "Quince sign-in",
|
|
labels: { zh: "Quince 登录", "zh-TW": "Quince 登入", ja: 42, de: " " },
|
|
prompts: [{
|
|
type: "select", key: "way", message: "Choose a sign-in method",
|
|
messages: { zh: "选择登录方式", ja: "サインイン方法を選択" },
|
|
options: [
|
|
{ label: "Builder ID", value: "builderid", hint: "AWS sign-in", labels: { zh: "Builder ID(个人)" }, hints: { zh: "AWS 登录" } },
|
|
{ label: "Sign-in page", value: "portal", labels: ["not", "a", "map"] },
|
|
],
|
|
}],
|
|
authorize: async () => ({ url: "https://quince.invalid", instructions: "", method: "auto", callback: async () => ({ type: "failed" }) }),
|
|
},
|
|
{ type: "api", label: "Quince API key", labels: { zh: "Quince API Key" } },
|
|
],
|
|
},
|
|
})
|
|
|
|
export const Pear = async () => ({
|
|
auth: {
|
|
provider: "pear",
|
|
methods: [{ type: "api", label: "Pear API key" }],
|
|
},
|
|
})
|