matomo-org / matomo

Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
https://matomo.org/
GNU General Public License v3.0
19.87k stars 2.65k forks source link

Making piwik translation ready #5482

Closed mattab closed 15 years ago

mattab commented 16 years ago

There is still work to make piwik fully translatable.

We have to all strings

zawadzinski commented 16 years ago

Attachment: Merged changes with current (409) revision i18n.patch

zawadzinski commented 16 years ago

Attachment: i18n.patch + some example approach for JS translation (see more in comment) i18n_withJs.patch

zawadzinski commented 16 years ago

Attachment: new version of i18n patch with javascript translation functions i18n_withJs.2.patch

zawadzinski commented 16 years ago

Attachment: current i18n patch (compatible with rev 424) i18n_withJs.3.patch

zawadzinski commented 16 years ago

Attachment: compatible with rev 432 i18n_withJs.4.patch

zawadzinski commented 16 years ago

Attachment: right patch i18n_withJs.5.patch

zawadzinski commented 16 years ago

Attachment: TranslateException, translation strings for exceptions in plugins/ i18n_withJs.6.patch

zawadzinski commented 16 years ago

Attachment: solves also #65 and #116 i18n_feedback_password.patch

zawadzinski commented 16 years ago

Attachment: i18n_feedback_password.2.patch

zawadzinski commented 16 years ago

Attachment: i18n_feedback_password.3.patch

zawadzinski commented 16 years ago

Attachment: i18n_feedback_password.4.patch

zawadzinski commented 16 years ago

Attachment: _pk_translation without default strings, fix in Visitors->Overview view js.patch

anonymous-matomo-user commented 16 years ago

Attachment: german language files de.patch

zawadzinski commented 16 years ago

Attachment: fixes #62, #65, #116 and adds german translations multi.patch

mattab commented 16 years ago

Translate also

mattab commented 16 years ago

(In [390]) - fix #5563

zawadzinski commented 16 years ago

Javascripts translations can be done by renaming [to filename_js.tpl and putting in those smarty templates translations strings (I can include this change in my template translation patch which is nearly done).

Theres are problems with:

zawadzinski commented 16 years ago

Submitted patch introduces translation strings in templates.

Some things to discusss:

zawadzinski commented 16 years ago

Javascript translations.

If you use text strings in your plugin:

1) put in Controller: $view->loadTranslation('General'); $view->loadTranslation('yourPluginName');

2) whenever you use string make it translate-friendly:

_('yourPluginName_stringIdentificator','default string/message')

you can also use some popular translations from 'General' module:

_('General_Back','back')

3) in php translation files define your variable keys as:

'yourPluginName_stringIdentificator_js' => 'string/message translation'

so the translation team will know which strings should be translated

Example of working code is in SitesManager plugin.

mattab commented 16 years ago

quick remarks:

{$nbVisitors} {'General_yesterday'|translate}

Should be

{'General_yesterday'|translate:$nbVisitors}

ie. we give the value to be replaced as an argument of the smarty filter.

NB: When there are more than one value to be sprintf (should be very rare) we should number the %s, ie

$format = 'The %2$s contains %1$d monkeys';

Because in different languages numbers orders can be swapped in the sentence.


        if( !$moduleList )
            return '';

should be


        if( !$moduleList )
        {
            return '';
        }

anyway this is good work in progress :) i hope this review is useful. good luck!

zawadzinski commented 16 years ago

I made several modifications,

{loadJavascriptTranslations modules='SitesManager General'}

ps. I couldn't find any translation that was done without format strings, but maybe I missed sth?

mattab commented 16 years ago
zawadzinski commented 16 years ago

New patch:

PS. somehow you managed to break trac html filter (everything in bold now) ;>

mattab commented 16 years ago

it seems you haven't added the right patch (the patch is still the same).

whats needs to be done in order to have a working i18n version of piwik?

we have to think of the Plugin that we have to write to make it easy to translate piwik, through a simple web interface that would

mattab commented 16 years ago

NB: we have to make sure that all exceptions thrown before the language files are loaded are ONLY thrown in ENGLISH and that the text is hardcoded in the source files.

--> how to make sure all these exceptions are hardcoded?

zawadzinski commented 16 years ago
throw new PiwikException("General_PluginNotFound","Plugin not found");

PS. I attached the right patch :)

mattab commented 16 years ago

''' * agree, please create a new ticket with your specification

zawadzinski commented 16 years ago

Just several quick comments and issues to discuss.

  1. Exceptions.

Message translation cannot be done in Piwik_Exception class, because getMessage() method is not overridable. I will check for translations in Piwik_ExceptionHandler.

  1. Javascript strings duplication.

We certainly need definitions in translation files, so the only way is not to put default string in js code, and by default load english strings.

  1. Column labels.

I haven't understood all of datatables code yet, but we can call _pk_translate() in javascripts on column labels (and somewhere store original labels to keep working sort functions etc.). The same applies to other chart labels, but I need some help with it in order not to waste much time on it :)

zawadzinski commented 16 years ago

TODO:

zawadzinski commented 16 years ago

Some quick remarks on last patch:

zawadzinski commented 16 years ago

Idea for columns translations interface:

in Controller.php add

$view = Piwik_ViewDataTable::factory();
(...)
$view->setColumnsToDisplay( array('label','nb_visits') );
$view->setColumnTranslation('label', 'Referers_ColumnLabel');
$view->setColumnTranslation('label', 'General_ColumnNbVisits');

or maybe even better assigning translated string:

$view->setColumnTranslation('label', Piwik_Translate('General_ColumnNbVisits'));

Then change modules/ViewDataTable so they pass translated strings values to templates (if translation does exist, in other case translated string = column name).

And change templates so instead of column names display translated labels.

I tried to find a place where it can break widgets (e.g. sorting, paging) but didn't find anything... maybe I haven't noticed sth?

zawadzinski commented 16 years ago
zawadzinski commented 16 years ago

CHANGES:

TODO:

zawadzinski commented 16 years ago

Changes:

TODO:

mattab commented 16 years ago

(In [mauser)- refs #5482 commited huge work by Maciej Zawadzi?\197?\132ski: thanks! still some work to do + QA but looks really good :) [mauser]- refs #5536 commited partial fix [mauser]- refs #5485 commited partial fix

mattab commented 16 years ago

feedback on the submitted patch

string = _pk_translate('Home_IncludeAllPopulation');```
would be better than the current

string = _pk_translate('Home_IncludeAllPopulation','Include all population');```

And if the dev doesn't care about translations he would simply use hardcoded strings in his JS files...

anonymous-matomo-user commented 16 years ago

Status of german translation is nearly 80%. (i would note it here, so that nobody else started to translate) :)

zawadzinski commented 16 years ago

small patch

anonymous-matomo-user commented 16 years ago

German languages files for avaiable plugins attached - pls integrate into svn.

mattab commented 16 years ago

(In [mauser) - fixes #5536, font consistent, escape key now works [mauser] - fixes #5485, now catching error, printing friendly message, refactoring template code [mauser] - fixes #5482, fixing JS translations api, Piwik is now ready to be translated!!! :)

mattab commented 16 years ago

We must add the information of the translators in the main translation files.

zawadzinski commented 16 years ago

Support for right-to-left languages:

zawadzinski commented 16 years ago
mattab commented 16 years ago

Please, let's leave this ticket, the first part of the plan has been implemented. We are now working on part 2, see #5671