Skip to content

Commit aa67be7

Browse files
committed
Revise the manner in which the tab "titles" are set, so that the
appropriate strings get into the translation files properly. In the initial release of WW 2.16 the title of the "Import" tab disappeared from the translation files, and it was later noticed that the titles of the second stage tabs were also not available for translation in either WW 2.15 or WW 2.16. See discussion at #1477
1 parent 6bd242f commit aa67be7

File tree

3 files changed

+53
-13
lines changed

3 files changed

+53
-13
lines changed

lib/WeBWorK/ContentGenerator/Instructor/AchievementList.pm

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ use warnings;
5151
#use CGI qw(-nosticky );
5252
use WeBWorK::CGI;
5353
use WeBWorK::Debug;
54-
use WeBWorK::Utils qw(timeToSec readFile listFilesRecursive sortAchievements);
54+
use WeBWorK::Utils qw(timeToSec readFile listFilesRecursive sortAchievements x);
5555
use DateTime;
5656
use Text::CSV;
5757
use Encode;
@@ -65,6 +65,21 @@ use constant EDIT_FORMS => [qw(saveEdit cancelEdit)];
6565
use constant VIEW_FORMS => [qw(edit assign import export score create delete)];
6666
use constant EXPORT_FORMS => [qw(saveExport cancelExport)];
6767

68+
# Prepare the tab titles for translation by maketext
69+
use constant FORM_TITLES => {
70+
saveEdit => x("Save Edit"),
71+
cancelEdit => x("Cancel Edit"),
72+
edit => x("Edit"),
73+
assign => x("Assign"),
74+
import => x("Import"),
75+
export => x("Export"),
76+
score => x("Score"),
77+
create => x("Create"),
78+
delete => x("Delete"),
79+
saveExport => x("Save Export"),
80+
cancelExport => x("Cancel Export")
81+
};
82+
6883
use constant VIEW_FIELD_ORDER => [ qw( enabled achievement_id name number category ) ];
6984
use constant EDIT_FIELD_ORDER => [ qw( icon achievement_id name number assignment_type category enabled points max_counter description icon_file test_file) ];
7085
use constant EXPORT_FIELD_ORDER => [ qw( select achievement_id name) ];
@@ -294,6 +309,7 @@ sub body {
294309
} else {
295310
@formsToShow = @{ VIEW_FORMS() };
296311
}
312+
my %formTitles = %{ FORM_TITLES() };
297313

298314
my @tabArr;
299315
my @contentArr;
@@ -304,7 +320,7 @@ sub body {
304320

305321
push(@tabArr, CGI::li($actionID eq $formsToShow[0] ? { class => "active" } : {},
306322
CGI::a({ href => "#$id", data_toggle => "tab", class => "action-link", data_action => $actionID },
307-
$r->maketext(ucfirst(WeBWorK::split_cap($actionID))))));
323+
$r->maketext($formTitles{$actionID}))));
308324
push(@contentArr, CGI::div({
309325
class => "tab-pane achievement_list_action_div" . ($actionID eq $formsToShow[0] ? " active" : ""),
310326
id => $id

lib/WeBWorK/ContentGenerator/Instructor/ProblemSetList.pm

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,22 @@ use constant EDIT_FORMS => [qw(saveEdit cancelEdit)];
9595
use constant VIEW_FORMS => [qw(filter sort edit publish import export score create delete)];
9696
use constant EXPORT_FORMS => [qw(saveExport cancelExport)];
9797

98-
# capture names for maketext
99-
# (gettext only takes the last one if the use constant is not here)
100-
use constant mk_filter => x('Filter');
101-
use constant mk_sort => x('Sort');
102-
use constant mk_publish => x('Publish');
98+
# Prepare the tab titles for translation by maketext
99+
use constant FORM_TITLES => {
100+
saveEdit => x("Save Edit"),
101+
cancelEdit => x("Cancel Edit"),
102+
filter => x("Filter"),
103+
sort => x("Sort"),
104+
edit => x("Edit"),
105+
publish => x("Publish"),
106+
import => x("Import"),
107+
export => x("Export"),
108+
score => x("Score"),
109+
create => x("Create"),
110+
delete => x("Delete"),
111+
saveExport => x("Save Export"),
112+
cancelExport => x("Cancel Export")
113+
};
103114

104115
use constant VIEW_FIELD_ORDER => [ qw( set_id problems users visible enable_reduced_scoring open_date reduced_scoring_date due_date answer_date) ];
105116
use constant EDIT_FIELD_ORDER => [ qw( set_id visible enable_reduced_scoring open_date reduced_scoring_date due_date answer_date) ];
@@ -575,6 +586,7 @@ sub body {
575586
} else {
576587
@formsToShow = @{ VIEW_FORMS() };
577588
}
589+
my %formTitles = %{ FORM_TITLES() };
578590

579591
my @tabArr;
580592
my @contentArr;
@@ -592,7 +604,7 @@ sub body {
592604

593605
push(@tabArr, CGI::li({ class => $active },
594606
CGI::a({ href => "#$id", data_toggle => "tab", class => "action-link", data_action => $actionID },
595-
$r->maketext(ucfirst(WeBWorK::split_cap($actionID))))));
607+
$r->maketext($formTitles{$actionID}))));
596608
push(@contentArr, CGI::div({ class => "tab-pane $active", id => $id },
597609
$self->$actionForm($self->getActionParams($actionID))));
598610
}

lib/WeBWorK/ContentGenerator/Instructor/UserList.pm

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,21 @@ use constant EDIT_FORMS => [qw(saveEdit cancelEdit)];
7777
use constant PASSWORD_FORMS => [qw(savePassword cancelPassword)];
7878
use constant VIEW_FORMS => [qw(filter sort edit password import export add delete)];
7979

80-
# capture names for maketext
81-
# (gettext only takes the last one if the use constant is not here)
82-
use constant mk_filter => x('Filter');
83-
use constant mk_sort => x('Sort');
80+
# Prepare the tab titles for translation by maketext
81+
use constant FORM_TITLES => {
82+
saveEdit => x("Save Edit"),
83+
cancelEdit => x("Cancel Edit"),
84+
filter => x("Filter"),
85+
sort => x("Sort"),
86+
edit => x("Edit"),
87+
password => x("Password"),
88+
import => x("Import"),
89+
export => x("Export"),
90+
add => x("Add"),
91+
delete => x("Delete"),
92+
savePassword => x("Save Password"),
93+
cancelPassword => x("Cancel Password")
94+
};
8495

8596
# permissions needed to perform a given action
8697
use constant FORM_PERMS => {
@@ -519,6 +530,7 @@ sub body {
519530
} else {
520531
@formsToShow = @{ VIEW_FORMS() };
521532
}
533+
my %formTitles = %{ FORM_TITLES() };
522534

523535
my @tabArr;
524536
my @contentArr;
@@ -536,7 +548,7 @@ sub body {
536548

537549
push(@tabArr, CGI::li({ class => $active },
538550
CGI::a({ href => "#$id", data_toggle => "tab", class => "action-link", data_action => $actionID },
539-
$r->maketext(ucfirst(WeBWorK::split_cap($actionID))))));
551+
$r->maketext($formTitles{$actionID}))));
540552
push(@contentArr, CGI::div({ class => "tab-pane $active", id => $id },
541553
$self->$actionForm($self->getActionParams($actionID))));
542554
}

0 commit comments

Comments
 (0)