-
Notifications
You must be signed in to change notification settings - Fork 152
Translations in di.xml #223
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
Open
buskamuza
wants to merge
1
commit into
magento:master
Choose a base branch
from
magento-architects:translations
base: master
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
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Translations in `di.xml` | ||
|
||
## Current Situation | ||
|
||
Currently all XML files that support types, allow `translate` attribute for `string` type. This attribute leads to: | ||
|
||
1. The specified string to be translated when XML file is read, so the client of the string receives a translated string automatically. | ||
2. A translation tool recognizes such strings as translatable and collect them in a translation file. | ||
|
||
`di.xml`, instead, supports `translatable` attribute which: | ||
|
||
1. Allows the translation tool to recognize the string as translatable and collect it. | ||
2. Does NOT lead to automatic translation of the string for the client code. It is expected that the client code will translate the string. | ||
|
||
The decision was based on the requirement that it us not DI responsibility to translate phrases, which makes sense. | ||
|
||
## Problem Statement | ||
|
||
Such behavior has two problems in my opinion: | ||
|
||
1. It is confusing. `translate` sounds very similar to `translatable`, while the behavior is different. Without deep knowledge of the feature, it's impossible to expect such behavior. | ||
2. Somebody can make a mistake (because attribute names sound very similar). Though the translation tool can recognize both attributes, so it will not cause any issue. | ||
|
||
## Solution | ||
|
||
Unify translation behaviors: | ||
|
||
1. Allow `translate` attribute in `di.xml`. | ||
2. `translate` attribute leads to the string being automatically translated during XML parsing and passed to the client code as translated phrase. | ||
2.1. If it is impossible to translate the phrase (e.g., the application is running in `global` area), the phrase is provided untranslated. | ||
3. Remove `translatable` attribute. Temporarily, support it as deprecated with existing behavior. | ||
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.
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.
This would remove the ability to defer the translation. Is this an acceptable feature loss?