Skip to content

feat: Add i18n system and comprehensive AI agent documentation#95

Closed
esafwan wants to merge 23 commits intodevelopfrom
claude/i18n-system-ai-docs-JRwIz
Closed

feat: Add i18n system and comprehensive AI agent documentation#95
esafwan wants to merge 23 commits intodevelopfrom
claude/i18n-system-ai-docs-JRwIz

Conversation

@esafwan
Copy link
Copy Markdown
Contributor

@esafwan esafwan commented Mar 19, 2026

Summary

This PR introduces a lightweight internationalization (i18n) system to the POS frontend and adds comprehensive AI agent documentation across the URY repository. The i18n system enables multi-language support without external dependencies, while the documentation provides detailed guidance for AI agents working on the codebase.

Key Changes

i18n System (pos/src/i18n/)

  • config.ts: Defines default language ('en') and supported languages map
  • loader.ts: Dynamic locale loader with caching to avoid repeated imports
  • index.ts: Core translation API with t(key, params?) function supporting dot-notation keys and {{placeholder}} interpolation
  • resolve-language.ts: Language resolution with priority chain (Frappe boot → localStorage → default)
  • locales/en.json & locales/fr.json: Complete English and French translation files covering all UI strings across namespaces (common, header, menu, cart, order, payment, pos, customer, comment, errors, success)

Component Refactoring

Updated components to use t() for user-visible strings:

  • Header.tsx: Search placeholders, menu items, logout
  • OrderPanel.tsx: Cart labels, validation errors, button text
  • PaymentDialog.tsx: Payment dialog strings and error messages
  • POSOpeningDialog.tsx: POS opening/closing dialog text
  • CustomerSelect.tsx: Customer search and form labels
  • CommentDialog.tsx: Comment dialog labels
  • Orders.tsx: Order action strings and success/error messages
  • POS.tsx: Menu filter labels

App Initialization

  • main.tsx: Modified to call initI18n() before React mount, ensuring translations are loaded synchronously before first render

Documentation

  • pos/AGENTS.MD: 312-line comprehensive guide covering overview, tech stack, project structure, component architecture, data flow, API integration, i18n system, design principles, and AI modification guidelines
  • AGENTS.MD (root): 240-line guide to the URY backend covering app overview, repository structure, Frappe backend organization, key doctypes, document event hooks, and API modules
  • URYMosaic/AGENTS.MD: 216-line guide to the KOT display system covering Vue 3 architecture, Socket.io integration, API interactions, data flow, and extension points
  • CLAUDE.MD files: Added at root, pos/, and URYMosaic/ pointing to respective AGENTS.MD files

Implementation Details

  • No external dependencies added: i18n system uses only TypeScript and native import() for dynamic locale loading
  • Fallback mechanism: Missing translations return the key itself (visible but non-breaking), and unsupported languages fall back to English
  • Lazy loading: Locales are loaded on-demand and cached to avoid repeated imports
  • Interpolation support: Simple {{key}} token replacement for parameterized strings
  • Frappe integration: Language resolution respects Frappe's boot configuration and allows localStorage override
  • Comprehensive coverage: Translation keys organized into logical namespaces matching UI domains (payment, customer, errors, etc.)

Testing Considerations

  • Verify i18n initialization completes before first render
  • Test language resolution priority chain (Frappe boot → localStorage → default)
  • Confirm all hardcoded strings in modified components now use t() function
  • Validate interpolation with parameters (e.g., customer names, amounts)
  • Check fallback behavior for missing translation keys

https://claude.ai/code/session_01QhB9M6JhTa6gJRp1wfZZbv

claude added 2 commits March 19, 2026 01:32
Documents the full implementation plan for:
- i18n infrastructure in pos/src/i18n/
- Language resolution strategy
- Component refactoring to use t()
- AGENTS.MD documentation files for pos/, root, and URYMosaic/

https://claude.ai/code/session_01QhB9M6JhTa6gJRp1wfZZbv
- Add pos/src/i18n/ infrastructure: config, loader, resolve-language, t()
- Add en.json and fr.json translation files with structured namespaces
- Wire initI18n() into main.tsx before React render
- Refactor Header, OrderPanel, POSOpeningDialog, CommentDialog,
  CustomerSelect, PaymentDialog, POS, and Orders to use t()
- Create pos/AGENTS.MD: detailed POS frontend docs for AI agents
- Create AGENTS.MD (root): Frappe backend structure and navigation guide
- Create URYMosaic/AGENTS.MD: KOT display system docs for AI agents
- Create CLAUDE.MD files pointing to AGENTS.MD in each location

https://claude.ai/code/session_01QhB9M6JhTa6gJRp1wfZZbv
@esafwan esafwan changed the title Add i18n system and comprehensive AI agent documentation feat: Add i18n system and comprehensive AI agent documentation Mar 19, 2026
claude and others added 21 commits March 23, 2026 15:39
frappe.local.lang is already set from the user's ERPNext language preference.
Wrapping item_name and course with _() causes Frappe to look up Translation
DocType entries for the active language, so cashiers see translated item and
course names without any frontend changes.

https://claude.ai/code/session_01QhB9M6JhTa6gJRp1wfZZbv
Audit identifies 47 layout anti-patterns that break with dir=rtl:

- 8 space-x-* utilities (should use gap-*)
- 14 directional margins ml-*/mr-* (should use ms-*/me-* or gap)
- 9 absolute positioning with left/right
- 6 directional padding issues
- 4 directional borders

Critical case flagged:
- Header.tsx line 141: User menu button uses space-x-2
  Pattern: div(avatar) + span(username) + svg(arrow)
  This creates ml-* margins that don't flip in RTL

Fix: Replace space-x-* with gap-* which auto-mirrors in RTL
…rtl-support

Fix/standardize layout for i18n rtl support
…t-for-i18n-rtl-support

Revert "Fix/standardize layout for i18n rtl support"
@esafwan esafwan closed this Apr 8, 2026
@esafwan esafwan deleted the claude/i18n-system-ai-docs-JRwIz branch April 8, 2026 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants