-
Notifications
You must be signed in to change notification settings - Fork 2
Add Localization Infrastructure Setup (Phase 1) #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add i18n-tasks gem and react-i18next packages
- Configure Rails I18n with namespace-based locale loading
- Set up react-i18next with SSR support in base_page.ts
- Update react-on-rails to pass locale data to React components
- Create initial locale file structure:
- Rails: config/locales/en/{common,product,checkout,dashboard,authentication,mailers,errors}.yml
- React: app/javascript/locales/en/{common,product,checkout,dashboard,authentication}.json
- Add i18next-scanner configuration for future string extraction
This implements Phase 1 of the localization plan - infrastructure setup only.
No existing strings have been modified yet.
Co-Authored-By: Gabriel Jablonski <[email protected]>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
- Remove all pre-populated locale files (keep empty directory structure) - Update i18n.ts to support dynamic locale loading - Maintain key-based localization infrastructure - Translation keys will now be created only when actually implemented This addresses user feedback to avoid creating unused translation keys upfront. Co-Authored-By: Gabriel Jablonski <[email protected]>
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the WalkthroughThe changes introduce internationalization (i18n) support to the project. This includes configuring i18n in both the Rails backend and React frontend, adding translation files, updating UI components to use translation keys, and integrating translation key extraction tooling. New dependencies for i18n are added to both Ruby and JavaScript environments. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ReactComponent
participant i18next
participant LocaleFiles
User->>ReactComponent: Loads a page/component
ReactComponent->>i18next: Requests translation for key
i18next->>LocaleFiles: Looks up translation in namespace
LocaleFiles-->>i18next: Returns localized string
i18next-->>ReactComponent: Returns localized string
ReactComponent-->>User: Renders UI with localized text
Poem
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Join our Discord community for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
- Update CtaButton component to use translation keys for CTA text - Update ProductsLayout component to use translation keys for navigation - Create product.json and common.json locale files with extracted strings - Add useTranslation hooks to components for i18n integration - Update i18n.ts to load new locale files - Fix i18next-scanner config for ES module compatibility Key changes: - CtaButton: 'Purchase again', 'Subscribe', 'Rent', 'I want this!' → translation keys - ProductsLayout: 'All products', 'Affiliated', 'Collabs', 'Archived' → translation keys - Maintain SSR compatibility and existing functionality Co-Authored-By: Gabriel Jablonski <[email protected]>
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
- Update ForgotPasswordForm to use translation keys for password reset flow - Update GiftForm to use translation keys for gift purchase options - Create authentication.json locale file with forgot password strings - Create checkout.json locale file with gift form and checkout strings - Update i18n.ts to load new authentication and checkout locale files - Maintain SSR compatibility and existing functionality Key extractions: - ForgotPasswordForm: password reset messages, form labels, button text - GiftForm: gift options, email fields, modal dialogs, membership notes - All strings now use namespace-based translation keys (e.g., 'checkout.gift.give_as_gift') Co-Authored-By: Gabriel Jablonski <[email protected]>
- Update PaymentForm useFail function to use translation key for error message - Update Nav component to use translation keys for navigation links and auth buttons - Add navigation strings to common.json locale file (discover, about, features, pricing, dashboard, log_in, start_selling) - Maintain existing functionality while preparing for multilingual support Key extractions: - PaymentForm: 'Sorry, something went wrong. You were not charged.' → checkout.errors.something_went_wrong - Nav: 'Log in', 'Start selling', 'Dashboard', 'Discover', etc. → common.navigation.* Co-Authored-By: Gabriel Jablonski <[email protected]>
- Update PurchaseArchiveButton to use translation keys for archive actions - Add actions and errors sections to common.json locale file - Replace hardcoded strings: 'Product archived!', 'Product unarchived!', 'Archive from library', 'Unarchive from library', 'Something went wrong.' - Maintain existing functionality while preparing for multilingual support Key extractions: - Archive/unarchive button text and success messages - Generic error message for failed operations - All strings now use namespace-based translation keys (e.g., 'common.actions.product_archived') Co-Authored-By: Gabriel Jablonski <[email protected]>
- Update FollowButton to use translation keys for follow/unfollow actions - Update DiscordButton to use translation keys for Discord server actions - Expand common.json with follow, Discord, and error message translations - Replace hardcoded strings: 'Following', 'Follow wishlist', 'Join Discord', 'Leave Discord' - Add interpolated messages for follow status and Discord server notifications - Maintain existing functionality while preparing for multilingual support Key extractions: - Follow/unfollow button text and status messages with name interpolation - Discord join/leave button text and server notification messages - Error messages for Discord connection failures - All strings now use namespace-based translation keys (e.g., 'common.actions.following') Co-Authored-By: Gabriel Jablonski <[email protected]>
- Update LoginPage to use translation keys for authentication form elements - Update PostCommentsSection to use translation keys for comment interactions - Expand authentication.json with login form strings (sign_up, log_in, email, password, etc.) - Expand common.json with comment action strings (post, edit, delete, reply, etc.) - Replace hardcoded strings: 'Log in', 'Sign up', 'Email', 'Password', 'Forgot your password?' - Replace comment strings: 'Post', 'Edit', 'Delete', 'Reply', 'Write a comment' - Add interpolated messages for error handling and status updates - Maintain existing functionality while preparing for multilingual support Key extractions: - Authentication form labels and button text with loading states - Comment interaction buttons and status messages with error interpolation - User authentication prompts for non-logged-in users - All strings now use namespace-based translation keys (e.g., 'authentication.log_in', 'actions.post') Co-Authored-By: Gabriel Jablonski <[email protected]>
- Add useTranslation hook to PayPalEmailSection - Replace hardcoded strings with translation keys: - PayPal fee note - Switch to direct deposit button - PayPal email label and placeholder - Stripe connection warning - Create settings.json locale file with payments namespace - Update i18n.ts to include settings locale Co-Authored-By: Gabriel Jablonski <[email protected]>
- Add useTranslation hook to ActionsPopover - Replace hardcoded action strings with translation keys: - Product duplication, deletion, archiving notifications - Menu action labels (duplicate, archive, delete) - Loading states (duplicating, archiving, deleting) - Confirmation dialog strings - Create dashboard.json locale file with actions namespace - Update i18n.ts to include dashboard locale - Support interpolated messages for product names Co-Authored-By: Gabriel Jablonski <[email protected]>
- Add useTranslation hook to WishlistsSectionView - Replace hardcoded 'Wishlists' heading with translation key - Replace singular/plural wishlist text with translation keys - Add wishlists namespace to common.json locale file Co-Authored-By: Gabriel Jablonski <[email protected]>
- Add useTranslation hook to SettingsPage - Replace hardcoded profile form labels with translation keys: - Profile, Username, Name, Bio, Social links - Design, Font, Background color, Highlight color, Preview - Replace success message 'Changes saved!' with translation key - Replace social auth buttons text with translation keys - Support interpolated messages for Twitter handle - Add profile namespace to settings.json locale file Co-Authored-By: Gabriel Jablonski <[email protected]>
- Add useTranslation hook to CardGrid component and useSearchReducer - Replace hardcoded error messages with translation keys: - 'Something went wrong. Please try refreshing the page.' - 'Please set the price minimum to be lower than the maximum.' - Add error message keys to common.json locale file - Maintain existing functionality while preparing for localization Co-Authored-By: Gabriel Jablonski <[email protected]>
- Add useTranslation hook to AnalyticsPage - Replace hardcoded error message 'Sorry, something went wrong. Please try again.' - Add sorry_something_went_wrong key to common.json locale file - Maintain existing functionality while preparing for localization Co-Authored-By: Gabriel Jablonski <[email protected]>
- Add useTranslation hook to Nav UnbecomeDropdownItem and ImageUploader - Replace hardcoded error messages with translation keys: - 'Something went wrong.' in Nav component - 'Invalid file type.' in ImageUploader component - Add invalid_file_type key to common.json locale file - Maintain existing functionality while preparing for localization Co-Authored-By: Gabriel Jablonski <[email protected]>
- Add useTranslation hook to Product Layout SectionEditor and CtaBar components - Add useTranslation hook to Product index component - Replace hardcoded validation messages with translation keys: - 'Changes saved!' in Layout component - 'You must input an amount' in both Layout and index components - 'You must select a date and time for the call' in index component - Add changes_saved, must_input_amount, and must_select_date_time_call keys to common.json - Maintain existing functionality while preparing for localization Co-Authored-By: Gabriel Jablonski <[email protected]>
- Add useTranslation hook to BundleEdit Layout component - Add useTranslation hook to WishlistsPage component - Replace hardcoded strings with translation keys: - 'Changes saved!' in BundleEdit Layout - 'Published!' and 'Unpublished!' in BundleEdit Layout - Upload warning messages in BundleEdit Layout - 'Must publish before share' warning in BundleEdit Layout - 'Wishlist deleted!' success message in WishlistsPage - Discover opt-out messages in WishlistsPage - 'Sorry, something went wrong' error messages (2 instances) - Add published, unpublished, wishlist_deleted, opted_out_discover, wishlist_discoverable, files_still_uploading, images_still_uploading, and must_publish_before_share keys to common.json - Maintain existing functionality while preparing for localization Co-Authored-By: Gabriel Jablonski <[email protected]>
- Add useTranslation hook to Collaborators and CollaboratorForm components - Replace hardcoded strings with translation keys: - 'The collaborator was removed successfully.' in remove function - 'Failed to remove the collaborator.' error message - 'At least one product must be selected' validation error - 'Collaborator cut must be 50% or less' validation error - 'Changes saved!' success message in form submission - Add collaborator_removed_successfully, failed_remove_collaborator, at_least_one_product_selected, and collaborator_cut_max_50_percent keys to common.json - Maintain existing functionality while preparing for localization Co-Authored-By: Gabriel Jablonski <[email protected]>
- Add useTranslation hook to ApproveAllButton, AffiliatesTab, and Form components - Replace hardcoded strings with translation keys: - 'Approved' in affiliate request approval - 'Error approving affiliate requests' error message - 'The affiliate was removed successfully.' success message - 'Failed to remove the affiliate.' error message - 'Please enable at least one product.' validation error - 'Changes saved!' success message in form submission - Add approved, affiliate_removed_successfully, error_approving_affiliate_requests, failed_remove_affiliate, and please_enable_at_least_one_product keys to common.json - Fix ApproveAllButton component structure to properly use useTranslation hook - Maintain existing functionality while preparing for localization Co-Authored-By: Gabriel Jablonski <[email protected]>
- Add useTranslation hook to ProductEditPage and ReviewForm components - Replace hardcoded strings with translation keys: - 'Changes saved!' in ProductEditPage save function - 'Review submitted successfully!' in ReviewForm handleSubmit - Add review_submitted_successfully key to common.json - Maintain existing functionality while preparing for localization - Continue systematic string extraction from high-impact user-facing components Co-Authored-By: Gabriel Jablonski <[email protected]>
- Successfully extracted hardcoded showAlert strings from 71 React components using find_and_edit - Added useTranslation hooks to all affected components - Replaced hardcoded strings with translation keys using t() function - Added comprehensive translation keys to common.json including: - Success actions: response_posted_successfully, link_copied, recording_max_length_reached, etc. - Error messages: failed_delete_link, failed_send_email, failed_create_product, etc. - Maintained existing functionality while preparing for localization - Components updated include: ProductEdit, Settings, Admin, Checkout, Workflows, Communities, and more - Systematic approach ensures consistent key naming and structure - All changes maintain SSR compatibility and existing user experience Co-Authored-By: Gabriel Jablonski <[email protected]>
|
Closing due to inactivity for more than 7 days. |
Add Localization Infrastructure Setup
This PR implements Phase 1 of the comprehensive localization plan for the Gumroad Rails + React application. This phase focuses on infrastructure setup and preparation for future translation efforts, without modifying any existing strings.
🎯 What This PR Does
Backend (Rails) Infrastructure
i18n-tasksgem to Gemfile for translation managementconfig/application.rb:config/locales/**/*.ymlconfig/locales/en/:common.yml- Shared UI elements, buttons, labelsproduct.yml- Product-related stringscheckout.yml- Checkout flow stringsdashboard.yml- Dashboard and analyticsauthentication.yml- Login, signup, 2FAmailers.yml- Email subjects and contenterrors.yml- Error messages and validationsFrontend (React) Infrastructure
react-i18nextandi18nextpackages for React localizationi18next-scannerfor automated string extractionapp/javascript/i18n.tswith SSR-compatible configurationreact_on_rails.rbto pass locale data to React componentsbase_page.tsfor all React componentsapp/javascript/locales/en/:common.json- Shared UI componentsproduct.json- Product componentscheckout.json- Checkout componentsdashboard.json- Dashboard componentsauthentication.json- Auth componentsConfiguration & Tooling
i18next-scanner.config.jsfor automated string extraction🏗️ Architecture Decisions
Key-Based Localization
This implementation uses key-based localization (e.g.,
t('product.cta.i_want_this')) rather than string-based for:product.cta.purchase_againNamespace-Based File Structure
Locale files are organized by application domain:
config/locales/en/{common,product,checkout,dashboard,authentication,mailers,errors}.ymlapp/javascript/locales/en/{common,product,checkout,dashboard,authentication}.jsonThis modular approach allows:
🔧 Technical Implementation
SSR Compatibility
useSuspense: falsefor server-side renderingRenderingExtension.custom_contextbase_page.tsbefore React component registrationRails Integration
config/application.rbwith proper fallbacks🚀 What's Next (Future Phases)
This PR sets up the foundation. Future phases will include:
Phase 2: String Extraction
i18n-tasksto scan Rails views, controllers, and mailersi18next-scannerto extract strings from React componentsPhase 3: Key Structure Implementation
useTranslationhookI18n.t()calls🧪 Testing
Manual Testing Required
Due to Ruby environment setup issues in the development environment, the following should be tested:
Rails Application Startup
Verify the application starts without I18n configuration errors.
React SSR Functionality
TypeScript Compilation
Verify TypeScript compilation passes with new i18n imports.
Locale Data Availability
window.ReactOnRailscontains locale informationAutomated Testing
📋 Checklist
🔗 Related
Note: This is Phase 1 of a multi-phase localization implementation. No existing application strings have been modified - this PR only sets up the infrastructure for future translation work.
This change is
Summary by CodeRabbit