Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Sep 28, 2025

This PR adds comprehensive French language support to the ToughRadius web interface internationalization system, resolving the request in issue #X for adding additional translation languages.

Problem

The existing internationalization system only supported Chinese (zh_CN) and English (en_US) with a basic binary toggle switch. Users requested the ability to add French translations to make the interface accessible to French-speaking administrators.

Solution

Extended the i18n system to support French (fr_FR) as a third language option with the following key changes:

Core System Enhancement

  • Added FrFR = "fr_FR" language constant alongside existing ZhCN and EnUS
  • Updated database initialization to create French translation buckets in BoltDB
  • Enhanced language validation in SetTranslateLang() to accept French
  • Extended translation file generation and cleanup operations for French support

Improved User Interface

Replaced the binary language switch with a modern dropdown selector:

Before:

<switch onLabel="中文" offLabel="English" value="{{zhlang}}">

After:

<richselect options="[
  { id: 'en_US', value: 'English' },
  { id: 'zh_CN', value: '中文' },
  { id: 'fr_FR', value: 'Français' }
]">

Enhanced Language Switching

Updated the controller endpoint from a binary parameter to accept language codes:

  • /admin/translate/switch/fr_FR - Switch to French
  • /admin/translate/switch/zh_CN - Switch to Chinese
  • /admin/translate/switch/en_US - Switch to English
  • Maintains backward compatibility with existing binary URLs (/switch/1 and /switch/0)

Translation Management

  • Added French option to the admin translation interface
  • Enabled bulk import/export for French translation files
  • Extended auto-translation features to support French

Usage

Administrators can now:

  1. Select "Français" from the language dropdown in the main interface
  2. Create French translations through the admin panel by selecting "fr_FR" as the language
  3. Import existing French translation JSON files
  4. Use the "Translate All" feature to automatically generate French translations

Backward Compatibility

All existing functionality is preserved:

  • Current Chinese and English translations remain unchanged
  • Legacy binary language switch URLs continue to work
  • No breaking changes to existing API endpoints or database structure
  • All template variables maintain consistency

Testing

  • ✅ Go build compiles successfully with new language support
  • ✅ Unit tests pass for translation functionality
  • ✅ Database operations validated for French translation storage
  • ✅ Language switching mechanism tested across all three languages

This implementation provides a solid foundation for French localization while maintaining the system's existing stability and functionality.

Original prompt

This section details on the original issue you should resolve

<issue_title>How do I add an additional translation?</issue_title>
<issue_description>Hello, I'm currently testing toughRadius, which I already find very good.

Is it possible to add a translation language?

I can't find the option, and I'd like to translate the web interface into French.</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #188

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@Copilot Copilot AI changed the title [WIP] How do I add an additional translation? Add French language support to internationalization system Sep 28, 2025
@Copilot Copilot AI requested a review from jamiesun September 28, 2025 12:47
Copilot finished work on behalf of jamiesun September 28, 2025 12:47
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.

How do I add an additional translation?

2 participants