Skip to content

Commit

Permalink
Issue 7: Support for String Translation in the System
Browse files Browse the repository at this point in the history
  • Loading branch information
sumaiyamannan committed Jan 30, 2025
1 parent 95b0973 commit 450d9cb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
23 changes: 16 additions & 7 deletions classes/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,15 @@ public static function save_sms_school_details($data, $action = null, $groups =
$data->organisation_school_type = school::STANDARD;
if ($cohortid == 0) {
// Create new school and cohort.
$result->message[] = "Create a new school: {$schoolname} ";
$result->message[] = get_string('notifyschoolcreate', 'tool_smsimport', $schoolname);
if ($action == 'edit') {
if ($localorg) {
$cohortid = local_organisations_create_organisation($data, 'tool_smsimport');
} else {
$cohortid = cohort_add_cohort($data);
}
$data->cohortid = $cohortid;
$result->message[] = "Created school with cohort ".$cohortid;
$result->message[] = get_string('notifyschoolcreated', 'tool_smsimport', $cohortid);
}
} else {
$schoolname = $DB->get_field('cohort', 'name', ['id' => $cohortid]);
Expand All @@ -231,7 +231,7 @@ public static function save_sms_school_details($data, $action = null, $groups =
// Unlink a school.
if (isset($data->unlink) && $data->unlink) {
$logaction = get_string('logdelete', 'tool_smsimport');
$result->message[] = "Unlink school from organisation {$schoolname}";
$result->message[] = get_string('notifyschoolunlink', 'tool_smsimport', $cohortid);
}

if ($action == 'edit') {
Expand Down Expand Up @@ -264,8 +264,12 @@ public static function save_sms_school_details($data, $action = null, $groups =
foreach ($deletegroups as $deletegroup) {
$deletegroupdata = groups_get_group_by_idnumber($courseid, $deletegroup);
$dgroupnamedisplay = str_replace($schoolname, '', $deletegroupdata->name);
$result->message[] = "Unlink SMS school {$schoolname} from group:
{$dgroupnamedisplay} ({$deletegroup})";
$a = [
'schoolname' => $schoolname,
'dgroupnamedisplay' => $dgroupnamedisplay,
'deletegroup' => $deletegroup,
];
$result->message[] = get_string('notifysmsschoolunlink', 'tool_smsimport', $a);
if ($action == 'edit') {
self::delete_sms_school_groups($data->id, $deletegroupdata->id);
$info['groupremove'] = $deletegroup;
Expand Down Expand Up @@ -324,8 +328,13 @@ public static function save_sms_school_details($data, $action = null, $groups =
if (empty($data->unlink) && empty($deletegroups)) {
$schoolname = $DB->get_field('cohort', 'name', ['id' => $cohortid]);
$groupname = $schoolname."".$groupname;
$a = [
'schoolname' => $schoolname,
'groupnamedisplay' => $groupnamedisplay,
'gidnumber' => $gidnumber,
];
if ($logaction == get_string('logcreate', 'tool_smsimport') ) {
$result->message[] = "Link SMS school {$schoolname} to new group: {$groupnamedisplay} ({$gidnumber})";
$result->message[] = get_string('notifysmsschoollinkgroupnew', 'tool_smsimport', $a);
$newgroupdata = new stdClass();
$newgroupdata->courseid = $courseid;
$newgroupdata->name = $groupname;
Expand All @@ -336,7 +345,7 @@ public static function save_sms_school_details($data, $action = null, $groups =
}
}
if ($logaction == get_string('logupdate', 'tool_smsimport')) {
$result->message[] = "Link SMS school {$schoolname} to group: {$groupnamedisplay} ({$gidnumber})";
$result->message[] = get_string('notifysmsschoollinkgroup', 'tool_smsimport', $a);
$groupdata->idnumber = $gidnumber;
$groupdata->name = $groupname;
if ($action == 'edit') {
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
echo '<a href="' . $urladd . '" class="btn btn-secondary">' . get_string('addschool', 'tool_smsimport') . '</a>';

echo html_writer::start_tag('p');
echo "Or you can ";
echo get_string('oryoucan', 'tool_smsimport');
echo html_writer::link(new moodle_url('upload.php') , get_string('uploadusers', 'tool_smsimport'));
echo html_writer::end_tag('p');

Expand Down
7 changes: 7 additions & 0 deletions lang/en/tool_smsimport.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,10 @@
$string['privacy:metadata:ip'] = 'The IP address if the origin is web';
$string['privacy:metadata:tool_sms_school_log'] = 'SMS import log record';
$string['invaliddobformat'] = 'Invalid date of birth format used. Please use YYYY-MM-DD.';
$string['notifyschoolcreate'] = 'Create a new school: {$a}';
$string['notifyschoolcreated'] = 'Created school with cohort {$a}';
$string['notifyschoolunlink'] = 'Unlink school from organisation {$a}';
$string['notifysmsschoolunlink'] = 'Unlink SMS school {$a->schoolname} from group: {$a->dgroupnamedisplay} {$a->deletegroup}';
$string['notifysmsschoollinkgroup'] = 'Link SMS school {$a->schoolname} to group: {$a->groupnamedisplay} {$a->gidnumber}';
$string['notifysmsschoollinkgroupnew'] = 'Link SMS school {$a->schoolname} to new group: {$a->groupnamedisplay} {$a->gidnumber}';
$string['oryoucan'] = 'Or you can';

0 comments on commit 450d9cb

Please sign in to comment.