-
Notifications
You must be signed in to change notification settings - Fork 178
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
WASM Demo #4684
base: main
Are you sure you want to change the base?
WASM Demo #4684
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking into this!
let fallbackerWithConfig = fallbacker.for_config(fallbackConfig); | ||
|
||
this.fallbacker = fallbackerWithConfig; | ||
enProvider.enable_locale_fallback_with(this.fallbacker); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue: enable_locale_fallback_with
should take a ICU4XLocaleFallbacker
, not a ICU4XLocaleFallbackerWithConfig
. I think TypeScript should catch this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I wanted to display the fallbacked
locale. ICU4XLocaleFallbackerWithConfig
gives an iterator which helps to get the fallback, not sure how to achieve this using ICU4XLocaleFallbacker
.
Also it doesn't through an error 😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The resolved locale is returned in DataResponseMetdata.locale
(None
if it's the request locale).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(oh this is not Rust, ignore my comment).
Just to test the new fallbacker instead of let enProvider = await createDataProviderFromBlob('dist/en.postcard');
let unProvider = await createDataProviderFromBlob('dist/und.postcard');
let fallbacker = ICU4XLocaleFallbacker.create(unProvider);
enProvider.enable_locale_fallback_with(fallbacker);
const locale = result(() => ICU4XLocale.create_from_string("bn"));
const groupingStrategy = ICU4XFixedDecimalGroupingStrategy.Auto;
const formatter = result(() => ICU4XFixedDecimalFormatter.create_with_grouping_strategy(
enProvider,
unwrap(locale),
groupingStrategy
)); Also @robertbastian for caching we could possible generate a hash of |
const enFilePath = 'dist/en.postcard'; | ||
let enProvider = await this.createDataProviderFromBlob(enFilePath); | ||
this.loadedLocales.add(ICU4XLocale.create_from_string("en")); | ||
const unFilePath = 'dist/en.postcard'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried this with dist/und.postcard
, with no help. Will fix this in consecutive commits**
Added changes suggested by @sffc & @robertbastian except the |
ICU4X WG discussion:
Conclusion: yes, merge this PR after comments have been resolved. |
This Pull Request is intended to shift our WASM demo from using
create_compiled
to dynamically load locales whenever request from a front end. It achieves falling task:Created a
DataProviderManager
which forks locales on the goAdded
fallback
with configIt prints the fallback locale, also printing trying possibilties
Fixes #2769
Also we could also discuss the possiblity of adding
DataGen
in our FFI declarations, I could only find it for Dart, not for C++ and JavaScript. I could work on this, if this is what dev wants. This could be useful reduce application's binary size, for eg.