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
32 changes: 32 additions & 0 deletions .github/workflows/validate-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Validate App

on:
pull_request:
push:
branches:
- main

jobs:
check:
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm

- name: Install dependencies
run: npm ci

- name: Run app checks
run: npm run check
Comment on lines +25 to +29
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description calls out running npm run build in validation, but this workflow only runs npm run check (currently i18n + prettier). Consider adding a build step (and/or typecheck/lint if applicable), or folding npm run build into npm run check, so CI enforces the stated validation.

Copilot uses AI. Check for mistakes.

- name: Build app
run: npm run build
22 changes: 22 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# AGENTS.md

These instructions apply to the whole repository.

## Language

- Use Australian/British English over US English.

## Frontend

- Prefer Server Components by default. Only add `"use client"` when the component needs browser-only APIs, state/effects, event handlers, or client-only libraries.
- When touching JS/JSX components, convert them to TS/TSX when it is reasonable and scoped to the change.
- Keep shared presentational components server-safe where possible. For translated labels or suffixes, prefer passing translated text from the caller instead of adding `useTranslations` to a shared component.
- In MDX prose, if an inline component inside a Markdown list item is formatted onto multiple lines and changes rendered spacing, use a targeted `{/* prettier-ignore */}` before that list rather than disabling formatting for the whole file.

## Internationalisation

- Put user-facing app UI copy in `next-intl` message files under `messages/`.
- Treat `messages/en.json` as the source catalogue. Keep Spanish (`es`) and German (`de`) complete whenever adding or changing message keys.
- Run `npm run i18n:check` after editing messages. Run `npm run check` before handing work back.
- Do not put dynamic user-generated content, internal enum values, table names, route constants, CSS strings, logs, or analytics identifiers into message files.
- For listing types and other enums, pass stable keys such as `business`, `community`, or `residential` and handle display grammar in translations, usually with ICU `select`.
363 changes: 360 additions & 3 deletions messages/de.json

Large diffs are not rendered by default.

361 changes: 359 additions & 2 deletions messages/en.json

Large diffs are not rendered by default.

363 changes: 360 additions & 3 deletions messages/es.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"supabase:reset": "supabase db reset",
"seed:local-media": "node scripts/seed-local-media.mjs",
"supabase:diff": "supabase db diff",
"i18n:check": "node scripts/check-i18n-messages.mjs",
"check": "npm run i18n:check && npm run format:check",
"format": "prettier --write .",
"format:check": "prettier --check ."
},
Expand Down
266 changes: 266 additions & 0 deletions scripts/check-i18n-messages.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,266 @@
import fs from "node:fs";
import path from "node:path";
import process from "node:process";

const rootDir = process.cwd();
const configPath = path.join(rootDir, "src/i18n/config.ts");
const messagesDir = path.join(rootDir, "messages");

function readConfig() {
const source = fs.readFileSync(configPath, "utf8");
const localesMatch = source.match(/locales\s*=\s*(\[[^\]]+\])\s*as const/);
const defaultLocaleMatch = source.match(
/defaultLocale:\s*Locale\s*=\s*["']([^"']+)["']/
);

if (!localesMatch) {
throw new Error(`Could not find the locales array in ${configPath}`);
}

const locales = JSON.parse(localesMatch[1].replaceAll("'", '"'));
const defaultLocale = defaultLocaleMatch?.[1] ?? locales[0];

if (!locales.includes(defaultLocale)) {
throw new Error(
`Default locale "${defaultLocale}" is not listed in ${configPath}`
);
}

return { locales, defaultLocale };
}

function readMessages(locale) {
const filePath = path.join(messagesDir, `${locale}.json`);

if (!fs.existsSync(filePath)) {
throw new Error(
`Missing message file: ${path.relative(rootDir, filePath)}`
);
}

return JSON.parse(fs.readFileSync(filePath, "utf8"));
}

function valueType(value) {
if (Array.isArray(value)) {
return "array";
}

if (value === null) {
return "null";
}

return typeof value;
}

function flattenMessages(value, pathParts = [], entries = new Map()) {
if (value && typeof value === "object" && !Array.isArray(value)) {
entries.set(pathParts.join("."), {
type: "object",
value,
});

for (const [key, childValue] of Object.entries(value)) {
flattenMessages(childValue, [...pathParts, key], entries);
}

return entries;
}

entries.set(pathParts.join("."), {
type: valueType(value),
value,
});

return entries;
}

function leafKeys(entries) {
return [...entries]
.filter(([, entry]) => entry.type !== "object")
.map(([key]) => key)
.sort();
}

function extractIcuArguments(message) {
const argumentsSet = new Set();

for (let index = 0; index < message.length; index += 1) {
if (message[index] !== "{") {
continue;
}

const match = message
.slice(index + 1)
.match(/^([A-Za-z_][\w]*)\s*(?:[,}])/);

if (match) {
argumentsSet.add(match[1]);
}

let depth = 1;
index += 1;

while (index < message.length && depth > 0) {
if (message[index] === "{") {
depth += 1;
} else if (message[index] === "}") {
depth -= 1;
}

index += 1;
}
}

return [...argumentsSet].sort();
}

function extractRichTextTags(message) {
const tags = new Set();
const tagPattern = /<\/?([A-Za-z][\w]*)\b[^>]*>/g;

for (const match of message.matchAll(tagPattern)) {
tags.add(match[1]);
}

return [...tags].sort();
}

function listDifference(left, right) {
const rightSet = new Set(right);
return left.filter((item) => !rightSet.has(item));
}

function sameList(left, right) {
return (
left.length === right.length &&
left.every((item, index) => item === right[index])
);
}

function formatList(items) {
return items.map((item) => `- ${item}`).join("\n");
}

function compareLocale(locale, baselineLocale, baselineEntries, localeEntries) {
const problems = [];
const baselineLeaves = leafKeys(baselineEntries);
const localeLeaves = leafKeys(localeEntries);
const missingKeys = listDifference(baselineLeaves, localeLeaves);
const extraKeys = listDifference(localeLeaves, baselineLeaves);

if (missingKeys.length > 0) {
problems.push(
`messages/${locale}.json is missing keys from messages/${baselineLocale}.json:\n${formatList(
missingKeys
)}`
);
}

if (extraKeys.length > 0) {
problems.push(
`messages/${locale}.json has extra keys not found in messages/${baselineLocale}.json:\n${formatList(
extraKeys
)}`
);
}

for (const [key, baselineEntry] of baselineEntries) {
const localeEntry = localeEntries.get(key);

if (!localeEntry) {
continue;
}

if (baselineEntry.type !== localeEntry.type) {
problems.push(
`messages/${locale}.json has a structural mismatch at "${key}": expected ${baselineEntry.type}, found ${localeEntry.type}`
);
continue;
}

if (localeEntry.type !== "string") {
continue;
}

if (localeEntry.value.trim() === "") {
problems.push(`messages/${locale}.json has an empty string at "${key}"`);
continue;
}

const baselineArguments = extractIcuArguments(baselineEntry.value);
const localeArguments = extractIcuArguments(localeEntry.value);

if (!sameList(baselineArguments, localeArguments)) {
problems.push(
`messages/${locale}.json has ICU placeholder mismatch at "${key}": expected {${baselineArguments.join(
", "
)}}, found {${localeArguments.join(", ")}}`
);
}

const baselineTags = extractRichTextTags(baselineEntry.value);
const localeTags = extractRichTextTags(localeEntry.value);

if (!sameList(baselineTags, localeTags)) {
problems.push(
`messages/${locale}.json has rich-text tag mismatch at "${key}": expected <${baselineTags.join(
">, <"
)}>, found <${localeTags.join(">, <")}>`
);
}
}

return problems;
}

function main() {
const { locales, defaultLocale } = readConfig();
const baselineMessages = readMessages(defaultLocale);
const baselineEntries = flattenMessages(baselineMessages);
const problems = [];

for (const locale of locales) {
const messages = readMessages(locale);
const entries = flattenMessages(messages);

for (const [key, entry] of entries) {
if (entry.type === "string" && entry.value.trim() === "") {
problems.push(
`messages/${locale}.json has an empty string at "${key}"`
);
}
}

if (locale === defaultLocale) {
continue;
}

problems.push(
...compareLocale(locale, defaultLocale, baselineEntries, entries)
);
}

if (problems.length > 0) {
console.error(
`i18n message check failed with ${problems.length} problem(s):`
);
console.error("");
console.error(problems.join("\n\n"));
process.exitCode = 1;
return;
}

console.log(
`i18n message check passed for ${locales.length} locale(s): ${locales.join(
", "
)}`
);
}

try {
main();
} catch (error) {
console.error(error instanceof Error ? error.message : error);
process.exitCode = 1;
}
8 changes: 5 additions & 3 deletions src/app/(core)/(interact)/(centered)/profile/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import LegalFooter from "@/components/LegalFooter";
import { styled } from "@pigment-css/react";
import { Suspense } from "react";
import Toast from "@/components/Toast";
import { getTranslations } from "next-intl/server";

export const metadata = {
title: "Profile",
};

// Keep URL-based feedback in a client leaf so server rendering is driven by auth/data only.
export default async function ProfilePage() {
const t = await getTranslations("Profile.sections");
const supabase = await createClient();
// Get the authenticated user first, then fetch profile data in parallel.
const {
Expand Down Expand Up @@ -42,17 +44,17 @@ export default async function ProfilePage() {
</NakedSection>

<Section>
<h2>Listings</h2>
<h2>{t("listings")}</h2>
<ProfileListings user={user} profile={profile} listings={listings} />
</Section>

<Section>
<h2>Account</h2>
<h2>{t("account")}</h2>
<ProfileAccountSettings user={user} profile={profile} />
</Section>

<Section>
<h2>Actions</h2>
<h2>{t("actions")}</h2>
<ProfileActions listings={listings} />
</Section>

Expand Down
Loading
Loading