Skip to content

Commit 32f002a

Browse files
committed
frontend/llm: record llm prompt history
1 parent a9c6ddc commit 32f002a

36 files changed

+1553
-191
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Update i18n Translations
2+
3+
Complete workflow for updating internationalization translations in CoCalc frontend.
4+
5+
## What this command does
6+
7+
This command runs the full i18n update sequence:
8+
1. **Extract** new translation strings from source code
9+
2. **Upload** them to SimpleLocalize for automatic translation to 19+ languages
10+
3. **Download** the translated files
11+
4. **Compile** them for runtime use
12+
13+
## Usage
14+
15+
```
16+
/update-i18n
17+
```
18+
19+
## Commands executed
20+
21+
Run this in `./packages/frontend/`
22+
23+
Step 1:
24+
25+
Wait for the auto-translations to finish
26+
27+
```bash
28+
pnpm i18n:extract && pnpm i18n:upload
29+
```
30+
31+
Step 2:
32+
33+
34+
```
35+
pnpm i18n:download && pnpm i18n:compile
36+
```
37+
38+
## When to use
39+
40+
- After adding new FormattedMessage components with translation IDs
41+
- After modifying existing translation strings
42+
- When preparing translations for a new feature release
43+
- When onboarding new languages
44+
45+
## Prerequisites
46+
47+
- Must be in the `packages/frontend` directory
48+
- SIMPLELOCALIZE_KEY environment variable must be set
49+
- Changes to translation strings should already be committed to source code

src/.claude/settings.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"allow": [
44
"Bash(../node_modules/.bin/tsc:*)",
55
"Bash(NODE_OPTIONS=--max-old-space-size=8192 ../node_modules/.bin/tsc --noEmit)",
6+
"Bash(bash:*)",
7+
"Bash(curl:*)",
68
"Bash(curl:*)",
79
"Bash(docker run:*)",
810
"Bash(find:*)",
@@ -19,8 +21,10 @@
1921
"Bash(npx tsc:*)",
2022
"Bash(pnpm build:*)",
2123
"Bash(pnpm i18n:*)",
24+
"Bash(pnpm list:*)",
2225
"Bash(pnpm ts-build:*)",
2326
"Bash(pnpm tsc:*)",
27+
"Bash(pnpm why:*)",
2428
"Bash(prettier -w:*)",
2529
"Bash(psql:*)",
2630
"WebFetch(domain:cocalc.com)",
@@ -29,10 +33,10 @@
2933
"WebFetch(domain:github.com)",
3034
"WebFetch(domain:mistral.ai)",
3135
"WebFetch(domain:simplelocalize.io)",
32-
"Bash(pnpm list:*)",
33-
"Bash(pnpm why:*)",
34-
"mcp__github__get_issue",
3536
"WebFetch(domain:www.anthropic.com)",
37+
"WebSearch",
38+
"mcp__cclsp__find_definition",
39+
"mcp__github__get_issue",
3640
"mcp__cclsp__find_definition"
3741
],
3842
"deny": []

src/CLAUDE.md

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ This file provides guidance to Claude Code (claude.ai/code) and also Gemini CLI
2020
- Some older code is JavaScript or CoffeeScript, which will be translated to TypeScript
2121
- Use ES modules (import/export) syntax, not CommonJS (require)
2222
- Organize the list of imports in such a way: installed npm packages are on top, newline, then are imports from @cocalc's code base. Sorted alphabetically.
23+
- **Colors**: Always use the `COLORS` dictionary from `@cocalc/util/theme` for all color values. Never hardcode colors like `#f0f0f0` or `rgb(...)`. Import with `import { COLORS } from "@cocalc/util/theme";` and use predefined constants like `COLORS.GRAY_M`, `COLORS.GRAY_L`, `COLORS.GRAY_LL`, etc.
2324
- **Backend Logging**: Use `getLogger` from `@cocalc/project/logger` for logging in backend code. Do NOT use `console.log`. Example: `const L = getLogger("module:name").debug;`
2425

2526
## Development Commands
@@ -40,6 +41,7 @@ This file provides guidance to Claude Code (claude.ai/code) and also Gemini CLI
4041
- `cd packages/[package] && pnpm tsc:watch` - TypeScript compilation in watch mode for a specific package
4142
- `cd packages/[package] && pnpm test` - Run tests for a specific package
4243
- `cd packages/[package] && pnpm build` - Build a specific package
44+
- To typecheck the frontend, it is best to run `cd packages/static && pnpm build` - this implicitly compiles the frontend and reports typescript errors
4345
- **IMPORTANT**: When modifying packages like `util` that other packages depend on, you must run `pnpm build` in the modified package before typechecking dependent packages
4446

4547
### Development
@@ -165,18 +167,34 @@ CoCalc is organized as a monorepo with key packages:
165167

166168
CoCalc uses react-intl for internationalization with SimpleLocalize as the translation platform.
167169

170+
### Architecture Overview
171+
172+
- **Library**: Uses `react-intl` library with `defineMessages()` and `defineMessage()`
173+
- **Default Language**: English uses `defaultMessage` directly - no separate English translation files
174+
- **Supported Languages**: 19+ languages including German, Chinese, Spanish, French, Italian, Dutch, Russian, Japanese, Portuguese, Korean, Polish, Turkish, Hebrew, Hindi, Hungarian, Arabic, and Basque
175+
- **Translation Platform**: SimpleLocalize with OpenAI GPT-4o for automatic translations
176+
168177
### Translation ID Naming Convention
169178

170179
Translation IDs follow a hierarchical pattern: `[directory].[subdir].[filename].[aspect].[label|title|tooltip|...]`
171180

172181
Examples:
182+
173183
- `labels.masked_files` - for common UI labels
174184
- `account.sign-out.button.title` - for account sign-out dialog
175185
- `command.generic.force_build.label` - for command labels
176186

187+
### Usage Patterns
188+
189+
- **TSX Components**: `<FormattedMessage id="..." defaultMessage="..." />`
190+
- **Data Structures**: `defineMessage({id: "...", defaultMessage: "..."})`
191+
- **Programmatic Use**: `useIntl()` hook + `intl.formatMessage()`
192+
- **Non-React Contexts**: `getIntl()` function
193+
177194
### Translation Workflow
178195

179196
**For new translation keys:**
197+
180198
1. Add the translation to source code (e.g., `packages/frontend/i18n/common.ts`)
181199
2. Run `pnpm i18n:extract` - updates `extracted.json` from source code
182200
3. Run `pnpm i18n:upload` - sends new strings to SimpleLocalize
@@ -189,14 +207,22 @@ Same flow as above, but **before 3. i18n:upload**, delete the key. Only new keys
189207

190208
### Translation File Structure
191209

192-
- `packages/frontend/i18n/README.md` - more information
193-
- `packages/frontend/i18n/common.ts` - shared translation definitions
194-
- `packages/frontend/i18n/extracted.json` - auto-generated, do not edit manually
195-
- `packages/frontend/i18n/[locale].json` - downloaded translations per language
196-
- `packages/frontend/i18n/[locale].compiled.json` - compiled for runtime use
210+
- `packages/frontend/i18n/README.md` - detailed documentation
211+
- `packages/frontend/i18n/common.ts` - shared translation definitions (labels, menus, editor, jupyter, etc.)
212+
- `packages/frontend/i18n/extracted.json` - auto-extracted messages from source code
213+
- `packages/frontend/i18n/trans/[locale].json` - downloaded translations from SimpleLocalize
214+
- `packages/frontend/i18n/trans/[locale].compiled.json` - compiled translation files for runtime
215+
- `packages/frontend/i18n/index.ts` - exports and locale loading logic
197216

198217
# Ignore
199218

200219
- Ignore files covered by `.gitignore`
201220
- Ignore everything in `node_modules` or `dist` directories
202221
- Ignore all files not tracked by Git, unless they are newly created files
222+
223+
# important-instruction-reminders
224+
225+
Do what has been asked; nothing more, nothing less.
226+
NEVER create files unless they're absolutely necessary for achieving your goal.
227+
ALWAYS prefer editing an existing file to creating a new one.
228+
NEVER proactively create documentation files (\*.md) or README files. Only create documentation files if explicitly requested by the User.

src/packages/frontend/account/i18n-selector.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
/*
7-
Basically a drop-down to change the langauge (i18n localization)
7+
Basically a drop-down to change the language (i18n localization)
88
*/
99

1010
import { DownOutlined } from "@ant-design/icons";
@@ -114,7 +114,7 @@ export function I18NSelector(props: Readonly<Props>) {
114114

115115
const menu: MenuProps = {
116116
items,
117-
style: { maxHeight: "75vh", overflow: "auto" },
117+
style: { maxHeight: "50vh", overflow: "auto" },
118118
onClick: ({ key }) => {
119119
if (key in LOCALIZATIONS) {
120120
if (confirm) {

0 commit comments

Comments
 (0)