agentleFS
MicrosoftKnown publishermicrosoft/data-formulator/.cursor/rules/i18n-no-hardcoded-strings.mdc

data-formulator / rules

Cursor rule18k starsChanged 7 months agoMITView on GitHub

No hardcoded UI strings — use i18n translation keys

Trending

Steady talk.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 1 mentionMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 2 mentionsJun 2026: 0 mentionsJul 2026: 1 mentionAug 2026: 1 mentionSep 2026: 0 mentionsOct 2026: 2 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the microsoft/data-formulator repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about microsoft/data-formulator

The biggest 5 of 31 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 31

Talked about on Bluesky, GitHub and Hacker News (31 times).

On Bluesky · 22

17 more on Bluesky

On GitHub · 7

2 more on GitHub

The file

We split this i18n-no-hardcoded-strings.mdc into the rules it gives an agent

5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    All user-visible text in the frontend MUST go through the i18n system.

    line 9
  2. Very specific:

    When you cannot use hooks (Redux thunks, plain .ts utilities, store helpers), import the i18n instance directly:

    line 30
  3. Very specific:

    When adding a new key, add it to both en and zh locale files.

    line 50
  4. Very specific:

    Must use t(): button labels, tooltips, placeholders, error messages, dialog titles, tab names, toast notifications, table headers, …

    line 54
  5. Very specific:

    When the backend returns a user-visible message with a message_code (or content_code, error_code), use translateBackend() from …

    line 62

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
i18n-no-hardcoded-strings.mdc
---
description: No hardcoded UI strings — use i18n translation keys
globs: src/**/*.{ts,tsx}
alwaysApply: true
---

# i18n: No Hardcoded UI Strings

All user-visible text in the frontend MUST go through the i18n system. Never hardcode Chinese, English, or any other language string directly in components.

## How to Use

```tsx
import { useTranslation } from 'react-i18next';

const { t } = useTranslation();

// ✅ GOOD
<Button>{t('common.save')}</Button>
<Tooltip content={t('chart.noData')} />

// ❌ BAD
<Button>保存</Button>
<Button>Save</Button>
<Tooltip content="No data available" />
```

## Non-Component Contexts (thunks, utilities, helpers)

When you cannot use hooks (Redux thunks, plain `.ts` utilities, store helpers), import the i18n instance directly:

```ts
import i18n from '../i18n';

// ✅ GOOD — works outside React components
i18n.t('messages.rowLimitReached', { count: 20000 })

// ❌ BAD — hooks only work inside React function components
const { t } = useTranslation();  // will crash in a thunk
```

The same rule applies: every user-visible string must use `i18n.t()` with a translation key, never a hardcoded literal.

## Translation Files

- English: `src/i18n/locales/en/<namespace>.json`
- Chinese: `src/i18n/locales/zh/<namespace>.json`
- Namespaces: `common`, `upload`, `chart`, `model`, `encoding`, `messages`, `navigation`, `dataLoading`, `errors`

When adding a new key, add it to **both** `en` and `zh` locale files. Pick the namespace that fits; create a new namespace only if none applies.

## What Counts as User-Visible

Must use `t()`: button labels, tooltips, placeholders, error messages, dialog titles, tab names, toast notifications, table headers, empty-state text.

May stay hardcoded: log messages (`console.log`), error messages thrown but never displayed, internal constants, CSS class names, test IDs.

**Cross-stack sentinel values** — strings shared between frontend and backend as identity markers (e.g. `UNTITLED_SESSION` in `dfSlice.ts` used by both Redux state and backend workspace API) must NOT be translated. They are internal constants, not display text. Translate them only at the UI rendering layer by mapping the sentinel to `t('...')`.

## Backend Messages with message_code

When the backend returns a user-visible message with a `message_code` (or `content_code`, `error_code`), use `translateBackend()` from `src/app/utils.tsx` to translate it:

```tsx
import { translateBackend } from '../app/utils';

// Translate a backend error message
const msg = translateBackend(event.message, event.message_code, event.message_params);

// Translate options with parallel code arrays
const options = translateBackendOptions(rawOptions, event.option_codes);
```

The translation keys live in `messages.json` under the `agent` section. Always add **both** `en` and `zh` entries.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.