Skip to content
This repository was archived by the owner on Nov 29, 2018. It is now read-only.

ResourceManagerStringLocalizer should support throwing if name not found #13

Closed
DamianEdwards opened this issue May 15, 2015 · 3 comments
Milestone

Comments

@DamianEdwards
Copy link
Member

Add the ability to configure the ResourceManagerStringLocalizer so that if a given resource name is not found it throws, rather than returning the key itself. This effectively makes it behave like the underlying ResourceManager API itself.

e.g.

public enum ResourceLookupBehavior
{
    UseNameIfNotFound,
    ThrowIfNotFound
}

public class ResourceManagerStringLocalizerFactory...
{
    ...
    public ResourceLookupBehavior ResourceLookupBehavior { get; set; } = ResourceLookupBehavior.UseNameIfNotFound;
    ...
}
@glen-84
Copy link

glen-84 commented Jun 5, 2015

This could be used by other implementations of IStringLocalizer, so you might consider making it more generic (f.e. LookupBehavior / StringLookupBehavior / LocalizedStringLookupBehavior).

@DamianEdwards DamianEdwards added this to the Backlog milestone Sep 8, 2015
leonardlabat added a commit to leonardlabat/Localization that referenced this issue Nov 6, 2015
…Localizer

- Added the ResourceLookupBehavior enum
- Using it into the LocalizationOptions
- Added it to the ResourceMangerStringLocalizer
- Refactored all the automatic fallbacks to the resource name (now use a
single method)
- Added unit tests for both specific behaviors

Addresses aspnet#13
@Rick-Anderson
Copy link

If you could make it act like MVC does when it can't find a view - that is, MVC will list the folders searched, that would really help debug.

An unhandled exception occurred while processing the request. InvalidOperationException: The view 'About' was not found. The following locations were searched: /Views/Home/About.cshtml /Views/Shared/About.cshtml.

@Eilon
Copy link
Contributor

Eilon commented Jan 3, 2017

Closing because there are no plans to implement this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants