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 get "language" parameter during "IInstantiationProcessor" or "IUserAction" #927

Closed
violaguttorm opened this issue Nov 25, 2024 · 7 comments
Labels
kind/bug Something isn't working status/triage

Comments

@violaguttorm
Copy link

Description of the bug

I need the language parameter for these as I need to store certain values in the datamodel in the correct language for the user.

IInstantiationProcessor->DataCreation does not have any parameters for language at all.
IUserAction->HandleAction has a parameter of the type UserActionContext, which has a Language-parameter, but this one is always null.

According to the Network-tab in the browser, at least HandleAction does not even send language as part of the HTTP-request, so there in no way I can get it.

Steps To Reproduce

  1. Try instantiating a form and getting the language.
  2. Try to create a button that triggers IUserAction->HandleAction.

Additional Information

No response

@violaguttorm violaguttorm added the kind/bug Something isn't working label Nov 25, 2024
@ivarne
Copy link
Member

ivarne commented Nov 26, 2024

Correct that it is missing on DataCreation. It's somewhat hard to update interfaces (we need to have an update script for apps, but we only do that on major releases), but we could at least send the data from frontend, so you can get it from _httpContextAccessor.HttpContext.Request.Query.TryGetValue("language", out var language);.

For the UserActionContext, I think the issues should be fixed in the latest versions. What versions of frontend and backend are you using?

@ivarne
Copy link
Member

ivarne commented Nov 26, 2024

As far as I read the current main app-frontend-react code, we already send ?language=nb as a query parameter, so getting it from httpContext should work.

@violaguttorm
Copy link
Author

@ivarne I am stuck on front-end version 4.8.2 because of an unrelated issue (Altinn/app-frontend-react#2755), but I can confirm the language parameter is there if I force the newest version. So the instantiation problem is solved as soon as we figure out the other issue! 😊

The UserActionContext still doesn't work however. It has a parameter for Language (context.Language), but it always becomes null, at least when I test locally. I updated Altinn.App.Api and Altinn.App.Core from version 8.2.4 to version 8.3.8 (what NuGet recommended), but it still didn't work. The "actions" call also does not contain a language query parameter even on the newest (default) front-end. I haven't tried the preview ones.

Am I doing something wrong?
Here is the code where I try to print the language code to no avail (excuse the test code around it, I have also taken a look with more sophisticated debugging tools however, and can confirm it is indeed null): https://altinn.studio/repos/brg/rrh-innrapportering/src/branch/560-engelsk-nynorsk/App/logic/Actions/FnrSearchAction.cs#L73

Here is the place I use this for a button in the layout: https://altinn.studio/repos/brg/rrh-innrapportering/src/branch/560-engelsk-nynorsk/App/ui/rrh-form/layouts/rrh_utfylling.json#L183

@ivarne
Copy link
Member

ivarne commented Nov 27, 2024

It is fixed in 8.5.0 release candidates as well.

@violaguttorm
Copy link
Author

@ivarne Is this 8.5.0-rc9 of both Core and Api, yes? I have updated to that version locally, but the context.Language parameter is still empty in my implementations of IUserAction->HandleAction. Language is also not sent as a query-parameter (using simply version 4 for the front-end and no specific version). I pushed my changes to this branch (same as I linked code from above) , can you see anything I'm doing wrong?

https://altinn.studio/repos/brg/rrh-innrapportering/src/branch/560-engelsk-nynorsk

@ivarne
Copy link
Member

ivarne commented Nov 27, 2024

Now I see, frontend does not send this properly, for user actions triggered by custom button. I'll open an issue in frontend.

@ivarne
Copy link
Member

ivarne commented Nov 27, 2024

Closing this in favour of the more focused issue in frontend. Altinn/app-frontend-react#2759

@ivarne ivarne closed this as completed Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working status/triage
Projects
Status: No status
Development

No branches or pull requests

2 participants