~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

The console says every word from a message, ready for other languages

Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:web/locales
.claude/skills/ui/SKILL.md+10−0
@@ -127,6 +127,16 @@ than inventing.
## House rules
**Messages.** Every word on a page is a message in
`web/messages/en.json`, called as `m.<key>()` (keys start with the
component's name: `invites_empty_title`), so the rules below are held
there. A sentence is one message, with its parameters (`{group}`) and
any component inside it as markup (`{#person/} loses access to
{group}.`, drawn by `ParaglideMessage`), never pieces joined, as other
languages order words their own way. A count is a plural message. A
refusal from the host is said by its error's name (`#lib/errors.ts`).
`node harness/strings.mjs` finds words written into markup.
**Case.** Sentence case everywhere: buttons, links, headings, menu
items, field labels, dialog titles, notes and errors ("Invite someone",
"Asking to join", "Sign out"). Only the first word and proper nouns take
.knotless/workflows/web.yml+4−1
@@ -2,7 +2,8 @@
# harness and the docs site are formatted as `just fmt` leaves them
# (oxfmt), that each component uses only its own layer and those below
# (harness/layers.mjs), that every dialog's title is its own fixed words
# (harness/dialogs.mjs), the SDK's types and tests (packages/sdk, which the
# (harness/dialogs.mjs), that every word a page shows is a message
# (harness/strings.mjs), the SDK's types and tests (packages/sdk, which the
# site shell builds on), and svelte-check, which fails on any warning. The
# packages are kept between runs and installed again only when a lockfile
# changes.
@@ -32,6 +33,8 @@ steps:
run: node harness/layers.mjs
- name: dialogs
run: node harness/dialogs.mjs
- name: strings
run: node harness/strings.mjs
- name: sdk check
run: cd packages/sdk && npm run check
- name: sdk test
crates/group-host/src/moderation.rs+17−3
@@ -728,7 +728,10 @@ impl Host {
}
/// Defines one of the group's own labels, or changes one it defines, in
/// its labeler, the label among the values it applies.
/// its labeler, the label among the values it applies. A change replaces
/// how apps show it but only the name and description in the given
/// language: the definition keeps its other languages, in their order,
/// and a new language goes after them.
pub async fn put_label_definition(
State(host): State<Arc<Host>>,
headers: HeaderMap,
@@ -742,17 +745,28 @@ pub async fn put_label_definition(
return Err(invalid("label is lowercase letters and hyphens"));
}
let or = |key: &str, unless: &str| body[key].as_str().unwrap_or(unless).to_string();
let lang = or("lang", "en");
let labeler = host.labeler_of(group)?;
let mut locales: Vec<Value> = labeler["policies"]["labelValueDefinitions"]
.as_array()
.and_then(|ds| ds.iter().find(|d| d["identifier"] == label))
.and_then(|d| d["locales"].as_array().cloned())
.unwrap_or_default();
let locale = json!({"lang": lang, "name": body["name"], "description": body["description"]});
match locales.iter_mut().find(|l| l["lang"] == lang.as_str()) {
Some(same) => *same = locale,
None => locales.push(locale),
}
let mut definition = json!({
"identifier": label,
"severity": or("severity", "inform"),
"blurs": or("blurs", "none"),
"defaultSetting": or("defaultSetting", "warn"),
"locales": [{"lang": or("lang", "en"), "name": body["name"], "description": body["description"]}],
"locales": locales,
});
if body["adultOnly"] == true {
definition["adultOnly"] = json!(true);
}
let labeler = host.labeler_of(group)?;
let defined = definition.clone();
let change = |values: &mut Vec<Value>, definitions: &mut Vec<Value>| {
if !values.contains(&json!(label)) {
crates/group-host/tests/moderation.rs+25−1
@@ -961,8 +961,28 @@ async fn defines_the_groups_own_labels_for_one_who_configures_it() {
let again = json!({"group": did, "label": "troll", "name": "Troll", "description": "Baits people.", "lang": "sl", "severity": "alert", "blurs": "content", "defaultSetting": "hide", "adultOnly": true});
let (_, changed) = call(&h, &alice, "putLabelDefinition", again).await;
assert_eq!(changed["adultOnly"], true);
assert_eq!(changed["locales"][0]["lang"], "sl");
assert_eq!(changed["severity"], "alert");
// It keeps its English name beside the Slovenian one.
assert_eq!(changed["locales"][0]["lang"], "en");
assert_eq!(changed["locales"][1]["lang"], "sl");
assert_eq!(labels().await, json!([changed]));
// A French name joins them, and a new English one replaces only the
// English, in its place.
let fr = json!({"group": did, "label": "troll", "name": "Troll (fr)", "description": "Cherche la bagarre.", "lang": "fr"});
let (status, _) = call(&h, &alice, "putLabelDefinition", fr).await;
assert_eq!(status, 200);
let en = json!({"group": did, "label": "troll", "name": "Provoker", "description": "Stirs things up."});
let (status, changed) = call(&h, &alice, "putLabelDefinition", en).await;
assert_eq!(status, 200);
let fr = json!({"lang": "fr", "name": "Troll (fr)", "description": "Cherche la bagarre."});
assert_eq!(
changed["locales"],
json!([
{"lang": "en", "name": "Provoker", "description": "Stirs things up."},
{"lang": "sl", "name": "Troll", "description": "Baits people."},
fr,
])
);
let meta = meta_space(&did);
let labeler = h
.host
@@ -973,6 +993,10 @@ async fn defines_the_groups_own_labels_for_one_who_configures_it() {
json!(["!hide", "!takedown", "troll"])
);
assert_eq!(labeler["subjectTypes"], json!(["account", "record"]));
assert_eq!(
labeler["policies"]["labelValueDefinitions"],
json!([changed])
);
// atproto's own values, and anything else, are not the group's to define.
for label in ["!hide", "Troll", "spam bot", ""] {
let body = json!({"group": did, "label": label, "name": "x", "description": "x"});
docs/design/moderation.md+3−1
@@ -209,7 +209,9 @@ should show what wears it (`severity`, `blurs`, `defaultSetting`,
defines, and none of its own.
`putLabelDefinition` defines one, or changes the one with that value,
and adds it to the values the labeler applies. `deleteLabelDefinition`
and adds it to the values the labeler applies. A change replaces its
name and meaning in one language and keeps the others, so naming a
label in French leaves its English name. `deleteLabelDefinition`
takes both away, and labels already applied stay. Each needs
`group.configure`, and writes the labeler as the group, like any change
to its meta space. A group's own label is lowercase letters and hyphens,
docs/guides/shots/recovery-added-dark.png+0−0
A binary file, not shown.
docs/guides/shots/recovery-added.png+0−0
A binary file, not shown.
docs/guides/shots/recovery-dialog-dark.png+0−0
A binary file, not shown.
docs/guides/shots/recovery-dialog.png+0−0
A binary file, not shown.
docs/guides/shots/recovery-refused-dark.png+0−0
A binary file, not shown.
docs/guides/shots/recovery-refused.png+0−0
A binary file, not shown.
docs/guides/shots/recovery-refused.txt+1−1
@@ -6,6 +6,6 @@
- textbox "A key of yours, as a did:key":
- /placeholder: did:key:z…
- text: did:key:<key>
- paragraph: not a did:key the directory takes (secp256k1 or P-256)
- paragraph: That isn’t a key this host takes. Use a did:key for secp256k1 or P-256.
- button "Cancel"
- button "Add"
docs/guides/shots/recovery-removed-dark.png+0−0
A binary file, not shown.
docs/guides/shots/recovery-removed.png+0−0
A binary file, not shown.
docs/guides/shots/recovery-tab-dark.png+0−0
A binary file, not shown.
docs/guides/shots/recovery-tab.png+0−0
A binary file, not shown.
docs/guides/shots/starting-card-done-dark.png+0−0
A binary file, not shown.
docs/guides/shots/starting-words.txt+9−9
@@ -226,13 +226,13 @@
- option "South Sudan"
- option "Spain"
- option "Sri Lanka"
- option "St. Barthélemy"
- option "St. Helena"
- option "St. Kitts & Nevis"
- option "St. Lucia"
- option "St. Martin"
- option "St. Pierre & Miquelon"
- option "St. Vincent & Grenadines"
- option "St Barthélemy"
- option "St Helena"
- option "St Kitts & Nevis"
- option "St Lucia"
- option "St Martin"
- option "St Pierre & Miquelon"
- option "St Vincent & the Grenadines"
- option "Sudan"
- option "Suriname"
- option "Svalbard & Jan Mayen"
@@ -253,14 +253,14 @@
- option "Turkmenistan"
- option "Turks & Caicos Islands"
- option "Tuvalu"
- option "U.S. Outlying Islands"
- option "U.S. Virgin Islands"
- option "Uganda"
- option "Ukraine"
- option "United Arab Emirates"
- option "United Kingdom"
- option "United States"
- option "Uruguay"
- option "US Outlying Islands"
- option "US Virgin Islands"
- option "Uzbekistan"
- option "Vanuatu"
- option "Vatican City"
docs/guides/recovery-keys.md+1−1
@@ -104,7 +104,7 @@ The dialog stays open, and the reason shows in a pink box under the
field.
<!-- look /g/choir.groups.test/settings/recovery --as erin --click 'button[popovertarget=add-key]' --type '#add-key [name=key]=did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK' --click '#add-key button[type=submit]' --element ':popover-open' -->
![The Add a recovery key dialog with a key of another kind in the field and, under it, not a did:key the directory takes (secp256k1 or P-256)](shots/recovery-refused.png)
![The Add a recovery key dialog with a key of another kind in the field and, under it, the reason: that isn’t a key this host takes, so use a did:key for secp256k1 or P-256](shots/recovery-refused.png)
It refuses a key in these cases:
docs/reference/api.md+1−1
@@ -218,7 +218,7 @@ Its tools are in [MCP tools](mcp.md).
| `GET fyi.opensocial.listSubjects` | lists the moderation queue for one status, `open` by default |
| `GET fyi.opensocial.getSubjectHistory` | lists a subject's events, oldest first, a page at a time. With a `cid`, it lists those about that version |
| `POST fyi.opensocial.resolveSubject` | sets a subject `resolved` or `escalated`, with an optional note, and answers the subject |
| `POST fyi.opensocial.putLabelDefinition` | defines or changes one of the group's own labels (lowercase letters and hyphens) in its labeler, for someone with `group.configure`. It answers the definition, and `getGroup` answers them as `labels` |
| `POST fyi.opensocial.putLabelDefinition` | defines or changes one of the group's own labels (lowercase letters and hyphens) in its labeler, for someone with `group.configure`. Its name and description are in `lang` (`en` unless given), and replace only those in that language. It answers the definition, and `getGroup` answers them as `labels` |
| `POST fyi.opensocial.deleteLabelDefinition` | stops defining one. Labels already applied stay |
## Operating the host
docs/development.md+31−1
@@ -123,6 +123,34 @@ light and phone dark unless you ask otherwise. It tells you when a page
is wider than the screen, naming the element that runs past its edge.
Its options are at the top of `harness/look/look.mjs`.
## The console's languages
Every word the console shows is a message in `web/messages/en.json`,
compiled by [Paraglide](https://paraglidejs.com) into functions under
`web/src/lib/paraglide` (made as the console builds, and by `npm run
i18n`, not kept in git). A page calls one as `m.invites_empty_title()`.
`node harness/strings.mjs` fails on words written straight into a
component. English is the only language so far.
Each request's language is the one the `PARAGLIDE_LOCALE` cookie names,
else the first of the browser's `Accept-Language` the console has, else
English. The page's `<html lang>` and `dir` say it. Dates, lists, and
countries' and languages' names follow it (`#lib/locale.ts`), and a
label shows its name in it when the group gave one. Times stay in UTC,
since the page is drawn on the server. The host's own error messages
stay English, and the console says each by its name (`#lib/errors.ts`).
A few names (`InvalidRequest`, `InvalidHandle`, `InvalidSite`,
`InvalidArchive`, `UpstreamFailure`) cover several reasons the reader
needs to tell apart, so for those the console shows the host's message.
A language other than English needs the host to give each such reason
a name of its own first.
Adding a language takes three changes. Add it to `locales` in
`web/project.inlang/settings.json`, add `web/messages/<language>.json`
with every key `en.json` has, and add its `Intl` locale to `INTL` in
`web/src/lib/locale.ts`. `web/src/app.css` lays pages out by left and
right, so a right-to-left language needs that changed first.
## The guides' pictures
A guide (`docs/guides/`) shows the console with pictures. `just look`
@@ -196,7 +224,9 @@ docs-deploy` after a change to the docs lands.
That's `cargo fmt --check`, `oxfmt --check`, clippy with warnings
denied, the console's component layers (`harness/layers.mjs`), a check
that no dialog's title holds a name or anything typed
(`harness/dialogs.mjs`), and svelte-check.
(`harness/dialogs.mjs`), a check that no component writes words into
its markup rather than saying a message (`harness/strings.mjs`), and
svelte-check.
`just fmt` formats everything the checks hold to a format. It formats
the Rust with rustfmt, and the console, the harness and the docs site
harness/e2e/flows.spec.mjs+4−0
harness/dialogs.mjs+6−2
harness/strings.mjsnew+113−0
lexicons/fyi/opensocial/putLabelDefinition.json+4−4
web/messages/en.jsonnew+745−0
745 lines changed: not loaded until asked for.
web/project.inlang/settings.jsonnew+9−0
web/shell/shell.ts+3−2
web/shell/vite.config.ts+3−1
web/src/lib/atoms/Copy.svelte+4−1
web/src/lib/molecules/BackToApp.svelte+8−2
web/src/lib/molecules/ConfirmDialog.svelte+3−1
web/src/lib/molecules/DeleteGroup.svelte+8−3
web/src/lib/molecules/Dialog.svelte+2−1
web/src/lib/molecules/Facts.svelte+13−3
web/src/lib/molecules/FormDialog.svelte+2−1
web/src/lib/molecules/HandleInput.svelte+2−1
web/src/lib/molecules/LeaveGuard.svelte+5−4
web/src/lib/molecules/Links.svelte+2−1
web/src/lib/molecules/MoveSignIn.svelte+4−3
web/src/lib/molecules/Permissions.svelte+31−18
web/src/lib/molecules/PickMany.svelte+7−8
web/src/lib/molecules/Rules.svelte+2−1
web/src/lib/molecules/SaveBar.svelte+7−4
web/src/lib/molecules/SignIn.svelte+2−1
web/src/lib/molecules/Standing.svelte+12−7
web/src/lib/molecules/SubjectHistory.svelte+7−4
web/src/lib/molecules/SwitchedOff.svelte+8−5
web/src/lib/molecules/UserMenu.svelte+19−10
web/src/lib/organisms/AccountMove.svelte+22−17
web/src/lib/organisms/AppPasswords.svelte+40−16
web/src/lib/organisms/AuthorizeRequest.svelte+34−22
web/src/lib/organisms/ConnectAiApp.svelte+8−7
web/src/lib/organisms/ConnectedApps.svelte+7−8
web/src/lib/organisms/FindAccount.svelte+4−3
web/src/lib/organisms/GroupActivity.svelte+12−9
web/src/lib/organisms/GroupApps.svelte+24−15
web/src/lib/organisms/GroupHandle.svelte+25−16
web/src/lib/organisms/GroupList.svelte+2−1
web/src/lib/organisms/GroupSite.svelte+53−50
web/src/lib/organisms/Invitations.svelte+6−3
web/src/lib/organisms/InviteDialog.svelte+14−5
web/src/lib/organisms/Invites.svelte+3−4
web/src/lib/organisms/JoinPanel.svelte+19−18
web/src/lib/organisms/JoinRequests.svelte+4−3
web/src/lib/organisms/LabelsEditor.svelte+47−33
web/src/lib/organisms/LinksEditor.svelte+21−7
web/src/lib/organisms/MemberList.svelte+37−26
web/src/lib/organisms/ModerationQueue.svelte+23−9
web/src/lib/organisms/NewGroupForm.svelte+14−11
web/src/lib/organisms/ProfileForm.svelte+26−23
web/src/lib/organisms/ProfilePictures.svelte+15−11
web/src/lib/organisms/RecoveryKeys.svelte+13−10
web/src/lib/organisms/ReportDialog.svelte+15−6
web/src/lib/organisms/ReviewDialog.svelte+43−41
web/src/lib/organisms/RolesEditor.svelte+29−13
web/src/lib/organisms/RulesEditor.svelte+20−8
web/src/lib/organisms/SignInDialog.svelte+10−8
web/src/lib/organisms/SiteDomain.svelte+31−14
web/src/lib/organisms/SiteFooter.svelte+2−1
web/src/lib/organisms/SwitchOff.svelte+6−5
web/src/lib/organisms/Visibility.svelte+7−7
web/src/lib/server/settings.ts+22−32
web/src/lib/server/site.ts+2−1
web/src/lib/activity.ts+56−25
web/src/lib/asGroup.ts+2−3
web/src/lib/data.ts+9−8
web/src/lib/dates.ts+28−18
web/src/lib/errors.tsnew+131−0
web/src/lib/forms.ts+5−4
web/src/lib/labels.tsnew+20−0
web/src/lib/locale.tsnew+34−0
web/src/lib/moderation.ts+24−16
web/src/lib/permissions.ts+39−44
web/src/lib/places.ts+14−13
web/src/lib/reasons.ts+11−9
web/src/lib/saving.svelte.ts+2−1
web/src/routes/authorize/+page.server.ts+2−1
web/src/routes/authorize/+page.svelte+5−4
web/src/routes/g/[handle]/moderation/+page.server.ts+5−3
web/src/routes/g/[handle]/moderation/+page.svelte+20−8
web/src/routes/g/[handle]/settings/apps/+page.svelte+10−6
web/src/routes/g/[handle]/settings/labels/+page.svelte+8−5
web/src/routes/g/[handle]/settings/recovery/+page.svelte+11−7
web/src/routes/g/[handle]/settings/roles/+page.svelte+8−5
web/src/routes/g/[handle]/settings/rules/+page.svelte+8−5
web/src/routes/g/[handle]/settings/site/+page.svelte+15−10
web/src/routes/g/[handle]/settings/+layout.svelte+22−12
web/src/routes/g/[handle]/settings/+page.svelte+17−14
web/src/routes/g/[handle]/+page.server.ts+2−1
web/src/routes/g/[handle]/+page.svelte+20−17
web/src/routes/move/+page.server.ts+2−4
web/src/routes/move/+page.svelte+6−8
web/src/routes/new/+page.server.ts+2−4
web/src/routes/new/+page.svelte+11−5
web/src/routes/+error.svelte+9−8
web/src/routes/+page.svelte+7−6
web/src/app.html+1−1
web/src/hooks.server.ts+20−1
web/package-lock.json+1040−47
1087 lines changed: not loaded until asked for.
web/package.json+5−1
web/paraglide.tsnew+16−0
web/tsconfig.json+1−1
web/vite.config.ts+2−0
.gitignore+1−0
AGENTS.md+11−2
Justfile+1−0