Skip to content
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

🔄 chore: Enforce 18next Language Keys #5803

Merged
merged 6 commits into from
Feb 12, 2025

Conversation

rubentalstra
Copy link
Collaborator

@rubentalstra rubentalstra commented Feb 11, 2025

Summary

This PR updates and refines the project’s translation and localization system to enforce stricter type safety and consistency across the codebase. The key changes include:

  • i18next Type Improvements:

    • Added a module augmentation in client/src/@types/i18next.d.ts to define the CustomTypeOptions with defaultNS, resources, and enabling strictKeyChecks.
    • This change ensures that only valid translation keys (typed as TranslationKeys) are used in the project.
  • Refactoring Translation Key Usages:

    • Updated various components (such as in Chat, Settings, dynamic UI elements, and more) to replace plain strings with the new TranslationKeys type.
    • Adjusted calls to the localization hook (e.g., useLocalize) so that translation keys are now strongly typed and validated at compile time.
  • Workflow and ESLint Updates:

    • Modified the i18n unused keys workflow (in .github/workflows/i18n-unused-keys.yml) to format the output as checkboxes, making it easier for manual checks.
    • Updated ESLint configuration (in eslint.config.mjs) to reflect the new i18next rules and ensure that literal strings are not used where translation keys are expected.
  • Additional Minor Changes:

    • Tweaks in .gitignore, package configuration files, and various UI components (e.g., dynamic inputs, dropdowns, switches, and textareas) to support the new translation typing.
    • Updated tests and startup components to handle errors and headers using the new TranslationKeys types.

Change Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Translation update

Testing

To verify these changes:

  1. Local Testing:

    • Run the application locally and navigate through areas where text is rendered (chat, settings, dynamic form inputs, etc.) to ensure all translations display correctly.
    • Confirm that components which use dynamic inputs (e.g., dropdowns, checkboxes, textareas) render with the proper localized labels and placeholders.
  2. Linting & Type Checking:

    • Run the linter to ensure that there are no violations regarding literal strings in localized components.
    • Run the TypeScript compiler to verify that all translation keys adhere to the new TranslationKeys type.
  3. CI/CD Verification:

    • Check the GitHub Actions workflow (especially the i18n unused keys workflow) to ensure that it reports unused translation keys in the expected checkbox format.

Checklist

  • My code adheres to this project's style guidelines.
  • I have performed a self-review of my own code.
  • I have commented in any complex areas of my code where necessary.
  • My changes do not introduce new warnings or errors.
  • I have written tests or performed manual testing demonstrating that my changes work as expected.
  • Any changes that depend on these updates have been merged or will be updated accordingly.

@rubentalstra rubentalstra added 🌍 i18n Language 🔧 fix Bug fixes and code patches labels Feb 11, 2025
@rubentalstra rubentalstra self-assigned this Feb 11, 2025
Repository owner deleted a comment from github-actions bot Feb 12, 2025
Copy link
Contributor

github-actions bot commented Feb 12, 2025

🚨 Unused i18next Keys Detected

The following translation keys are defined in translation.json but are not used in the codebase:

  • com_auth_email_verification_rate_limited
  • com_auth_reset_password_email_sent
  • com_auth_username_required
  • com_endpoint_anthropic_custom_name_placeholder
  • com_endpoint_bing_context_placeholder
  • com_endpoint_bing_enable_sydney
  • com_endpoint_bing_jailbreak
  • com_endpoint_bing_system_message_placeholder
  • com_endpoint_bing_to_enable_sydney
  • com_endpoint_config_key_chatgpt
  • com_endpoint_config_key_chatgpt_copy_token
  • com_endpoint_config_key_chatgpt_then_visit
  • com_endpoint_config_key_edge_full_key_string
  • com_endpoint_config_key_edge_instructions
  • com_endpoint_config_key_expiry
  • com_endpoint_config_key_get_edge_key
  • com_endpoint_config_key_get_edge_key_dev_tool
  • com_endpoint_config_key_name_placeholder
  • com_endpoint_default_creative
  • com_endpoint_default_false
  • com_endpoint_disabled_with_tools
  • com_endpoint_disabled_with_tools_placeholder
  • com_endpoint_hide
  • com_endpoint_new_topic
  • com_endpoint_not_available
  • com_endpoint_not_implemented
  • com_endpoint_plug_resend_images
  • com_endpoint_preset_clear_all_confirm
  • com_endpoint_save_convo_as_preset
  • com_endpoint_show
  • com_endpoint_show_what_settings
  • com_endpoint_system_message
  • com_endpoint_token_count
  • com_endpoint_tone_style
  • com_endpoint_view_options
  • com_error_invalid_action_error
  • com_error_invalid_request_error
  • com_error_no_system_messages
  • com_nav_archive_all
  • com_nav_archive_all_chats
  • com_nav_command_settings
  • com_nav_command_settings_description
  • com_nav_commands_tab
  • com_nav_delete_account_confirm_placeholder
  • com_nav_info_delete_cache_storage
  • com_nav_info_revoke
  • com_nav_media_source_init_error
  • com_nav_shared_links_date_shared
  • com_nav_shared_links_empty
  • com_nav_shared_links_name
  • com_nav_source_chat
  • com_ui_agent_already_shared_to_all
  • com_ui_bulk_delete_partial_error
  • com_ui_categories
  • com_ui_chats
  • com_ui_connect
  • com_ui_drag_drop_file
  • com_ui_duplicate_agent_confirm
  • com_ui_entries
  • com_ui_experimental
  • com_ui_finance
  • com_ui_idea
  • com_ui_loading
  • com_ui_misc
  • com_ui_model_save_success
  • com_ui_more_options
  • com_ui_new_footer
  • com_ui_no_conversation_id
  • com_ui_no_prompt_description
  • com_ui_pay_per_call
  • com_ui_prompt_shared_to_all
  • com_ui_renaming_var
  • com_ui_roleplay
  • com_ui_search_categories
  • com_ui_select_a_category
  • com_ui_service_http
  • com_ui_share_created_message
  • com_ui_share_retrieve_error
  • com_ui_share_updated_message
  • com_ui_shop
  • com_ui_showing
  • com_ui_success
  • com_ui_teach_or_explain
  • com_ui_title
  • com_ui_travel
  • com_ui_write

⚠️ Please remove these unused keys to keep the translation files clean.

Repository owner deleted a comment from github-actions bot Feb 12, 2025
@rubentalstra rubentalstra changed the title WIP chore: enforcing language keys to adhere to the new standard. chore: enforcing language keys to adhere to the new standard. Feb 12, 2025
@rubentalstra rubentalstra marked this pull request as ready for review February 12, 2025 11:45
@rubentalstra rubentalstra changed the title chore: enforcing language keys to adhere to the new standard. 🔄 chore: enforcing language keys to adhere to the new standard. Feb 12, 2025
@danny-avila danny-avila changed the title 🔄 chore: enforcing language keys to adhere to the new standard. 🔄 chore: Enforce 18next Language Keys Feb 12, 2025
@danny-avila danny-avila merged commit 7f48030 into main Feb 12, 2025
6 checks passed
@danny-avila danny-avila deleted the fix/enforcing-i18next-language-keys branch February 12, 2025 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔧 fix Bug fixes and code patches 🌍 i18n Language
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants