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 Add Page without parent while Using Persian (Iran) Language #5054

Closed
behzadvahidpour opened this issue Feb 1, 2025 · 9 comments
Closed

Comments

@behzadvahidpour
Copy link

Oqtane Info

Version -6.0.2.0
Render Mode - Static
Interactivity - Server
Database - SQL Server

application returning error whenever in language section i select Iran(Fa) and try to add new page Parent:

Error Loading Page The input string '-1' was not in a correct format.

exception generated by the system

System.FormatException: The input string '-1' was not in a correct format.
at System.Number.ThrowFormatException[TChar](ReadOnlySpan1 value) at System.Int32.Parse(String s) at Oqtane.Modules.Admin.Pages.Add.<OnInitializedAsync>b__34_0(Page item) in D:\Project\oqtane.framework-dev\oqtane.framework-dev\Oqtane.Client\Modules\Admin\Pages\Add.razor:line 276 at System.Linq.Enumerable.ListWhereIterator1.MoveNext()
at Oqtane.Modules.Admin.Pages.Add.OnInitializedAsync() in D:\Project\oqtane.framework-dev\oqtane.framework-dev\Oqtane.Client\Modules\Admin\Pages\Add.razor:line 276

{"Error":"The input string \u0027-1\u0027 was not in a correct format."}

Steps To Reproduce

1- Adding Persian (Iran) for localization and enable it
2- Add new Page
3- Select as Parent Page

Image

@sbwalker
Copy link
Member

sbwalker commented Feb 1, 2025

@behzadvahidpour localization only affects the display of the UI text - it does not affect functionality. I am unable to reproduce the problem locally. This usually means that there is something specific to your environment or the data in your installation which is causing the issue. Please include the browser Url in the screen shot and also click the Parent dropdown so that the list of pages in displayed in the screen shot as well - this may provide hints why your installation is throwing an exception. The error message is indicating that the Page ID has single quotes enclosing it - which should not be possible as Page Id is stored an integer in the database.

@behzadvahidpour
Copy link
Author

@sbwalker I did record the entire process, & also screenshots of the Parent dropdown list of pages thx.

Image

Image
Image

@behzadvahidpour
Copy link
Author

behzadvahidpour commented Feb 2, 2025

I tried removing deleted pages from recycle bin and also any Persian character from page name and title

I believe it's caused by using Persian character in the name of the page

Image

@sbwalker
Copy link
Member

sbwalker commented Feb 3, 2025

@behzadvahidpour I am able to reproduce the problem locally... but I have no explanation for the behavior. I added some debugging statements:

Image

The value of _parentid is "-1" however when the int.Parse() is executed it throws an error:

Image

This error only occurs when the culture is set to Persian (Iran)

@sbwalker
Copy link
Member

sbwalker commented Feb 3, 2025

It appears that in order to support Persian, the InvariantCulture method of int.Parse needs to be used:

int.Parse(_parentid, CultureInfo.InvariantCulture)

And since the technique of using a "-1" string to represent an "undefined" option is used throughout the framework, this would require a lot of changes to address the problem (ie. it is not confined to "Add Page")

@leigh-pointer
Copy link
Contributor

Just tried setting up defaults in program.cs

        public static async Task Main(string[] args)
        {
            var builder = WebAssemblyHostBuilder.CreateDefault(args);

            // Set the default culture to InvariantCulture
            CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
            CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture;

but unfortunately that didn't help :(

This issue can affect all Right-to-Left (RTL) languages (e.g., Arabic, Persian, Urdu, Hebrew)

zyhfish added a commit to zyhfish/oqtane.framework that referenced this issue Feb 10, 2025
zyhfish added a commit to zyhfish/oqtane.framework that referenced this issue Feb 10, 2025
@zyhfish
Copy link
Contributor

zyhfish commented Feb 10, 2025

I tried to submit PR #5083 to resolve this issue. but it's not a perfect solution as we may introduce new references to int.Parse in future, also we can't make sure 3rd party module developers know this restrict and use this converter instead of original parse function.

zyhfish added a commit to zyhfish/oqtane.framework that referenced this issue Feb 10, 2025
zyhfish added a commit to zyhfish/oqtane.framework that referenced this issue Feb 10, 2025
@zyhfish
Copy link
Contributor

zyhfish commented Feb 13, 2025

submitted another PR #5094 which should be the correct solution.

@behzadvahidpour
Copy link
Author

Thank you for your effort to solve this issue. I am eagerly waiting for the new release. @sbwalker @zyhfish @leigh-pointer

sbwalker added a commit that referenced this issue Feb 19, 2025
Fix #5054: resolve the issue in fa-IR language.
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

4 participants