-
-
Notifications
You must be signed in to change notification settings - Fork 137
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
TASK: Use new translate()
method if possible
#3912
Open
mhsdesign
wants to merge
15
commits into
neos:9.0
Choose a base branch
from
mhsdesign:task/improve-publishing-translations
base: 9.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
TASK: Use new translate()
method if possible
#3912
mhsdesign
wants to merge
15
commits into
neos:9.0
from
mhsdesign:task/improve-publishing-translations
Conversation
This file contains 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
Wow, that’s a lot to take in! I’ll need some time to look into it. Thanks a bunch! |
…stitution in new `translate` function
Using the regex ``` <I18n[ \n]+id="([^"]*)"[ \n]+fallback="([^"]*)"[ \n]*/> ``` and replacing it via ``` {translate('$1', '$2')} ``` To target ``` <I18n id="Neos.Neos:Main:cancel" fallback="Cancel"/> ``` And migrate it to ``` {translate('Neos.Neos:Main:cancel', 'Cancel')} ``` Manual adjustments, to adjust the imports and fix cases where the replaced code would have too many braces like here were fixed according to the linter {someExpression && {translate(...)}}
Using the regex ``` (?<=[ {])(this.props.)?i18nRegistry\.translate\('Neos. ``` and replacing it via ``` translate('Neos. ``` To target all shorthand translations like `Neos.Neos:...` or from Neos.Neos.Ui. Also adjusted the imports and remove the injections of i18nRegistry if now obsolete
…ss the codebase Using the regex ``` (?<=[ {])i18nRegistry\.translate\('([^']+)'\) ``` and replacing it via ``` translate('Neos.Neos:Main:$1') ``` To target all translations like `i18nRegistry.translate('copy')` and replace them via `translate('Neos.Neos:Main:copy')` Also adjusted the imports and remove the injections of i18nRegistry if now obsolete
…ers across the codebase to shorthand strings Using the regex ``` (?<=[ {])(?:this.props.)?i18nRegistry\.translate\('([^']+)'\, '([^']+)'\, \{\}, '([^']+)'\, '([^']+)'\) ``` and replacing it via ``` translate('$3:$4:$1', '$2') ``` To target all translations like `i18nRegistry.translate('contentElementsSelected', 'content elements selected', {}, 'Neos.Neos.Ui', 'Main')` and replace them via `translate('Neos.Neos.Ui:Main:contentElementsSelected', 'content elements selected')` Also adjusted the imports and remove the injections of i18nRegistry if now obsolete
…f possible oddly (multiline) formatted things could not be targeted via regex replace
The todo references this pr which fixed the return value of `i18nRegistry.translate` long ago: neos#2594
…script ... and gracefully handle no fallback when used via javascript as this is not linted
Also appends Neos.Neos:Main if necessary, which was forgotten in: 05fe5f8
mhsdesign
force-pushed
the
task/improve-publishing-translations
branch
from
January 27, 2025 18:35
86e0b9b
to
77e52c2
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Followup to #3804 which deprecates the use of the component and the i18nRegistry, as this is now a global concept via the
translate
method.What I did
Using various careful regex replacements and manual adjustments, commit by commit the
translate()
method was introduced.As written here #3804 (comment) the new method does not handle user input gracefully, which is the reason why non static strings are still using the old translation methods to ensure nothing breaks here.
How I did it
How to verify it
Via the regex
All source files can be checked that each call to
translate()
now specifies the translation as fully qualified shorthand string.Replacing the component with a direct call to
translate()
might not always look correct as this leads to a missing<span />
tag. Those cases have to be identified by eye.