Closed mattab closed 15 years ago
Attachment: Merged changes with current (409) revision i18n.patch
Attachment: i18n.patch + some example approach for JS translation (see more in comment) i18n_withJs.patch
Attachment: new version of i18n patch with javascript translation functions i18n_withJs.2.patch
Attachment: current i18n patch (compatible with rev 424) i18n_withJs.3.patch
Attachment: compatible with rev 432 i18n_withJs.4.patch
Attachment: right patch i18n_withJs.5.patch
Attachment: TranslateException, translation strings for exceptions in plugins/ i18n_withJs.6.patch
Attachment: solves also #65 and #116 i18n_feedback_password.patch
Attachment: i18n_feedback_password.2.patch
Attachment: i18n_feedback_password.3.patch
Attachment: i18n_feedback_password.4.patch
Attachment: _pk_translation without default strings, fix in Visitors->Overview view js.patch
Attachment: german language files de.patch
Attachment: fixes #62, #65, #116 and adds german translations multi.patch
Translate also
(In [390]) - fix #5563
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:
Submitted patch introduces translation strings in templates.
Some things to discusss:
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.
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!
I made several modifications,
{loadJavascriptTranslations modules='SitesManager General'}
_()
function was renamed to _pk_translate()
, if there are more general functions I think it will be good to make a javascript namespace with all of them, i.e. i think we need sprintf function for some of javascript translations... and there will be certainly more of themsvn add
. There is quite a lot of small files to translate now, and I think it can be good to put all 'standard' plugins' translation strings into one file to make translators' work easier...ps. I couldn't find any translation that was done without format strings, but maybe I missed sth?
+{literal}Last modification time, description and reporter are included as hidden fields for useful RSS export.
why this add?
good job so far. we have to think also about how to make it easy for other people to translate piwik, we need a script that reads all the strings in all plugins, requests user translations in a nice HTML form, saves files in the given plugins. What do you think about it? We can have a look at how Facebook translations work.
PS: sorry for the delay now I should be able to review future code much faster :)
New patch:
PS. somehow you managed to break trac html filter (everything in bold now) ;>
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
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?
throw new PiwikException("General_PluginNotFound","Plugin not found");
functions_exists("Piwik_Translate")
PS. I attached the right patch :)
''' * agree, please create a new ticket with your specification
Piwik::loadPlugins()
(line 305 in /trunk/modules/FrontController.php) can be translated, but the few exceptions before this line cannot. I would suggest to go for Exception('Message in english') and Exception('IndexTranslation') : both of them would work. ie, if the dev doesnt care about translations, it's ok it stays the same simple syntax. If he cares, then he puts in an index and he has to add the entry in the english language file. The class name would be Piwik_Exception
Just several quick comments and issues to discuss.
Message translation cannot be done in Piwik_Exception class, because getMessage() method is not overridable. I will check for translations in Piwik_ExceptionHandler.
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.
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 :)
TODO:
Some quick remarks on last patch:
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?
CHANGES:
TODO:
Changes:
TODO:
(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
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...
Status of german translation is nearly 80%. (i would note it here, so that nobody else started to translate) :)
small patch
German languages files for avaiable plugins attached - pls integrate into svn.
(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!!! :)
We must add the information of the translators in the main translation files.
Support for right-to-left languages:
Please, let's leave this ticket, the first part of the plan has been implemented. We are now working on part 2, see #5671
There is still work to make piwik fully translatable.
We have to all strings