Is it possible to put the translation files in folders to get more organized?

Asked

Viewed 33 times

0

I would like to put the translation files organized by folders in this way

inserir a descrição da imagem aqui

Everything in the root of the folder Resources works but moves into that other folder stops working as I can configure so that I can access translations in that folder?

Things I set up: In the Startup.Cs file

    public void ConfigureServices(IServiceCollection services)
        {
            services.AddLocalization(option => option.ResourcesPath = "Resources");
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

        }

At the beginning of each Controller

private readonly IStringLocalizer<ValuesController> _localizer;

public ValuesController(IStringLocalizer<ValuesController> localizer)
{
 _localizer = localizer;
}

1 answer

0


I found the solution so just follow the following pattern

If my controller is in the Folder /Controllers/Novapasta/Exemplocontroller.Cs

Then I can put the translation file as follows

Resources/Controllers/Novapasta/Exemplocontroller.en.resx Resources/Controllers/Novapasta/Exemplocontroller.pt.resx

If I want to reduce a folder I can do as follows Resources/Controllers/Newfolder.ExemployController.en.resx Resources/Controllers/Newfolder.ExemployController.pt.resx

What I did was add the folder name to the resx file name

Browser other questions tagged

You are not signed in. Login or sign up in order to post.