Skip to content

Commit 9e7c2f5

Browse files
committed
Merge remote-tracking branch 'origin/master' into jupyter-llm-8500
2 parents 7e77995 + 5113a32 commit 9e7c2f5

File tree

22 files changed

+799
-222
lines changed

22 files changed

+799
-222
lines changed

src/.claude/commands/update-i18n.md

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: 11 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,14 @@
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",
40+
"mcp__github__get_pull_request_comments",
41+
"mcp__github__get_pull_request",
42+
"mcp__github__get_issue_comments",
43+
"mcp__github__get_pull_request_comments",
3644
"mcp__cclsp__find_definition"
3745
],
3846
"deny": []

src/CLAUDE.md

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,20 @@ This file provides guidance to Claude Code (claude.ai/code) and also Gemini CLI
1616
- Run `pretter -w [filename]` after modifying a file (ts, tsx, md, json, ...) to format it correctly.
1717
- All .js and .ts files are formatted by the tool prettier
1818
- Add suitable types when you write code
19-
- Variable name styles are "camelCase" for local and "FOO_BAR" for global variables. If you edit older code not following these guidlines, adjust this rule to fit the files style.
19+
- Follow DRY principles!
20+
- Variable name styles are `camelCase` for local and `FOO_BAR` for global variables. React Components and Classes are `FooBar`. If you edit older code not following these guidlines, adjust this rule to fit the files style.
2021
- Some older code is JavaScript or CoffeeScript, which will be translated to TypeScript
2122
- Use ES modules (import/export) syntax, not CommonJS (require)
2223
- 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.
24+
- **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.
2325
- **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;`
2426

2527
## Development Commands
2628

2729
### Essential Commands
2830

2931
- `pnpm build-dev` - Build all packages for development
30-
- `pnpm clean` - Clean all node_modules and dist directories
32+
- `pnpm clean` - Clean all `node_modules` and `dist` directories
3133
- `pnpm test` - Run full test suite
3234
- `pnpm depcheck` - Check for dependency issues
3335
- `python3 ./scripts/check_npm_packages.py` - Check npm package consistency across packages
@@ -38,15 +40,16 @@ This file provides guidance to Claude Code (claude.ai/code) and also Gemini CLI
3840

3941
- `cd packages/[package] && pnpm build` - Build and compile a specific package
4042
- for packages/next and packages/static, run `cd packages/[package] && pnpm build-dev`
41-
- `cd packages/[package] && pnpm tsc:watch` - TypeScript compilation in watch mode for a specific package
4243
- `cd packages/[package] && pnpm test` - Run tests for a specific package
4344
- `cd packages/[package] && pnpm build` - Build a specific package
45+
- To typecheck the frontend, it is best to run `cd packages/static && pnpm build` - this implicitly compiles the frontend and reports typescript errors
4446
- **IMPORTANT**: When modifying packages like `util` that other packages depend on, you must run `pnpm build` in the modified package before typechecking dependent packages
4547

4648
### Development
4749

4850
- **IMPORTANT**: Always run `prettier -w [filename]` immediately after editing any .ts, .tsx, .md, or .json file to ensure consistent styling
4951
- After TypeScript or `*.tsx` changes, run `pnpm build` in the relevant package directory
52+
- When editing the frontend, run `pnpm build-dev` in `packages/static`. This implicitly builds the frontend!
5053

5154
## Architecture Overview
5255

@@ -166,18 +169,34 @@ CoCalc is organized as a monorepo with key packages:
166169

167170
CoCalc uses react-intl for internationalization with SimpleLocalize as the translation platform.
168171

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

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

173183
Examples:
184+
174185
- `labels.masked_files` - for common UI labels
175186
- `account.sign-out.button.title` - for account sign-out dialog
176187
- `command.generic.force_build.label` - for command labels
177188

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

180198
**For new translation keys:**
199+
181200
1. Add the translation to source code (e.g., `packages/frontend/i18n/common.ts`)
182201
2. Run `pnpm i18n:extract` - updates `extracted.json` from source code
183202
3. Run `pnpm i18n:upload` - sends new strings to SimpleLocalize
@@ -190,14 +209,22 @@ Same flow as above, but **before 3. i18n:upload**, delete the key. Only new keys
190209

191210
### Translation File Structure
192211

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

199219
# Ignore
200220

201221
- Ignore files covered by `.gitignore`
202222
- Ignore everything in `node_modules` or `dist` directories
203223
- Ignore all files not tracked by Git, unless they are newly created files
224+
225+
# important-instruction-reminders
226+
227+
Do what has been asked; nothing more, nothing less.
228+
NEVER create files unless they're absolutely necessary for achieving your goal.
229+
ALWAYS prefer editing an existing file to creating a new one.
230+
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export function I18NSelector(props: Readonly<Props>) {
167167

168168
const menu: MenuProps = {
169169
items,
170-
style: { maxHeight: "75vh", overflow: "auto" },
170+
style: { maxHeight: "50vh", overflow: "auto" },
171171
onClick: ({ key }) => {
172172
if (key in LOCALIZATIONS) {
173173
if (confirm) {

0 commit comments

Comments
 (0)