valdisiljuconoks / LocalizationProvider

Database driven localization provider for .NET applications (core assemblies)
https://tech-fellow.eu/
Apache License 2.0
123 stars 41 forks source link

Properties with UseResourceAttribute returns null #265

Closed stefanolsen closed 11 months ago

stefanolsen commented 1 year ago

I have a good number of translation classes in a project. Some of them has UseResource attributes, like the following:

[LocalizedResource]
[TsInterface]
public class AResourceClass
{
    public string LabelOne { get; set; } = "An English text";

    [UseResource(typeof(GlobalResources), nameof(GlobalResources.ASharedLabel))]
    public string LabelTwo { get; set; }
}

If I call _localizationProvider.Translate<AResourceClass>(), then LabelOne will have a value, while LabelTwo will be null.

But explicitly requesting only the LabelTwo property, like the following, returns the expected string: _localizationProvider.GetString(_resourceKeyBuilder.BuildResourceKey(typeof(AResourceClass), nameof(AResourceClass.LabelTwo)))

Package version:

valdisiljuconoks commented 1 year ago

Hi Stefan,

Sounds like a bug. Will take a look at next round for release (January timeline).