Non-core contributed modules

Addition for better support in language packs

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: 1.9.3
  • Fix Version/s: None
  • Component/s: Block: Mrbs
  • Labels:
    None
  • Environment:
    Moodle4Mac
  • Database:
    MySQL
  • Affected Branches:
    MOODLE_19_STABLE

Description

Hi Anthony,

I found that there is missing a string in the language files so it cant be translated.

Look into the file blocks/mrbs/web/edit_entry.php and go to line 147 .... sorry if it's not the absolute correct number

  1. It is a new booking. The data comes from whichever button the user clicked
    $edit_type = "series";
    $name = getUserName();
    $create_by = getUserName();
    $description = get_string('description','block_mrbs'); // <---------- Ralf Krause 20081202
    $start_day = $day;
    $start_month = $month;
    $start_year = $year;

I changed this code line because I wanted to change the preloaded static string "Class" in the german language file.
You have to add the $string['description'] also in the other language files.

$string['description'] = 'Usage'; // en_utf8
$string['description'] = 'Nutzung'; // de_utf8
$string['description'] = 'Utilisation '; //fr_utf8

Best regards, Ralf

Activity

Hide
Ralf Krause added a comment -

Perhaps the string must have a different name ... you are using the string 'description' from Moodle inside your code.

Show
Ralf Krause added a comment - Perhaps the string must have a different name ... you are using the string 'description' from Moodle inside your code.
Hide
Ralf Krause added a comment -

Hi Anthony,

I found another string to add in the language pack. I saw that I cant translate the part of the duration menu that shows "periods" and "days" to choose. After I added a new string $string['days'] = 'Tage'; into the german translation the booking looks better in this case.

Yes, I found your notice that 'days' are duplicated in the language pack .... but while MRBS does not read this string from Moodle then it would be better to have an own string for MRBS.

Best regards from Germany, Ralf

Show
Ralf Krause added a comment - Hi Anthony, I found another string to add in the language pack. I saw that I cant translate the part of the duration menu that shows "periods" and "days" to choose. After I added a new string $string['days'] = 'Tage'; into the german translation the booking looks better in this case. Yes, I found your notice that 'days' are duplicated in the language pack .... but while MRBS does not read this string from Moodle then it would be better to have an own string for MRBS. Best regards from Germany, Ralf
Hide
Anthony Borrow added a comment -

Ralf - I think if we create a description string in mrbs language files that is fine. I would advocate that it should read description. Then for sites that want it to say something else they can edit the local language file and change it to class. I wonder if we should even do something like Type your description here ... as the text. I am not sure what Usage means in that context, I think that would be confusing. If you could give it some thought and let me know what you think the best string would be then I would be happy to change to it.

As for days - let me know where all you are finding that and I will look at those examples as well. Peace - Anthony

Show
Anthony Borrow added a comment - Ralf - I think if we create a description string in mrbs language files that is fine. I would advocate that it should read description. Then for sites that want it to say something else they can edit the local language file and change it to class. I wonder if we should even do something like Type your description here ... as the text. I am not sure what Usage means in that context, I think that would be confusing. If you could give it some thought and let me know what you think the best string would be then I would be happy to change to it. As for days - let me know where all you are finding that and I will look at those examples as well. Peace - Anthony
Hide
Anthony Borrow added a comment -

One of the places where I might be concerned about using a translated string of days is because I see in the code that it has a case statement with the quoted string hard coded. We would need to use a variable. For example in edit_entry_handler.php see around line 79:
79: if( $dur_units == "days" && $minute == 0 ) . We just need to be careful we do not start translating things that are hard coded like that. Certainly not insurmountable but I do want to be careful not to break things. Peace - Anthony

Show
Anthony Borrow added a comment - One of the places where I might be concerned about using a translated string of days is because I see in the code that it has a case statement with the quoted string hard coded. We would need to use a variable. For example in edit_entry_handler.php see around line 79: 79: if( $dur_units == "days" && $minute == 0 ) . We just need to be careful we do not start translating things that are hard coded like that. Certainly not insurmountable but I do want to be careful not to break things. Peace - Anthony
Hide
Ralf Krause added a comment -

Hi Anthony,

I found the place where the dropdown menu is build.

Yes, it could be a mistake to use the translated words in any php code with an if condition ... but the following code shows how it must work. The if condition must ask for the translated words of "periods", "days" or "minutes", "hours", "days", "weeks". Your example from the last message is an example for a mistake inside the code. If you also ask for $dur_units == get_string('days','block_mrbs') then you will be right ...

When I made the pictures I found out that I should also add $string['minutes']= 'Minuten'; to the language file. The first picture shows the problem, the second one shows it after I added the string and the third one shows the results of booking 40 minutes, 20 minutes and 200 minutes while each block has 30 minutes.

Ralf

My example from mrbs/web/edit_entry.php in line 341 to 351 (the numbers could differ a little bit because I tried some code before)

if( $enable_periods )
$units = array("periods", "days");
else
$units = array("minutes", "hours", "days", "weeks");

while (list(,$unit) = each($units))
{
echo "<OPTION VALUE=$unit";
if ($dur_units == get_string($unit,'block_mrbs')) echo " SELECTED";
echo ">".get_string($unit,'block_mrbs');
}

Show
Ralf Krause added a comment - Hi Anthony, I found the place where the dropdown menu is build. Yes, it could be a mistake to use the translated words in any php code with an if condition ... but the following code shows how it must work. The if condition must ask for the translated words of "periods", "days" or "minutes", "hours", "days", "weeks". Your example from the last message is an example for a mistake inside the code. If you also ask for $dur_units == get_string('days','block_mrbs') then you will be right ... When I made the pictures I found out that I should also add $string['minutes']= 'Minuten'; to the language file. The first picture shows the problem, the second one shows it after I added the string and the third one shows the results of booking 40 minutes, 20 minutes and 200 minutes while each block has 30 minutes. Ralf My example from mrbs/web/edit_entry.php in line 341 to 351 (the numbers could differ a little bit because I tried some code before) if( $enable_periods ) $units = array("periods", "days"); else $units = array("minutes", "hours", "days", "weeks"); while (list(,$unit) = each($units)) { echo "<OPTION VALUE=$unit"; if ($dur_units == get_string($unit,'block_mrbs')) echo " SELECTED"; echo ">".get_string($unit,'block_mrbs'); }
Hide
Ralf Krause added a comment -

1. before I added $string['minutes']= 'Minuten';
2. after I added it
3. the result of booking 40 minutes, 20 minutes, and 200 minutes while each block has 30 minutes

Show
Ralf Krause added a comment - 1. before I added $string['minutes']= 'Minuten'; 2. after I added it 3. the result of booking 40 minutes, 20 minutes, and 200 minutes while each block has 30 minutes
Hide
Anthony Borrow added a comment -

Ralf - I'm trying to wrap up another of other projects before I go to Nepal for 3 weeks. I'm going to put this on my to do list for the MRBS code whenever I get a chance to get back and make some improvements. If you want to provide some patch files that would be great. Essentially I want to search for words like unit, minute, etc. and make sure we are using the get_string function when appropriate (i.e. when it is not expected by the code). Peace - Anthony

Show
Anthony Borrow added a comment - Ralf - I'm trying to wrap up another of other projects before I go to Nepal for 3 weeks. I'm going to put this on my to do list for the MRBS code whenever I get a chance to get back and make some improvements. If you want to provide some patch files that would be great. Essentially I want to search for words like unit, minute, etc. and make sure we are using the get_string function when appropriate (i.e. when it is not expected by the code). Peace - Anthony

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated: