Skip to content

Conversation

Copy link

Copilot AI commented Dec 1, 2025

Implements configurable behavior when a localization key is not found (issue #38). Users can now choose to ignore (default), log a warning, or throw an exception.

Changes

  • MissingLocalizationBehavior enum - Defines Ignore, LogWarning, ThrowException options
  • MissingLocalizationException - Custom exception with key, culture, and searched location details
  • JsonLocalizationOptions.MissingLocalizationBehavior - New property (defaults to Ignore for backward compatibility)
  • JsonStringLocalizer - Handles missing localization based on configured behavior
  • JsonStringLocalizerLoggerExtensions - Added warning log message for missing localizations

Usage

services.AddJsonLocalization(options =>
{
    options.ResourcesPath = "Resources";
    options.MissingLocalizationBehavior = MissingLocalizationBehavior.ThrowException;
});

When a key is missing with ThrowException:

MissingLocalizationException: Localization for key 'MyKey' was not found for culture 'fr-FR' in '/path/to/resources'.
Original prompt

This section details on the original issue you should resolve

<issue_title>Missing Localization Behavior</issue_title>
<issue_description>We can:

  • Add log entry

  • Throw an exception

  • Ignore and use the localization key</issue_description>

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


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Dec 1, 2025
Copilot AI changed the title [WIP] Fix missing localization behavior by adding log entry or exception Add configurable missing localization behavior Dec 1, 2025
Copilot AI requested a review from hishamco December 1, 2025 01:51
Copilot finished work on behalf of hishamco December 1, 2025 01:51
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.

Missing Localization Behavior

2 participants