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

!!!FEATURE: Reform i18n mechanism #3804

Open
wants to merge 39 commits into
base: 9.0
Choose a base branch
from
Open

!!!FEATURE: Reform i18n mechanism #3804

wants to merge 39 commits into from

Conversation

grebaldi
Copy link
Contributor

@grebaldi grebaldi commented Jun 14, 2024

prelude to: #3773
refs: #3119

This PR reforms the UI's i18n mechanism by exposing a new function translate directly from the @neos-project/neos-ui-i18n package.

The function looks as follows:

function translate(
    fullyQualifiedTranslationAddressAsString: string,
    fallback: string | [string, string],
    parameters: Parameters = [],
    quantity: number = 0
): string;

And can be used like this:

translate(
  'Neos.Neos:Main:workspaces.allChangesInWorkspaceHaveBeenDiscarded',
  'All changes from workspace "{0}" have been discarded.',
  ['user-admin']
);

// output (en): All changes from workspace "user-admin" have been discarded.

The new mechanism is completely independent from registries. There's no longer a need for injecting the I18nRegistry to use translations, instead translate can be used directly.

translate will only work after the translations have been loaded during the bootstrapping process of @neos-project/neos-ui. If it is used too early, it throws an exception.

The function now also properly supports plural rules (via Intl Web API). Tha I18nRegistry had only supported English plurals, but with broken rules (quantity=0 yielded singular instead of plural).

Other changes included in this PR are:

  • Everything in @neos-project/neos-ui-i18n is now TypeScript (save manifest.js)
  • The <I18n/>-component was deprecated
  • The I18nRegistry is now properly documented, but was also deprecated
  • The xliff.json endpoint is now discovered via <link>-tag, instead of initial data
    • The <link>-tag is marked with prefetch to slightly speed up the fetch request
  • The @neos-project/neos-ui-i18n now has a comprehensive README.md

This change is breaking, because translations may have relied on the broken plural rules. It is also breaking, because the signature for substitution parameters has changed slightly - although this should be non-breaking at runtime.

@github-actions github-actions bot added the 9.0 label Jun 14, 2024
@grebaldi grebaldi force-pushed the task/centralize-i18n branch 2 times, most recently from 33fb626 to 232e6a8 Compare June 28, 2024 12:57
@grebaldi grebaldi changed the title WIP: Centralize i18n WIP: Reform i18n mechanism Jun 28, 2024
@grebaldi grebaldi changed the title WIP: Reform i18n mechanism !!!FEATURE: Reform i18n mechanism Jun 28, 2024
@grebaldi grebaldi marked this pull request as ready for review June 28, 2024 13:46
@kitsunet kitsunet self-requested a review July 2, 2024 16:55
@kitsunet
Copy link
Member

kitsunet commented Jul 2, 2024

I like this, but wow it's also A LOT. Thanks for digging in!

@markusguenther
Copy link
Member

Rebased to latest 9.0 state.

@markusguenther
Copy link
Member

Locally the e2e tests run fine:

 Create new nodes
 - Create content collection node
 - Create text node in container
 ✓ Create a text node in a new container element at the correct position

 Create new nodes
 ✓ Check ClientEval for dependencies between properties of NodeTypes in Creation Dialog
 - Open create dialog node
 - Open context help and check for Markdown rendering
 ✓ Check the nodetype help in create dialog
 ✓ Check that nodetype without help has no help button
 - Create Image node
 - Select image from media library
 ✓ Create an Image node from ContentTree
 ✓ Can create a new page
 - Create a headline node
 - Type something inside of it
 - Inline validation
 - Skipped: Create a link to node
 ✓ Can create content node from inside InlineUI
 - Create an inline headline node
 - Insert text into the inline text and press enter
 ✓ Inline CKEditor mode `paragraph: false` works as expected
 ✓ Supports secondary inspector view for element editors

 Discarding
 - Create a document node
 - Create another node inside it
 - Discard all nodes and hope to be redirected to root
 ✓ Discarding: create multiple nodes nested within each other and then discard them
 - Create a document node
 - Discard that node
 ✓ Discarding: create a document node and then discard it
 - Navigate via the page tree
 - Delete that page
 - Discard page deletion
 ✓ Discarding: delete a document node and then discard deletion
 - Create a content node
 - Discard that node
 ✓ Discarding: create a content node and then discard it
 - Delete this headline
 - Discard page deletion
 ✓ Discarding: delete a content node and then discard deletion

 Image editor
 ✓ Can crop an image

 Inspector
 - Rename Discarding page via inspector
 - Test unapplied changes dialog - resume
 - Test unapplied changes dialog - discard
 - Test unapplied changes dialog - apply
 ✓ Can edit the page title via inspector
 ✓ Check ClientEval for dependencies between properties of NodeTypes in Inspector

 InspectorValidation
 - Remove homepage title
 - Check error badge for one error
 ✓ Remove homepage title to get one error
 - Clean title and uri path segment field
 - Check error badge for two errors
 ✓ Remove Page title and URI segment to get two errors
 - Remove homepage title
 - Check error badge for one error
 - Enter new title Home
 ✓ Remove homepage title to get one error and resolve error by new title

 FIX #3184: Discarded node move changes are reflected correctly in the document tree
 ✓ Scenario #1: Moving nodes and then discarding that change does not lead to an error
 ✓ Scenario #2: Moved nodes do not just disappear after discarding the move change
 ✓ Scenario #3: Discarding a move change while being on a moved node does not lead to an error in the guest frame

 TODO Reimplement / Fix Node Tree Presets for 9.0 https://github.com/neos/neos-ui/issues/3702
 - Node tree preset "default" removes all blog related nodes and only loads nodes with depth <= 2
 - Node tree preset "blog" shows nothing but page [🗋 Blog]
 - In node tree preset "blog", page [🗋 Blog] has no toggle handle
 - Reloading the node tree while in preset "blog" results in nothing but page [🗋 Blog]
 - Node tree preset "blog-articles" shows page [🗋 Blog] and all articles beneath it
 - BUG #3816: Switching back from node tree preset "blog" does not affect loading children in node tree preset "default"
 - BUG #2583: Searching the document tree does not break expansion in node tree preset "default"
 - BUG #2800 1/2: Moving pages before/after in a filtered view does not lead to the disappearance of nodes
 - BUG #2800 2/2: Moving pages into each other in a filtered view does not break expansion

 Refresh Document Tree
 - Refresh the Document Tree and wait
 - Rename home page via inspector
 ✓ Refresh Document tree

 Rich text editor
 ✓ Can crop an image

 Select Boxes
 - SelectBox contents open below the SelectBox.
 ✓ SelectBox opens below and breaks out of the creation dialog if there's enough space below.
 - SelectBox contents open above if the SelectBox is just above the screen bottom.
 - SelectBox contents disappear when SelectBox is scrolled out of sight.
 ✓ SelectBox opens above in creation dialog if there's not enough space below.
 - SelectBox contents open above if the SelectBox is just above the screen bottom.
 - When the inspector tab panel is scrolled just enough, so that there's enough space, SelectBox contents jump below the SelectBox.
 ✓ SelectBox opens above in inspector if there's not enough space below.

 Sidebar toggle
 - LeftSideBar
 - RightSideBar
 ✓ Can toggle sidebars

 Switching dimensions
 - Navigate to some inner page and switch dimension
 - Switch back to original dimension
 ✓ Switching dimensions
 ✓ Grouping of dimensions

 Syncing
 - Create a headline node in the document
 - Type something inside of it
 ✓ Syncing: Create a conflict state between two editors and choose "Discard all" as a resolution strategy during rebase
 - Create a headline node in the document
 - Type something inside of it
 ✓ Syncing: Create a conflict state between two editors and choose "Drop conflicting changes" as a resolution strategy during rebase
 - Create a headline node in the document
 - Type something inside of it
 ✓ Syncing: Create a conflict state between two editors, start and cancel resolution, then restart and choose "Drop conflicting changes" as a resolution strategy
 during rebase
 - Create a headline node in the document
 - Type something inside of it
 ✓ Syncing: Create a conflict state between two editors and choose "Drop conflicting changes" as a resolution strategy, then cancel and choose "Discard all" as a
 resolution strategy during rebase
 - Create a headline node in the document
 - Type something inside of it
 ✓ Publish + Syncing: Create a conflict state between two editors, then try to publish and choose "Drop conflicting changes" as a resolution strategy during automatic
 rebase
 - Create a headline node in the document
 - Type something inside of it
 ✓ Publish + Syncing: Create a conflict state between two editors, then try to publish the document only and choose "Drop conflicting changes" as a resolution
 strategy during automatic rebase

 Tree multiselect
 ✓ Move multiple nodes via toolbar
 ✓ Move multiple nodes via DND, CMD-click
 ✓ Move multiple nodes via DND, SHIFT-click

 Tree search
 - Search the page tree
 - Set the Shortcut filter
 - Clear search
 - Clear filter
 ✓ PageTree search and filter
 - Search is initially hidden and can be opened
 - Close the search input again
 ✓ Pagetree search field can be toggled
 - Search is initially hidden and we open it
 - We reload the page
 - We expect to have a visible search field
 ✓ Pagetree search field state is stored
 - Search is initially hidden and we open it with "t s"
 ✓ Pagetree search field toggles on hotkey


 44 passed (8m 58s)
 9 skipped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants