Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't load resource from javascript after update to 7.1 #15536

Closed
1 task done
sturlath opened this issue Jan 29, 2023 · 1 comment
Closed
1 task done

Can't load resource from javascript after update to 7.1 #15536

sturlath opened this issue Jan 29, 2023 · 1 comment

Comments

@sturlath
Copy link
Contributor

sturlath commented Jan 29, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Description

I have a dropdown that needs localization but after updating to version 7.1 its not working anymore.

In the case below I just get PleaseSelectSports in the dropdown but not "Please select your sport" text that is in resources.

@section scripts{
    <abp-script src="/Pages/MyPage.cshtml.js" />
}

<abp-dropdown>
    <abp-dropdown-button class="" id="dropdownChangedSportsType" text="loading..." />
</abp-dropdown>

and then my javascript

$(function () {
const urlParams = new URLSearchParams(window.location.search);
document.querySelector('#dropdownChangedSportsType').children[0].innerText = abp.localization.localize('PleaseSelectSports');

If I put

<h1>@Localizer["PleaseSelectSports"]</h1> on the .cshtml page I can see it being localized but if I put this code into the javascript it returns false so it looks like the resource isn't loaded when the javascript is run.

abp.localization.isLocalized('PleaseSelectSports', 'MyResource'); //with my resources!

And then I saw this

Localization logic is changed in v7.0

I have tried various things without luck and then I saw this here "I also fixed a bug in the abp.localization.localize method for MVC UI." that feels like its connected.

Version

7.0.1

User Interface

MVC

Database Provider

EF Core (Default)

Tiered or separate authentication server

Separate Auth Server

Operation System

Windows (Default)

Other information

No response

@sturlath sturlath added the bug label Jan 29, 2023
@sturlath
Copy link
Contributor Author

OK I just figured this out!

I had skipped this step External Localization Infrastructure and the reason was probably the "External" part!

I added this script tag and now it works

<script src="~/Abp/ApplicationLocalizationScript?cultureName=@CultureInfo.CurrentUICulture.Name"></script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants