@tsteur opened this Issue on July 21st 2014 Member

I think as part of our "move code from core to plugins" we should also move the translations from core to the plugins. For instance all translations from group "Actions" into "Actions" plugin.

A minor disadvantage of this solution could be performance since it would have to load a few more language files. Not sure how much slower it would make it, don't think too much as it checks for each plugin whether a language file exists anyway. We could otherwise still cache all translations in a cache file and make it even faster than it is currently.

Another disadvantage I see is it makes it more complicated to search for existing translations. Here one could still use the LanguagesManager API or if we cache all existing translations in a cache file anyway one could still search there. On the other side it is already right now hard for plugin developers to find existing translations and keys. Maybe we could have a little page in the Admin or somewhere if development mode is enabled which allows a developer to search for translations and keys. Should be easy to implement.
BTW: if plugin developers are supposed to reuse existing translations and we rename/remove keys than this is breaking the API a well and should be mentioned in a changelog (we could link from there to a separate page showing all the detailed translation changes).

cc @sgiehl

@sgiehl commented on July 21st 2014 Member

Sounds good. Moving the translations to the according plugins shouldn't be hard. The script for automatic updates is already able to handle that.

Are you going to move them? Or shall I put it on my todo list?

@tsteur commented on July 21st 2014 Member

I will have a look later

@sgiehl commented on July 21st 2014 Member

Should be enough to move the english translations to the plugins and run a translations:update.

@tsteur commented on July 21st 2014 Member

FYI: Instead of 10ms it takes 30ms on my local VM now (APC enabled). Time is primarily spent in file_get_contents

@tsteur commented on July 21st 2014 Member

I reverted moving the translations into the core again as of course only translations of activated plugins are available. The tests fail when for instance Actions is not activated. Same would of course happen in the UI.

@sgiehl commented on July 21st 2014 Member

Hm. Thats right. Imho we have two options. Always load translations from all plugins (including deactivated) or move all translations from core plugins to main language files.

@tsteur commented on July 22nd 2014 Member

@mattab what do you think regarding splitting the translations into plugins and the problem with not activated core plugins resulting in not existing translations. Of course we could always load the translations of all core plugins but not sure about this. Maybe there is another solution?

@mattab commented on August 3rd 2014 Member

@tsteur @sgiehl

+1 for moving the translations into files in each plugin, as this brings better reliability and showcases how to use the platform.

loading core plugin translations all the time sounds like a fine solution to the "not available translations issue".

Performance: users will really need a APC opcache to cache all these file hits... Maybe we could add new System check setting warning user in case he does not use APC or other supported opcache?

@sgiehl commented on August 3rd 2014 Member

I would add an caching layer for the translations. Each language would have
it's own combined file in the tmp directory as soon the language is used
the first time.
For sure all translation cache files need to be cleared upon updating piwik
or adding, removing or updating a plugin.
That would minimize the stat calls...

@tsteur commented on August 24th 2014 Member

@sgiehl can you have a look at the Plugins/LanguagesManagerTest and Translate/WriterTest. I think they are the only ones that fail see https://travis-ci.org/piwik/piwik/builds/33435368 but I do not really know how to best adjust code/tests to make them green again. Code is in branch 5863_languageFilesInPlugin.

@sgiehl commented on August 24th 2014 Member

Sure. I'll have a look

@sgiehl commented on August 24th 2014 Member

OK. Should work now. Last branch build was green

@tsteur commented on August 25th 2014 Member

Thx! FYI: I was only looking at an Admin page but the time spent in loadPluginTranslations() reduced from 200ms on average to 5-20ms. Both APC enabled

@tsteur commented on August 25th 2014 Member

FYI: created #6060

This Issue was closed on August 25th 2014
Powered by GitHub Issue Mirror