Hi team,
I’m using ABP Framework v8.0.4 with an ABP Suite–generated application, and I’m working with the Language Management → Language Texts page. By default, this view allows us to edit existing texts but doesn’t provide a direct button to create a new language text entry. I’d like to add a custom “Create Language Text” button (for example, in the toolbar of the Language Texts table) that will open a modal or a new page to enter the following details manually:
Resource Name(Dropdown) Culture Name(Dropdown) Name (key) Value
After submission, it should call the backend API (PUT /api/language-management/language-texts) to create or update the text dynamically using ILanguageTextAppService.UpdateAsync().
Could you please guide me on: The recommended way to extend or customize the Language Texts page in an ABP Suite app? How to inject a new toolbar button and open a modal dialog or redirected to a create page with input fields ? Whether there’s an existing ABP component or helper for LanguageText creation that I can reuse?
Environment: ABP Framework Version: 8.3.4 UI Framework: MVC (Razor Pages) Tiered: Yes Database: SQL Server
Expected Outcome: A “Create” button (similar to other ABP entity pages) on the Language Texts list page that allows adding a new translation text manually and saves it using the existing Language Management APIs.
3 Answer(s)
-
0
To add a custom "Create Language Text" button to the Language Texts page in your ABP MVC (Razor Pages) application, follow these steps:
- Extend the Page Toolbar with a Custom Button
In your Web module's
ConfigureServices
method, use the ABP Page Toolbar Extensions to add a new button to the Language Texts page toolbar:Configure<AbpPageToolbarOptions>(options => { options.Configure<Volo.Abp.LanguageManagement.Web.Pages.LanguageManagement.LanguageTexts.IndexModel>(toolbar => { toolbar.AddButton( LocalizableString.Create<YourResource>("CreateLanguageText"), icon: "plus", id: "CreateLanguageTextButton", type: AbpButtonType.Primary ); }); });
- Add the "CreateLanguageText" string to your localization files.
- Add the Modal or Redirect Logic
- In your
Index.cshtml
(or the corresponding Razor Page), add JavaScript to handle the button click. You can use ABP's modal helpers or redirect to a custom create page.
Example for opening a modal (using Bootstrap/ABP modal):
$(function () { $('#CreateLanguageTextButton').click(function () { abp.modals.open({ title: 'Create Language Text', size: 'lg', bodyUrl: '/LanguageManagement/LanguageTexts/CreateModal' }); }); });
- Create the Modal or Create Page
- Add a new Razor Page (e.g.,
CreateModal.cshtml
) under/Pages/LanguageManagement/LanguageTexts/
. - The page should contain a form with fields: Resource Name (dropdown), Culture Name (dropdown), Name (key), and Value.
- On form submission, call the backend API (
PUT /api/language-management/language-texts
) using AJAX or ABP's form helpers.
Example form (simplified):
<form id="createLanguageTextForm"> <!-- Resource Name dropdown --> <!-- Culture Name dropdown --> <!-- Name (key) input --> <!-- Value input --> <button type="submit" class="btn btn-primary">Save</button> </form> <script> $('#createLanguageTextForm').submit(function (e) { e.preventDefault(); // Collect form data // Call the API using abp.ajax or $.ajax }); </script>
- Backend API Usage
- Use
ILanguageTextAppService.UpdateAsync()
in your backend to create or update the language text. - The API endpoint is already available in ABP Language Management module.
- Reusable Components
- There is no built-in ABP modal for creating language texts, but you can reuse ABP's form and modal helpers for consistency.
- For reference on converting modals to pages or customizing modals, see the community article below.
Sources:
- Page Toolbar Extensions (Official ABP Docs)
- Converting Create/Edit Modal to Page (Community Article)
This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.
-
0
When I use the above code, it creates a button on the /Pages/LanguageManagement view, which is used to create a new language. However, the below code creates a button on the /Pages/LanguageManagement/Texts page:
Configure<AbpPageToolbarOptions>(options => { options.Configure<Volo.Abp.LanguageManagement.Pages.LanguageManagement.Texts.IndexModel>(toolbar => { toolbar.AddButton( LocalizableString.Create<QueuingSystemAppResource>("CreateLanguageText"), icon: "plus", id: "CreateLanguageTextButton", type: AbpButtonType.Primary ); }); });
Since the application is created using ABP Suite, there is no visible /Pages/LanguageManagement/Texts/Index.cshtml file in the web project. So, where should I place the button click and related logic?
-
0
hi
You can add a custom JavaScript file to the
wwwroot
folder and add it totypeof(Volo.Abp.LanguageManagement.Pages.LanguageManagement.Texts.IndexModel).FullName
bundleSee https://abp.io/docs/latest/framework/ui/mvc-razor-pages/bundling-minification#configuring-an-existing-bundle
Thanks.