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

HebrewCalendar not working properly on client side blazor #107731

Open
1 task done
ysroels opened this issue Sep 11, 2024 · 12 comments
Open
1 task done

HebrewCalendar not working properly on client side blazor #107731

ysroels opened this issue Sep 11, 2024 · 12 comments
Assignees
Labels
arch-wasm WebAssembly architecture area-System.Globalization needs-author-action An issue or pull request that requires more info or actions from the author. no-recent-activity os-browser Browser variant of arch-wasm
Milestone

Comments

@ysroels
Copy link

ysroels commented Sep 11, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

printing DateTime using "he-IL" CultureInfo and the HebrewCalendar outputs the date with the month written in digits or using Latin characters instead of Hebrew characters.

Expected Behavior

The expected output of a DateTime printed using a "he-IL" CultureInfo that uses the HebrewCalendar would be fully in Hebrew characters (as is indeed the case when printing a DateTime on the server instead of client side)

Steps To Reproduce

string GetHebrewDate(DateTime d)
    {
        var hc = new HebrewCalendar();
        var culture = CultureInfo.CreateSpecificCulture("he-IL");
        culture.DateTimeFormat.Calendar = hc;
        return d.ToString("dd MMM yyyy", culture);
    } 

var d = new DateTime(2024,0,12);
var a = GetHebrewDate(d);

//EXPECTED:
//d = "ט' אלול תשפ"ד"

//ACTUAL:
//d = "ט' Elul תשפ"ד"

Exceptions (if any)

No response

.NET Version

confirmed on 7

Anything else?

No response

@javiercn
Copy link
Member

@javiercn javiercn transferred this issue from dotnet/aspnetcore Sep 12, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Sep 12, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-globalization
See info in area-owners.md if you want to be subscribed.

@tarekgh tarekgh added the arch-wasm WebAssembly architecture label Sep 12, 2024
Copy link
Contributor

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

@Clockwork-Muse
Copy link
Contributor

Expected Behavior

The expected output of a DateTime printed using a "he-IL" CultureInfo that uses the HebrewCalendar would be fully in Hebrew characters (as is indeed the case when printing a DateTime on the server instead of client side)

Pedantically, this isn't actually guaranteed (although it is likely). Culture data is sourced from the OS, and is subject to change without warning for no obvious reason. You should not rely on its stability.

@lewing lewing added this to the 10.0.0 milestone Sep 12, 2024
@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Sep 12, 2024
@lewing lewing added the os-browser Browser variant of arch-wasm label Sep 12, 2024
@ilonatommy
Copy link
Member

@ysroels, what globalization settings are you using? Do you have

<PropertyGroup>
  <BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData>
</PropertyGroup>

set?

@ysroels
Copy link
Author

ysroels commented Sep 13, 2024

@ilonatommy I do indeed have that set.
Hebrew month names (in Hebrew characters) are probably a part of International Components for Unicode (ICU) as @javiercn alluded, for which tooling is scheduled in November for .Net 9.

@ilonatommy
Copy link
Member

It seems to be a blazor-only issue, on WASM app the problem does not exist. I will update when I have more info.

@ilonatommy
Copy link
Member

ilonatommy commented Sep 19, 2024

There are two issues connected with this report. One is the know effect of trying to limit data loaded to browser - we're not adding all possible ICU data, even with BlazorWebAssemblyLoadAllGlobalizationData. You can look up the filters used for the "full" set here: https://github.com/dotnet/icu/blob/dotnet/main/icu-filters/icudt_wasm.json.
As you can notice, we are adding additionally a few calendars:

{
            "categories": ["locales_tree"],
            "files": {
                "blacklist": ["root"]
            },
            "rules": [
                "-/calendar/*",
                "+/calendar/default",
                "+/calendar/gregorian",
                "+/calendar/generic"
            ]
        },

but not +/calendar/hebrew. You can edit it for yourself and then build the ICU locally with ./build.sh /p:TargetOS=Browser /p:TargetArchitecture=wasm - the detailed docs can be found in docs.
I created 2 versions: one is the "full" ICU + hebrew calendars and the other is no_CJK no_cjk_filters + hebrew calendar, attaching them here for your reference.
You're loading them with

<BlazorIcuDataFileName>path/To/icudt_no_CJK_he_cal.dat</BlazorIcuDataFileName>

icudt_with_he_cal.zip

The other issue is that if you are using net9 of P7+, with fingerprinting, you can have problems with loading that custom file - we're fixing it in #108011 and will backport it asap. Without this fix you can load custom ICU only if you disable fingerprinting: <WasmFingerprintAssets>false</WasmFingerprintAssets>.

There's a minor mistake in the repro code: we cannot index months from 0, DateTime.

Let me know if this worked.

@ilonatommy
Copy link
Member

Culture data is sourced from the OS, and is subject to change without warning for no obvious reason. You should not rely on its stability.

In WASM apps, culture data is sourced from icu transport nugets that change when there's a change in CLDR. Using the OS's NLS applies to applications that do not run in browser's sandboxed environment.

@Clockwork-Muse
Copy link
Contributor

In WASM apps, culture data is sourced from icu transport nugets that change when there's a change in CLDR. Using the OS's NLS applies to applications that do not run in browser's sandboxed environment.

Sure, but at that point the nuget packages are essentially the OS packages (NLS or not), and the same considerations apply.

@ilonatommy ilonatommy added the needs-author-action An issue or pull request that requires more info or actions from the author. label Sep 19, 2024
Copy link
Contributor

This issue has been marked needs-author-action and may be missing some important information.

Copy link
Contributor

This issue has been automatically marked no-recent-activity because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will remove no-recent-activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-wasm WebAssembly architecture area-System.Globalization needs-author-action An issue or pull request that requires more info or actions from the author. no-recent-activity os-browser Browser variant of arch-wasm
Projects
None yet
Development

No branches or pull requests

6 participants