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

(Bug, guidance 2022.2.1.9, 04/11/2022) Blazor has an exception in About.razor for some languages #77

Closed
vvdb-architecture opened this issue Nov 10, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@vvdb-architecture
Copy link
Contributor

vvdb-architecture commented Nov 10, 2022

If your language is not EN or FR (for example: NL), the system falls back to the default About.resx and Global.resx.
About.razor assumes a specific formatting for a language in the resource called "cultures":

            @foreach (var cultureItem in Localizer["cultures"].ToString().Split(';'))
            {
                var c = cultureItem.Split(',');
                <Panel Color="secondary-300" Flat>
                    <Button OnClick="@(() => SetCulture(c[0]))">@c[1]</Button>
                </Panel>
            }

Unfortunately, About.resx contains the following content for "cultures":

cultures

There is no comma, therefore the var c = cultureItem.Split(',') yields a 1-sized array and c[1] fails.

      Unhandled exception rendering component: Index was outside the bounds of the array.
System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at Elia.HappyFlow.Client.Pages.About.<>c__DisplayClass0_0.<BuildRenderTree>b__9(RenderTreeBuilder __builder6) in C:\PRJ\Demo\HappyFlow\FE\Client\HappyFlow.Client\Pages\About.razor:line 34
   at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment)
   at Nova.Components.Button.<BuildRenderTree>b__0_0(RenderTreeBuilder __builder2)
   at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment)
   at Nova.Components.NovaBaseComponent.BuildRenderTree(RenderTreeBuilder builder)
   at Microsoft.AspNetCore.Components.ComponentBase.<.ctor>b__6_0(RenderTreeBuilder builder)
   at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException)

Two options:

  • set the value to a properly formatted language like in the other fields
  • make the code in About.razor more robust.
@vvdb-architecture
Copy link
Contributor Author

Still a problem in 2022.1.12--rc3

@rdarko rdarko added the bug Something isn't working label Apr 5, 2023
@vvdb-architecture
Copy link
Contributor Author

Still a problem in Guidance 2022.2.1.14

@rdarko
Copy link
Collaborator

rdarko commented May 8, 2024

I will close this, and we will focust on the above mentioned one, since its, according to Vincent, better explained.

@rdarko rdarko closed this as completed May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants