Base solution for your next web application
Open Closed

LanguageAppService - Why is there no CreateLanguageText? #6327


User avatar
1
peabaw created

Hello there

The LanguageAppService gives us a possibility to edit a language text:

public async Task UpdateLanguageText(UpdateLanguageTextInput input)

But why is there no Create?

public async Task CreateLanguageText(CreateLanguageTextInput input)

I guess there is a very good reason for that that I missed, so please hit me in the head with that explenation!

I'm asking because we need to dynamically create translatable language texts from the GUI to be used in the application. We are creating forms with 1..N inputs with labels, and these labels must be translatable. I thought I would be able to use the language DB in Zero and just create then through API but am I right that I need to implement a separate DB for this?

Solution: Asp.Net Zero angular+webapi


6 Answer(s)
  • User Avatar
    0
    ryancyq created
    Support Team

    Related https://github.com/aspnetzero/aspnet-zero-core/issues/1827

  • User Avatar
    0
    maliming created
    Support Team

    If there is no dynamic situation here, you don't need to have the CreateLanguageText function.

    You can use abp's Language Text database, Refresh the cache after you create a new Language Text.

  • User Avatar
    0
    peabaw created

    We need to dynamically create the language texts.

    @maliming: Do you mean to work directly to the database and insert string that way?

  • User Avatar
    0
    maliming created
    Support Team

    Use IRepository<ApplicationLanguageText, long> to dynamically add new text, remember to refresh the cache.

  • User Avatar
    0
    mahendra created

    Hi maliming,

    We also need to add new text dynamically. Could you please let us know how to refresh the Cache in the Code.

    **"Use IRepository<ApplicationLanguageText, long> to dynamically add new text, remember to refresh the cache. **"

  • User Avatar
    0
    maliming created
    Support Team

    hi mahendra

    But I think the framework will automatically update the cache, you can try it.

    https://github.com/aspnetboilerplate/aspnetboilerplate/blob/552c0240c44d9899c1209fb20eb48d35b17d5e54/src/Abp.Zero.Common/Localization/MultiTenantLocalizationDictionaryCacheHelper.cs#L16

    https://github.com/aspnetboilerplate/aspnetboilerplate/blob/552c0240c44d9899c1209fb20eb48d35b17d5e54/src/Abp.Zero.Common/Localization/MultiTenantLocalizationDictionaryCacheCleaner.cs#L11