Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

MultiLingual Entities - Creation #6892


User avatar
0
geaton created

Hi,

I was following the tutorial about MLE and got stucked with the CRUD/Creation part

<br>

public class ProductDto
{
    public decimal Price { get; set; }

    public ICollection<ProductTranslationDto> Translations { get; set; }
}

//After defining such a Dto class, we can use it in our application service to create a Multi-Lingual entity.

public class ProductAppService : ApplicationService, IProductAppService
{
    private readonly IRepository<Product> _productRepository;

    public ProductAppService(IRepository<Product> productRepository)
    {
        _productRepository = productRepository;
    }

    public async Task CreateProduct(ProductDto input)
    {
        var product = ObjectMapper.Map<Product>(input);
        await _productRepository.InsertAsync(product);
    }
}```

If the CreateProduct() AppService method receives a ProductDto with all Translations of type ProductTranslationDto. What are the properties of that Dto? How do I specifify each language of every translated "Name"?

Because the ProductTranslationDto defined in the example is this. But there is no property to define the "Language" of that translation


[AutoMap(typeof(ProductTranslation))]
public class ProductTranslationDto
{
    public string Name { get; set; }
}

What am I missing?


Thanks in advanced for your help

5 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    hi @geaton

    The definition of the ProductTranslationDto class should be:

    public class ProductTranslationDto
    {
    	public string Name { get; set; }
    
    	public string Language { get; set; }
    }
    

    I will update the documentation. :)

  • User Avatar
    0
    FlexSolution created

    I have a question about that, too. If I use such a MultiLingual Entity, what about the translation for the individual languages?

    Do I have to create my own page or is it implemented so that I can edit these translations on the same page that you use for the translations from the XML files?

  • User Avatar
    0
    maliming created
    Support Team

    @FlexSolution You have to maintain it yourself.

    see: https://github.com/aspnetboilerplate/aspnetboilerplate/blob/e0ded5d8702f389aa1f5947d3446f16aec845287/test/Abp.ZeroCore.Tests/Zero/MultiLingual/MultiLingual_Entity_Tests.cs

    https://github.com/aspnetboilerplate/aspnetboilerplate/blob/e0ded5d870/test/Abp.ZeroCore.SampleApp/Application/Shop/ProductAppService.cs#L48

  • User Avatar
    0
    FlexSolution created

    Okay, thanks for the info.

    What do you think about the suggestion that you have the option to select fields as multilingual in the PowerTool? Then you could do it faster and easier.

    Additionally, as a second extension, it might be an option to implement such fields in the same translation mask as the XML files. You could control this with an option in the settings, for example. So you could still make a custom version or integrate it into the existing translation page as needed.

    What do you think?

  • User Avatar
    0
    maliming created
    Support Team

    What do you think about the suggestion that you have the option to select fields as multilingual in the PowerTool? Then you could do it faster and easier.

    I think PowerTool may not add this feature.

    I mean these translations are dynamic, you may have many such entities, which may be modified or deleted at any time.

    So you need to maintain it according to your actual situation. It can't be applied to everyone.