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

Switch to ICU MessageFormat #2759

Merged
merged 18 commits into from
Apr 30, 2021
Merged

Switch to ICU MessageFormat #2759

merged 18 commits into from
Apr 30, 2021

Conversation

askvortsov1
Copy link
Member

@askvortsov1 askvortsov1 commented Apr 5, 2021

Foundation for flarum/issue-archive#385
Closes #2745
Closes #2062 as moot

Changes proposed in this pull request:
Done:

  • Support +intl-icu files in locales and language packs for backend translator
  • Add integration tests for locale extender (can't for language pack extender, as that can only run in an extension)

TODO:

Reviewers should focus on:

  • Should +intl-icu be the default for ALL files? This might have slight performance ramifications, but it would also be more consistent (see expected results of custom_translation_exists_if_added vs custom_translation_does_not_exist_by_default in the backend tests). This would be a further breaking change though. But it would be more consistent with what's done on the frontend. Currently in the PR.
  • We still need a translation args pre-processing system, but I think that should go in a second PR.

Confirmed

  • Frontend changes: tested on a local Flarum installation.
  • Backend changes: tests are green (run composer test).

@askvortsov1 askvortsov1 marked this pull request as draft April 5, 2021 05:48
@davwheat
Copy link
Member

davwheat commented Apr 5, 2021

I'm for the first option too. Smaller bundle! 👍

@tankerkiller125
Copy link
Contributor

Maybe we should include +intl-icu as a prefix by default? That way language packs don't have too? But I'm not 100% certain on that one.

@askvortsov1
Copy link
Member Author

Maybe we should include +intl-icu as a prefix by default? That way language packs don't have too? But I'm not 100% certain on that one.

This might hurt performance, as MessageFormat is more complex than non-MessageFormat. However, consistency would be a benefit: we would no longer need to include curly braces in variable keys. Plus, we're using MessageFormat code in the frontend anyway.

@askvortsov1
Copy link
Member Author

I'm for the first option too. Smaller bundle!

I got it working for 95% of what we need via ultraq/icu-message-formatter#7, other needed changes are outlined in the same issue. If that isn't merged, we can just include the code from the PR in our repo; this library is very extensible!

@askvortsov1
Copy link
Member Author

After some more thought, why don't we ise intl+icu for everything, and transform backend keys to remove wrapping curly braces if present as a BC layer?

@askvortsov1 askvortsov1 marked this pull request as ready for review April 12, 2021 22:23
@askvortsov1
Copy link
Member Author

This is ready for review, but we can't merge until the items in TODO are implemented over in https://github.com/ultraq/icu-message-formatter

@askvortsov1 askvortsov1 changed the title WIP: Switch to ICU MessageFormat Switch to ICU MessageFormat Apr 18, 2021
@askvortsov1
Copy link
Member Author

No longer WIP, this is now ready for review.

Copy link
Member

@luceos luceos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks awesome, but please involve our translators if this hasn't happened yet (a discussion under the i18n - https://discuss.flarum.org/t/i18n - tag would be smart. At least they need to know in advance because this will be NBC for all translations.

@askvortsov1
Copy link
Member Author

Copy link
Contributor

@tankerkiller125 tankerkiller125 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@askvortsov1 askvortsov1 merged commit b455199 into master Apr 30, 2021
@askvortsov1 askvortsov1 deleted the as/use-icu-messageformat branch April 30, 2021 16:44
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

Successfully merging this pull request may close these issues.

transChoice broken in PHP translator Javascript Translator interval/explicit syntax is broken
4 participants