@@ -56,8 +56,7 @@ Only proceed with pull request creation if ALL checks pass.
5656- Use ` Current.family ` for the current family. Do NOT use ` current_family ` .
5757
5858### Development Guidelines
59- - Prior to generating any code, carefully read the project conventions and guidelines
60- - Ignore i18n methods and files. Hardcode strings in English for now to optimize speed of development
59+ - Carefully read project conventions and guidelines before generating any code.
6160- Do not run ` rails server ` in your responses
6261- Do not run ` touch tmp/restart.txt `
6362- Do not run ` rails credentials `
@@ -112,6 +111,15 @@ Sidekiq handles asynchronous tasks:
112111 - Always use functional tokens (e.g., ` text-primary ` not ` text-white ` )
113112 - Prefer semantic HTML elements over JS components
114113 - Use ` icon ` helper for icons, never ` lucide_icon ` directly
114+ - ** i18n** : All user-facing strings must use localization (i18n). Update locale files for each new or changed element.
115+
116+ ### Internationalization (i18n) Guidelines
117+ - ** Key Organization** : Use hierarchical keys by feature: ` accounts.index.title ` , ` transactions.form.amount_label `
118+ - ** Translation Helper** : Always use ` t() ` helper for user-facing strings
119+ - ** Interpolation** : Use for dynamic content: ` t("users.greeting", name: user.name) `
120+ - ** Pluralization** : Use Rails pluralization: ` t("transactions.count", count: @transactions.count) `
121+ - ** Locale Files** : Update ` config/locales/en.yml ` for new strings
122+ - ** Missing Translations** : Configure to raise errors in development for missing keys
115123
116124### Multi-Currency Support
117125- All monetary values stored in base currency (user's primary currency)
@@ -220,11 +228,36 @@ Sidekiq handles asynchronous tasks:
220228``` erb
221229<!-- GOOD: Declarative - HTML declares what happens -->
222230<div data-controller="toggle">
223- <button data-action="click->toggle#toggle" data-toggle-target="button">Show</button>
224- <div data-toggle-target="content" class="hidden">Hello World!</div>
231+ <button data-action="click->toggle#toggle" data-toggle-target="button">
232+ <%= t("components.transaction_details.show_details") %>
233+ </button>
234+ <div data-toggle-target="content" class="hidden">
235+ <p><%= t("components.transaction_details.amount_label") %>: <%= @transaction.amount %></p>
236+ <p><%= t("components.transaction_details.date_label") %>: <%= @transaction.date %></p>
237+ <p><%= t("components.transaction_details.category_label") %>: <%= @transaction.category.name %></p>
238+ </div>
225239</div>
226240```
227241
242+ ** Example locale file structure (config/locales/en.yml):**
243+ ``` yaml
244+ en :
245+ components :
246+ transaction_details :
247+ show_details : " Show Details"
248+ hide_details : " Hide Details"
249+ amount_label : " Amount"
250+ date_label : " Date"
251+ category_label : " Category"
252+ ` ` `
253+
254+ **i18n Best Practices:**
255+ - Organize keys by feature/component: ` components.transaction_details.show_details`
256+ - Use descriptive key names that indicate purpose : ` show_details` not `button`
257+ - Group related translations together in the same namespace
258+ - Use interpolation for dynamic content : ` t("users.welcome", name: user.name)`
259+ - Always update locale files when adding new user-facing strings
260+
228261**Controller Best Practices:**
229262- Keep controllers lightweight and simple (< 7 targets)
230263- Use private methods and expose clear public API
0 commit comments