[ZBX-5458] Some date strings are not being translated. Created: 2012 Aug 16 Updated: 2017 May 30 Resolved: 2013 Jan 22 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | Frontend (F) |
Affects Version/s: | 2.0.1 |
Fix Version/s: | 2.0.5rc1, 2.1.0 |
Type: | Incident report | Priority: | Trivial |
Reporter: | Mikhail Dobrinin | Assignee: | Unassigned |
Resolution: | Fixed | Votes: | 0 |
Labels: | datestring | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified | ||
Environment: |
PHP 5.4.5, Ubuntu 12.04, Zabbix 2.0.1 |
Attachments: |
![]() ![]() ![]() ![]() ![]() ![]() |
||||||||
Issue Links: |
|
Description |
I am using Virtaal to create en_US translatation, and after going through the .po file, there are certain date strings that are still not being translated in the front end. Specifically: 15.08.2012 08:15 - (now!) the date range under Monitoring - Graphs - Filter - Zoom box date ranges in top right corner: I am planning on uploading the file to pootle as soon as I get proper permissions. |
Comments |
Comment by Oleksii Zagorskyi [ 2012 Aug 16 ] |
Not reproducible on screenshots: I.e. there dated is translatable, you could temporary switch to RU locale to check difference with ENG locale. |
Comment by Mikhail Dobrinin [ 2012 Aug 16 ] |
'Aug' is being translated to 'Авг', but the order is remaining the same. That is, it's still Y.M.d H:i:s, even though my po file "translates" it to m/d/Y h:i:s A on dates-not-working-3.png |
Comment by Oleksii Zagorskyi [ 2012 Aug 18 ] |
Note that if you can see a date translated to RU language (because it translated to almost 100%) then it means this date can be "translated" to en_US locale. |
Comment by Ryan Rupp [ 2012 Aug 20 ] |
Tested the following things on Zabbix 2.0 virtual appliance - note this is before the changes to the history screen done by It appears the issue with the timestamp under Monitoring-
$table->addRow(array(
zbx_date2str(HISTORY_ITEM_DATE_FORMAT, $data['clock']),
zbx_nl2br($value)
));
So the date format references a constant defined in defines.inc.php: define('HISTORY_ITEM_DATE_FORMAT', _('Y.M.d H:i:s')); Now the Russian PO file has this: #: include/defines.inc.php:878 include/defines.inc.php:879 #: include/defines.inc.php:882 msgid "Y.M.d H:i:s" msgstr "d.M.Y H:i:s" So the format is changed to have the day of the month first rather than the year in the Russian translation. However, for the Russian translation only the month abbreviation is translated, not the actual format. See attached image - LatestValuesTranslationNotWorking.png Then I tried instead of using a define doing this translation in line in the history.php file so instead of referencing HISTORY_ITEM_DATE_FORMAT in history.php now I have: $table->addRow(array( zbx_date2str(_('Y.M.d H:i:s'), $data['clock']), zbx_nl2br($value) )); then updated the .po file to reference the correct line in history.php and rebuilt the .mo files and this worked correctly. So I think there may be possibly something going on with using a define statement with text that is translated, those dates are the only defines I see that have translated text in them. Possibly the issue is that the defines are actually loaded/set before the translations are, if you look at config.inc.php it requires the define.inc.php which means the defines would be set a that point but inside that config.inc.php source is where the gettext translations are initialized. So the order of initialization in that case is: 1. Set defines <--- translations are not initialized at this point so _('Y.M.d H:i:s') resolves to the default 'Y.M.d H:i:s' That's just my guess as to why that occurs. This looks to also be true for the events timestamp as well as it looks like it's using the define EVENTS_ACTION_TIME_FORMAT which is not getting formatted based on the translation. |
Comment by Ryan Rupp [ 2012 Aug 20 ] |
As for the graph navigation bar not having the date translated it appears this is because the format is hardcoded in a javascript source file, see gtlc.js - // info left var date = datetoarray(userstarttime); this.dom.info_left.innerHTML = date[0] + '.' + date[1] + '.' + date[2] + ' ' + date[3] + ':' + date[4]; // info right var date = datetoarray(usertime); var right_info = date[0] + '.' + date[1] + '.' + date[2] + ' ' + date[3] + ':' + date[4]; if (this.timeline.now()) { right_info += ' (' + locale['S_NOW_SMALL'] + '!) '; } this.dom.info_right.innerHTML = right_info; And datetoarray has a pre-determined format: function datetoarray(unixtime) { var date = new CDate(unixtime * 1000); var dateArray = []; dateArray[0] = date.getDate(); dateArray[1] = date.getMonth() + 1; dateArray[2] = date.getFullYear(); dateArray[3] = date.getHours(); dateArray[4] = date.getMinutes(); dateArray[5] = date.getSeconds(); for (var i = 0; i < dateArray.length; i++) { if ((dateArray[i] + '').length < 2) { dateArray[i] = '0' + dateArray[i]; } } return dateArray; } So the format is always d.m.y h.m Sorry, not sure why the code macro doesn't work |
Comment by Mikhail Dobrinin [ 2012 Aug 20 ] |
One solution would be to hardcode the date format instead of using DEFINE constants. This is already the case for about half of the dates in the source, so it would improve consistency |
Comment by Alexander Vladishev [ 2012 Aug 22 ] |
Related issue: |
Comment by Toms (Inactive) [ 2013 Jan 14 ] |
Fixed in svn://svn.zabbix.com/branches/dev/ZBX-5458 |
Comment by richlv [ 2013 Jan 15 ] |
(1) 32734 comment said "introduced new 3rd party JavaScript library". this has to be documented tomtom CLOSED. after discussions, we decided to get rid of this library. |
Comment by Oleg Egorov (Inactive) [ 2013 Jan 16 ] |
dateFormater.js TESTED |
Comment by Toms (Inactive) [ 2013 Jan 17 ] |
Fixed in 2.0.5rc1 r32833, 2.1.0 r32837 |
Comment by Toms (Inactive) [ 2013 Jan 17 ] |
(2) REOPENED. 3rd party library should be removed. tomtom RESOLVED in r32920 tomtom CLOSED |
Comment by Oleg Egorov (Inactive) [ 2013 Jan 21 ] |
(3) In function documentation (clas.cdate.js:54-60) redundant spaces should be removed And in rows: 73, 77, 80, 83 should be added spaces (For example, "val<10" -> "val < 10") tomtom RESOLVED in r33021 oleg.egorov CLOSED |
Comment by Oleg Egorov (Inactive) [ 2013 Jan 21 ] |
(4) In class.cdate.js should be added Polish date format: 'd M Y H:m' CLOSED (Polish translation mistake) |
Comment by Oleg Egorov (Inactive) [ 2013 Jan 21 ] |
(5) Please rename functions names, as we discussed. tomtom RESOLVED in r33021 oleg.egorov CLOSED |
Comment by Oleg Egorov (Inactive) [ 2013 Jan 22 ] |
TESTED. But, please remove break in class.cdate.js:112 before merge tomtom done |
Comment by Toms (Inactive) [ 2013 Jan 23 ] |
Fixed in 2.0.5rc1 r33047, 2.1.0 r33048 |
Comment by richlv [ 2013 Jan 23 ] |
some trailing newlines were missing after this |
Comment by richlv [ 2013 Mar 05 ] |
this resulted in a regression : |
Comment by MATSUDA Daiki [ 2013 Jun 13 ] |
See |
Comment by MATSUDA Daiki [ 2013 Jun 17 ] |