Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Sep 14, 2025

🌍 Internationalization Support for Exception Messages

This pull request implements comprehensive internationalization (i18n) support for exception messages in the Platform.Exceptions library, resolving issue #17.

📋 Changes Made

🗂️ Resource Files

  • Resources.resx: English (default) resource file with exception message templates
  • Resources.ru.resx: Russian translation of all exception messages
  • Resources.Designer.cs: Strongly-typed resource accessor class for compile-time safety

🔧 Code Updates

  • EnsureExtensions.cs: Replaced hardcoded strings with resource references:
    • $"Argument {argumentName} is null."string.Format(Resources.ArgumentIsNull, argumentName)
    • $"Argument {argumentName} does not meet the criteria."string.Format(Resources.ArgumentDoesNotMeetCriteria, argumentName)
  • ExceptionExtensions.cs: Localized exception formatting strings:
    • "Unable to format exception."Resources.UnableToFormatException
    • "Inner exception: "Resources.InnerException
  • Platform.Exceptions.csproj: Updated project configuration for resource generation

🧪 Testing

  • InternationalizationTests.cs: Comprehensive test suite validating:
    • English/Russian localization for ArgumentNullException messages
    • English/Russian localization for ArgumentException messages
    • Exception formatting localization

🚀 Features

Supported Languages

  • English (default/fallback)
  • Russian (ru-RU culture)

Localized Messages

  • Argument null exception messages
  • Argument criteria validation messages
  • Exception formatting text
  • Inner exception labels

📊 Test Results

All tests pass successfully:

Passed!  - Failed:     0, Passed:     5, Skipped:     0, Total:     5

🔄 Version Updates

  • Version: Updated to 0.6.0
  • Release Notes: "Added internationalization support for exception messages. Supports English and Russian languages."

💡 Usage Example

// Will show localized messages based on current thread's UI culture
Ensure.Always.ArgumentNotNull(null, "testParam");

// English: "Argument testParam is null."
// Russian: "Аргумент testParam равен null."

📝 Notes

  • Uses standard .NET resource localization patterns
  • Thread-safe resource access
  • Fallback to English if translation not available
  • Maintains backward compatibility

Fixes #17

🤖 Generated with Claude Code

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

Issue: #17
@konard konard self-assigned this Sep 14, 2025
- Added resource files for English (default) and Russian translations
- Created Resources.Designer.cs with strongly-typed resource access
- Replaced hardcoded strings in EnsureExtensions.cs and ExceptionExtensions.cs with resource references
- Added comprehensive tests for localization functionality
- Updated project version to 0.6.0 and release notes

🤖 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 Add internationalization support for exception messages Sep 14, 2025
@konard konard marked this pull request as ready for review September 14, 2025 11:38
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

1 participant