|
| 1 | +# i18n Key Naming Ruleset for Cursor IDE |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +This document provides a comprehensive ruleset for naming internationalization (i18n) keys and keysets in Cursor IDE projects. Following these conventions ensures consistency, maintainability, and clarity in multilingual applications. |
| 6 | + |
| 7 | +## 1. Keyset Naming Rules |
| 8 | + |
| 9 | +### 1.1 Keyset Types |
| 10 | + |
| 11 | +Keysets are divided into 4 categories: |
| 12 | + |
| 13 | +1. **System-wide** - Used across many sections (e.g., `common`, `common.units`, `common.operations`) |
| 14 | +2. **Section-wide** - Common within a section (e.g., `billing.common`) |
| 15 | +3. **Page-specific** - Specific to section pages (e.g., `billing.account`) |
| 16 | +4. **Reusable components** - For shared components (e.g., `logs.events`) |
| 17 | + |
| 18 | +### 1.2 Keyset Naming Conventions |
| 19 | + |
| 20 | +- **MUST**: Write context description for each keyset |
| 21 | +- **MUST**: Keep keysets concise (prefer `billing.budgets` over `billing.account.budgets`) |
| 22 | +- **MUST NOT**: Create keysets with only a few keys - merge with existing section keysets |
| 23 | +- **MUST NOT**: Create multiple keysets for sections/popups within the same area |
| 24 | +- **MUST NOT**: Start reusable component keysets with `component.` - use the section name instead |
| 25 | + |
| 26 | +## 2. Key Naming Rules |
| 27 | + |
| 28 | +### 2.1 Key Format |
| 29 | + |
| 30 | +Keys follow the pattern: `<element-context>_<content-text>` |
| 31 | + |
| 32 | +### 2.2 Context Prefixes |
| 33 | + |
| 34 | +Use these standard context prefixes: |
| 35 | + |
| 36 | +| Prefix | Usage | Example | |
| 37 | +| --------- | --------------------------------------------------- | ----------------------------------- | |
| 38 | +| `context` | Contextual information, hints, section descriptions | `context_save-up-and-service-sales` | |
| 39 | +| `alert` | System feedback, notifications, warnings | `alert_load-document-error` | |
| 40 | +| `action` | User actions: buttons, links, menu items | `action_document-view` | |
| 41 | +| `field` | Resource field names in tables, forms, overviews | `field_account-name` | |
| 42 | +| `title` | Titles of sections, pages, popups, menu items | `title_billing-section` | |
| 43 | +| `confirm` | Confirmation prompts and calls to action | `confirm_delete-resource` | |
| 44 | +| `value` | Radio button values, statuses, field values | `value_active-status` | |
| 45 | + |
| 46 | +### 2.3 Key Naming Guidelines |
| 47 | + |
| 48 | +- **MUST**: Make content description unambiguous and concise |
| 49 | +- **MUST**: Use hyphens to separate words in content description |
| 50 | +- **MUST NOT**: Use `label_` prefix (deprecated) |
| 51 | +- **SHOULD**: If context cannot be determined, omit the prefix |
| 52 | + |
| 53 | +### 2.4 Examples |
| 54 | + |
| 55 | +| Text | Key | |
| 56 | +| ----------------------------------------------------------- | --------------------------- | |
| 57 | +| Error loading document (notification title) | `alert_load-document-error` | |
| 58 | +| Report document not ready, try later (notification message) | `alert_act-not-ready-error` | |
| 59 | +| Scheduled maintenance on 12.02.2022 14:00-15:00 | `alert_planned-maintenance` | |
| 60 | +| View document (button) | `action_document-view` | |
| 61 | + |
| 62 | +## 3. Technical Prefixes |
| 63 | + |
| 64 | +### 3.1 Special Processing Prefixes |
| 65 | + |
| 66 | +| Prefix | Purpose | Processing | |
| 67 | +| ------ | ---------------------------- | ------------------------------------ | |
| 68 | +| `raw_` | Bypass typography processing | Text displayed as-is | |
| 69 | +| `md_` | Enable markdown formatting | Supports **bold**, _italic_, [links] | |
| 70 | + |
| 71 | +### 3.2 Formatting Rules |
| 72 | + |
| 73 | +- **MUST NOT**: Use HTML markup in text |
| 74 | +- **MUST**: Use YFM markdown syntax for formatting |
| 75 | +- **CAN**: Add link attributes using markdown syntax: |
| 76 | + ```json |
| 77 | + { |
| 78 | + "md_example-key": "Learn [more](https://example.com){target=_blank rel=\"noreferrer noopener\"}" |
| 79 | + } |
| 80 | + ``` |
| 81 | + |
| 82 | +## 4. Character Restrictions |
| 83 | + |
| 84 | +### 4.1 Allowed Characters |
| 85 | + |
| 86 | +Keys must only contain characters matching this pattern: |
| 87 | + |
| 88 | +```regex |
| 89 | +^[a-z0-9\u0400-\u04ff[\](){}<>!@#$%^&*~_\-−–—+='"`«»„"''"?.,:;|\\/ ₽™®©№\u00a0]*$/i |
| 90 | +``` |
| 91 | + |
| 92 | +This includes: |
| 93 | + |
| 94 | +- Latin letters (a-z, A-Z) |
| 95 | +- Numbers (0-9) |
| 96 | +- Cyrillic letters (\u0400-\u04ff) |
| 97 | +- Common punctuation and symbols |
| 98 | +- Non-breaking space (\u00a0) |
| 99 | +- Currency symbols (₽) |
| 100 | +- Special characters (™®©№) |
| 101 | + |
| 102 | +## 5. Best Practices |
| 103 | + |
| 104 | +### 5.1 DO's |
| 105 | + |
| 106 | +- ✅ Keep keys descriptive but concise |
| 107 | +- ✅ Group related keys in appropriate keysets |
| 108 | +- ✅ Use consistent naming patterns within a project |
| 109 | +- ✅ Document keyset context and purpose |
| 110 | +- ✅ Review existing keys before creating new ones |
| 111 | + |
| 112 | +### 5.2 DON'Ts |
| 113 | + |
| 114 | +- ❌ Don't create overly granular keysets |
| 115 | +- ❌ Don't duplicate keys across keysets |
| 116 | +- ❌ Don't use technical jargon in user-facing keys |
| 117 | +- ❌ Don't include implementation details in key names |
| 118 | +- ❌ Don't use special characters outside the allowed set |
| 119 | + |
| 120 | +## 6. Regional Keys |
| 121 | + |
| 122 | +For region-specific content, use appropriate postfixes as defined in the regional keys documentation. |
| 123 | + |
| 124 | +## 7. Validation Checklist |
| 125 | + |
| 126 | +Before finalizing i18n keys, verify: |
| 127 | + |
| 128 | +- [ ] Key follows `<context>_<content>` format |
| 129 | +- [ ] Context prefix is from the standard list |
| 130 | +- [ ] Content description is clear and concise |
| 131 | +- [ ] Key is placed in appropriate keyset |
| 132 | +- [ ] No forbidden characters are used |
| 133 | +- [ ] Formatting prefixes (`raw_`, `md_`) are used correctly |
| 134 | +- [ ] No HTML markup in text values |
| 135 | + |
| 136 | +## 8. Examples Summary |
| 137 | + |
| 138 | +```json |
| 139 | +{ |
| 140 | + "common": { |
| 141 | + "action_save": "Save", |
| 142 | + "action_cancel": "Cancel", |
| 143 | + "field_name": "Name", |
| 144 | + "field_description": "Description" |
| 145 | + }, |
| 146 | + "billing.account": { |
| 147 | + "title_billing-overview": "Billing Overview", |
| 148 | + "alert_payment-failed": "Payment processing failed", |
| 149 | + "context_billing-help": "Manage your billing accounts and payment methods", |
| 150 | + "confirm_delete-account": "Are you sure you want to delete this account?" |
| 151 | + }, |
| 152 | + "logs.events": { |
| 153 | + "field_timestamp": "Timestamp", |
| 154 | + "value_error-level": "Error", |
| 155 | + "action_filter-logs": "Filter logs" |
| 156 | + } |
| 157 | +} |
| 158 | +``` |
0 commit comments