From 3c59be763a2264b45120ec3aa7b247ee5b7ba889 Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Tue, 17 Feb 2026 19:41:03 +0100 Subject: [PATCH] Add translation guidelines and coding tips to documentation --- .windsurf/rules/next.md | 42 +++++++++++++++++++++++++++++++++++++++++ docs/knowledge.md | 11 +++++++++++ 2 files changed, 53 insertions(+) create mode 100644 .windsurf/rules/next.md diff --git a/.windsurf/rules/next.md b/.windsurf/rules/next.md new file mode 100644 index 00000000..fa377ded --- /dev/null +++ b/.windsurf/rules/next.md @@ -0,0 +1,42 @@ +--- +trigger: manual +description: +globs: +--- + +### Translations + +```typescript +import {useT} from "web/lib/locale"; + +const t = useT() +t("common.key", "English translations") +``` + +Translations should go to the JSON files in `web/messages` (`de.json` and `fr.json`, as of now). + +### Misc coding tips + +We have many useful hooks that should be reused rather than rewriting them again. + +--- + +We prefer using lodash functions instead of reimplementing them with for loops: + +```ts +import {keyBy, uniq} from 'lodash' + +const betsByUserId = keyBy(bets, 'userId') +const betIds = uniq(bets, (b) => b.id) +``` + +--- + +Instead of Sets, consider using lodash's uniq function: + +```ts +const betIds = uniq([]) +for (const id of betIds) { +... +} +``` diff --git a/docs/knowledge.md b/docs/knowledge.md index 8c85d45f..25883a70 100644 --- a/docs/knowledge.md +++ b/docs/knowledge.md @@ -424,6 +424,17 @@ const res = await pg.manyOrNone(query) Use these functions instead of string concatenation. +### Translations + +```typescript +import {useT} from "web/lib/locale"; + +const t = useT() +t("common.key", "English translations") +``` + +Translations should go to the JSON files in `web/messages` (`de.json` and `fr.json`, as of now). + ### Misc coding tips We have many useful hooks that should be reused rather than rewriting them again.