-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Refactoring translation handling into a Translation component #6909
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
Merged
Conversation
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
OK to review and merge (once tests are finished and green) When merged, TODO:
|
OK I need to rebase again… Also this PR is for 2.11 so maybe don't merge yet? |
Translations are now lazily loaded instead of being explicitely loaded by other components (e.g. the front controller, the plugin manager, etc...). Now other parties only configure "directories" where the translator can find translations. That makes the translator decoupled from the rest of Piwik.
…ager plugin These classes are only used in that plugin, so it doesn't make sense to keep then in Core.
It looks excellent, a nice clean code change for the new year 👍 |
mattab
pushed a commit
that referenced
this pull request
Jan 5, 2015
Refactoring translation handling into a Translation component
\o/ Cool you also updated everything else thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
answered
For when a question was asked and we referred to forum or answered it.
c: i18n
For issues around internationalisation and localisation.
c: Platform
For Matomo platform changes that aren't impacting any of our APIs but improve the core itself.
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.
Translations were stored in a
$GLOBALS
array and handled by a static classPiwik\Translate
. Furthermore, handling of translations were spread all over the place, caching logic was mixed with translation logic, …This refactoring contains:
Piwik\Translate
is kept for BC and forwards call to the newTranslator
classLoaderInterface
with the following implementations:JsonFileLoader
LoaderCache
: caches another loader by wrapping it (which would be theJsonFileLoader
)dev
environment (which addresses this TODO)dev
environment (= new DI config file) where translation cache is disabled: this environment can be used for other things as wellfr_CA
(canadian french) would fallback tofr
which would fallback toen
(not implemented)Piwik\Translate\Writer
and its subclasses to the LanguagesManager plugin because these classes were only used in that pluginAnd I was able to unit tests the new classes, which is just an awesome feeling :)
There's still a lot of room for improvement, I'll keep working on that PR. Feedback welcome!