-
Notifications
You must be signed in to change notification settings - Fork 5.4k
[browser][coreclr] ICU download #121800
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
Merged
Merged
[browser][coreclr] ICU download #121800
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
1df4970
Added function to load ICU data in browser host and commented out ENV…
dariatiurina 9adc35b
Fixes
dariatiurina 6de2394
Fixed choosing the correct ICU shard
dariatiurina 40e07e9
Small import clean-up
dariatiurina ed967ab
Refactoring
dariatiurina 0229a48
Fornat
dariatiurina 79a13f6
Adding the GetLocaleInfo import
dariatiurina 9c3c428
Merge branch 'main' into icu-wasm-coreclr
dariatiurina 2c4d3bb
Fix
dariatiurina 01ee525
Small clean-up and fixes
dariatiurina a81ddb9
Add direct reference
dariatiurina 8880ac9
Small clean-up
dariatiurina File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/libraries/Common/src/Interop/Browser/Interop.Locale.CoreCLR.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
| using System.Runtime.InteropServices; | ||
|
|
||
| internal static partial class Interop | ||
| { | ||
| internal static unsafe partial class JsGlobalization | ||
| { | ||
| [LibraryImport(Libraries.JavaScriptNative, EntryPoint = "SystemJS_GetLocaleInfo")] | ||
| public static unsafe partial nint GetLocaleInfo(char* locale, int localeLength, char* culture, int cultureLength, char* buffer, int bufferLength, out int resultLength); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import type { LoaderConfig } from "./types"; | ||
| import { GlobalizationMode } from "./types"; | ||
| import { ENVIRONMENT_IS_WEB } from "./per-module"; | ||
|
|
||
| export function getIcuResourceName(config: LoaderConfig): string | null { | ||
| if (config.resources?.icu && config.globalizationMode != GlobalizationMode.Invariant) { | ||
| const culture = config.applicationCulture || (ENVIRONMENT_IS_WEB ? (globalThis.navigator && globalThis.navigator.languages && globalThis.navigator.languages[0]) : Intl.DateTimeFormat().resolvedOptions().locale); | ||
| if (!config.applicationCulture) { | ||
| config.applicationCulture = culture; | ||
| } | ||
|
|
||
| const icuFiles = config.resources.icu; | ||
| let icuFile = null; | ||
| if (config.globalizationMode === GlobalizationMode.Custom) { | ||
| // custom ICU file is saved in the resources with fingerprinting and does not require mapping | ||
| if (icuFiles.length >= 1) { | ||
| return icuFiles[0].name; | ||
| } | ||
| } else if (!culture || config.globalizationMode === GlobalizationMode.All) { | ||
| icuFile = "icudt.dat"; | ||
| } else if (config.globalizationMode === GlobalizationMode.Sharded) { | ||
| icuFile = getShardedIcuResourceName(culture); | ||
| } | ||
|
|
||
| if (icuFile) { | ||
| for (let i = 0; i < icuFiles.length; i++) { | ||
| const asset = icuFiles[i]; | ||
| if (asset.virtualPath === icuFile) { | ||
| return asset.name; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| config.globalizationMode = GlobalizationMode.Invariant; | ||
| return null; | ||
| } | ||
|
|
||
| function getShardedIcuResourceName(culture: string): string { | ||
| const prefix = culture.split("-")[0]; | ||
| if (prefix === "en" || ["fr", "fr-FR", "it", "it-IT", "de", "de-DE", "es", "es-ES"].includes(culture)) { | ||
| return "icudt_EFIGS.dat"; | ||
| } | ||
|
|
||
| if (["zh", "ko", "ja"].includes(prefix)) { | ||
| return "icudt_CJK.dat"; | ||
| } | ||
|
|
||
| return "icudt_no_CJK.dat"; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.