Suitecrm: Resource Calendar - Days and month are not translated

Created on 17 May 2017  路  6Comments  路  Source: salesagility/SuiteCRM

Issue


Days of week and months cannot be translated on the Resources Calendar

Expected Behavior


Days and month should be translated

Steps to Reproduce


  1. Install a language pack
  2. Login with that language
  3. Enter Menu ALL / Resources Calendar
  4. See days and month not translated

2017-05-17 12_15_04-projetos suitecrm

or a pic from another user and language
0921055e-2c03-11e7-9a86-17e603116628

Same goes for the resource calendar when you view a project in Gantt mode view (enter a Project / Actions tab/ View Gantt mode)
2017-05-24 12_06_48-suitecrm_gantt

Context



Also posted by @maladrill in a different but non related issue

Your Environment

  • SuiteCRM Version used:
  • Browser name and version (e.g. Chrome Version 51.0.2704.63 (64-bit)): 7.8.x and 7.9.0 RC
  • Environment name and version (e.g. MySQL, PHP 7):
  • Operating System and version (e.g Ubuntu 16.04):
Moderate Fix Proposed Bug

Most helpful comment

Reason for project not displaying native/selected language is simple. There is no implementation of native/selected language in file chart.php. chart.php file generate resource calendar. Hotfix is to change chart.php at lines:

PS: Changes are tested on polish and english versions. So do a copy of your old file before you continue.

278
orginal: echo '<td class="inner_td"><div class="cell_width">'.$d[0].'</div></td>';//First letter of the days name shown
modificated: echo '<td class="inner_td"><div class="cell_width">'.$d.'</div></td>';//First letter of the days name shown

  • In polish this change is needed to properly display polish letters for english is optional and do not change anything if change occur.

547
orginal:
$aResult[$dt->format('Y')][ceil($dt->format('m')/3)][$count] = $dt->format('M');
modificated:
$aResult[$dt->format('Y')] [ceil($dt->format('m')/3)] [$count] = mb_substr($GLOBALS['app_list_strings']['dom_cal_month_long'][$dt->format('n')],0, 3);

571
orginal:
$aResult[$dt->format('Y')][$dt->format('M')][] = $dt->format('W');
modificated:
$aResult[$dt->format('Y')] [$GLOBALS['app_list_strings']['dom_cal_month_long'][$dt->format('n')]] [] = $dt->format('W');

593:
orginal:
$aResult[$dt->format('Y')][$dt->format('M')][$dt->format('j')] = $dt->format('D');
modificated:
$aResult[$dt->format('Y')] [mb_substr($GLOBALS['app_list_strings']['dom_cal_month_long'][$dt->format('n')],0, 3)] [$dt->format('j')] = mb_substr($GLOBALS['app_list_strings']['dom_cal_day_long'][$dt->format('N')],0, 1);

All 6 comments

Reason for project not displaying native/selected language is simple. There is no implementation of native/selected language in file chart.php. chart.php file generate resource calendar. Hotfix is to change chart.php at lines:

PS: Changes are tested on polish and english versions. So do a copy of your old file before you continue.

278
orginal: echo '<td class="inner_td"><div class="cell_width">'.$d[0].'</div></td>';//First letter of the days name shown
modificated: echo '<td class="inner_td"><div class="cell_width">'.$d.'</div></td>';//First letter of the days name shown

  • In polish this change is needed to properly display polish letters for english is optional and do not change anything if change occur.

547
orginal:
$aResult[$dt->format('Y')][ceil($dt->format('m')/3)][$count] = $dt->format('M');
modificated:
$aResult[$dt->format('Y')] [ceil($dt->format('m')/3)] [$count] = mb_substr($GLOBALS['app_list_strings']['dom_cal_month_long'][$dt->format('n')],0, 3);

571
orginal:
$aResult[$dt->format('Y')][$dt->format('M')][] = $dt->format('W');
modificated:
$aResult[$dt->format('Y')] [$GLOBALS['app_list_strings']['dom_cal_month_long'][$dt->format('n')]] [] = $dt->format('W');

593:
orginal:
$aResult[$dt->format('Y')][$dt->format('M')][$dt->format('j')] = $dt->format('D');
modificated:
$aResult[$dt->format('Y')] [mb_substr($GLOBALS['app_list_strings']['dom_cal_month_long'][$dt->format('n')],0, 3)] [$dt->format('j')] = mb_substr($GLOBALS['app_list_strings']['dom_cal_day_long'][$dt->format('N')],0, 1);

@darkassazi can you create a PR with your changes against the SuiteCRM Hotfix branch?

@darkassazi I tested your changes to file \modules\Project\chart.php :

  • it works to get days and month translated when you view the Resources calendar module
    2017-05-24 12_10_07-suitecrm
  • Note: Instead of dom_cal_day_long you could also use dom_cal_day_short (some languages has lower-case for day long but initial capital letter for day short )

But...

  • It does not solves the translation of resource calendar when you enter a project and change to Gantt mode view (enter a Project / Actions tab/ View Gantt mode)
    2017-05-24 12_06_48-suitecrm_gantt

This requires some coding skills that I haven't, so requesting an hand to:
@pgorod @pribeiro42 @likhobory @urdhvatech @Mausino

To @samus-aran a note for you
\modules\ResourceCalendar\language\en_us.lang.php has no strings to be translated, is just an empty array.

Note to self: First letter for day in calendar is from dom_cal_day_long array that gets its values from \include\language\en_us.lang.php

Sorry i don't answer on your post, but I was busy with other projects.
About the gantt I have no idea this chart existed to begin with.
Thanks for pointing it out.

About your sugestion. I use long because regardles of using short or long, there is need to use substring to be sure that lenght of day and month is 1 nad 3 letters respectively. And also i have on Idea that there are langueges that use uppercase for short but lowercase for long.

I post chart.php, and gantt.php, both have implemented language pack. I

also i change all used languege strings from long to short as sugested by @horus68

Also, I need to confes. I make a mistake at line 547. I use format('N'), that use ISO-8601 representation of days, but i should use format('w') that represent days from sunday(0) to saturday(6) and + to get proper day. In other words monday was saturday

In these 2 files i correct my mistake. I try to find some time to set Suite with my changes.

chart.php.txt
gantt.php.txt

@darkassazi it's very use to use Github to make these changes in a way that can later be imported into the main project.

All you have to do is:

  1. Fork the SuiteCRM project into your own Github area
  2. In your fork, start a new branch under the hotfix branch
  3. Edit the files directly on Github
  4. When everything is ready, submit a Pull Request into the main SuiteCRM repository

There are plenty of easy tutorials online explaining each of those steps.

And thanks for your contributions, we're looking forward to more from you!

@darkassazi both calendars are now translated! 馃
Hope you can submit your changes into a PR to github code so they can get approved

Was this page helpful?
0 / 5 - 0 ratings