Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Sep 14, 2025

Summary

Implements comprehensive internationalization support for all exception messages in Platform.Data library to address issue #6.

Changes

  • ✅ Created resource-based localization system with English (default) and Russian translations
  • ✅ Refactored all exception classes to use localized messages instead of hardcoded Russian strings
  • ✅ Added comprehensive test coverage for internationalization functionality
  • ✅ Maintained backward compatibility with existing APIs

Key Features

  • Centralized localization: ExceptionMessages class provides unified access to localized strings
  • Multi-language support: English (default) and Russian translations included
  • Dynamic culture resolution: Messages adapt to current UI culture at runtime
  • Type-safe formatting: Generic methods support different link address types
  • Full test coverage: 8 comprehensive tests covering all scenarios

Files Added

  • Resources/ExceptionMessages.cs - Centralized localization manager
  • Resources/ExceptionMessages.resx - English resource strings
  • Resources/ExceptionMessages.ru.resx - Russian resource strings
  • ExceptionMessagesTests.cs - Complete test coverage for i18n functionality
  • examples/InternationalizationDemo.cs - Usage demonstration

Files Modified

  • ArgumentLinkDoesNotExistsException.cs - Now uses localized messages
  • ArgumentLinkHasDependenciesException.cs - Now uses localized messages
  • LinksLimitReachedException.cs - Now uses localized messages
  • LinksLimitReachedExceptionBase.cs - Dynamic default message property
  • LinkWithSameValueAlreadyExistsException.cs - Dynamic default message property

Test Plan

  • All existing tests continue to pass
  • New internationalization tests validate English and Russian messages
  • Exception classes produce correctly localized messages based on culture
  • Default message properties dynamically resolve based on current culture
  • Different numeric types work correctly with message formatting

Usage Example

// Messages automatically localize based on current culture
CultureInfo.CurrentUICulture = CultureInfo.GetCultureInfo("en-US");
var exception = new ArgumentLinkDoesNotExistsException<int>(123, "linkId");
// Message: "Link [123] passed in argument [linkId] does not exist."

CultureInfo.CurrentUICulture = CultureInfo.GetCultureInfo("ru-RU"); 
var exception = new ArgumentLinkDoesNotExistsException<int>(123, "linkId");
// Message: "Связь [123] переданная в аргумент [linkId] не существует."

Backward Compatibility

✅ Full backward compatibility maintained - no breaking changes to public APIs

Fixes #6

🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #6
@konard konard self-assigned this Sep 14, 2025
This commit adds comprehensive internationalization support for all exception messages in the Platform.Data library. The solution includes:

### Key Changes:
- Created `ExceptionMessages` resource-based localization system with English (default) and Russian translations
- Refactored all exception classes to use localized messages instead of hardcoded Russian strings
- Added comprehensive test coverage for internationalization functionality
- Maintained backward compatibility with existing APIs

### Files Added:
- `Resources/ExceptionMessages.cs` - Centralized localization manager
- `Resources/ExceptionMessages.resx` - English resource strings
- `Resources/ExceptionMessages.ru.resx` - Russian resource strings
- `ExceptionMessagesTests.cs` - Complete test coverage for i18n functionality

### Files Modified:
- All exception classes now use the new localization system
- Default message properties converted to dynamic getters for proper culture resolution

The implementation uses .NET's standard ResourceManager for efficient resource loading and supports culture-specific message formatting. All tests pass and the solution maintains full compatibility with existing code.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] Internationalization of exception messages Implement internationalization of exception messages Sep 14, 2025
@konard konard marked this pull request as ready for review September 14, 2025 08:39
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.

Internationalization of exception messages

2 participants