Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs/make_translation_files.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

- Go to the location under which the renderer was installed.
- You need to have `xgettext.pl` installed.

```
cd container/lib
xgettext.pl -o WeBWorK/lib/WeBWorK/Localize/standalone.pot -D PG/lib -D PG/macros -D RenderApp -D WeBWorK/lib RenderApp.pm
```

- That creates the POT file of all strings found

```
cd WeBWorK/lib/WeBWorK/Localize
find . -name '*.po' -exec bash -c "echo \"Updating {}\"; msgmerge -qUN {} standalone.pot" \;
```

14 changes: 10 additions & 4 deletions lib/RenderApp/Controller/FormatRenderedProblem.pm
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use MIME::Base64 qw( encode_base64 decode_base64);
use WeBWorK::Utils::AttemptsTable; #import from ww2
use WeBWorK::PG::ImageGenerator; # import from ww2
use WeBWorK::Utils qw( wwRound); # required for score summary
use WeBWorK::Localize ; # for maketext
our $UNIT_TESTS_ON = 0;

#####################
Expand Down Expand Up @@ -181,6 +182,8 @@ sub formatRenderedProblem {
my $formLanguage = $self->{inputs_ref}{language} // 'en';
my $scoreSummary = '';

my $mt = WeBWorK::Localize::getLangHandle($self->{inputs_ref}{language} // 'en');

my $tbl = WeBWorK::Utils::AttemptsTable->new(
$rh_answers,
answersSubmitted => $self->{inputs_ref}{answersSubmitted}//0,
Expand Down Expand Up @@ -209,7 +212,10 @@ sub formatRenderedProblem {
# render equation images

if ($submitMode && $problemResult && $showSummary) {
$scoreSummary = CGI::p('Your score on this attempt is '.wwRound(0, $problemResult->{score} * 100).'%');
$scoreSummary = CGI::p($mt->maketext('Your score on this attempt is [_1]', wwRound(0, $problemResult->{score} * 100).'%'));

#$scoreSummary .= CGI::p($mt->maketext("Your score was not recorded."));

#scoreSummary .= CGI::p('Your score on this problem has not been recorded.');
#$scoreSummary .= CGI::hidden({id=>'problem-result-score', name=>'problem-result-score',value=>$problemResult->{score}});
}
Expand Down Expand Up @@ -267,9 +273,9 @@ sub formatRenderedProblem {
}
}

my $STRING_Preview = "Preview My Answers";
my $STRING_ShowCorrect = "Show correct answers";
my $STRING_Submit = "Submit Answers";
my $STRING_Preview = $mt->maketext("Preview My Answers");
my $STRING_ShowCorrect = $mt->maketext("Show correct answers");
my $STRING_Submit = $mt->maketext("Submit Answers");

#my $pretty_print_self = pretty_print($self);

Expand Down
44 changes: 44 additions & 0 deletions lib/WeBWorK/lib/WeBWorK/Localize.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,55 @@ eval "

package WeBWorK::Localize;

# This subroutine is shared with the safe compartment in PG to
# allow maketext() to be constructed in PG problems and macros
# It seems to be a little fragile -- possibly it breaks
# on perl 5.8.8
sub getLoc {
my $lang = shift;
my $lh = WeBWorK::Localize::I18N->get_handle($lang);
return sub {$lh->maketext(@_)};
}

sub getLangHandle {
my $lang = shift;
my $lh = WeBWorK::Localize::I18N->get_handle($lang);
return $lh;
}

# this is like [quant] but it doesn't write the number
# usage: [quant,_1,<singular>,<plural>,<optional zero>]

sub plural {
my($handle, $num, @forms) = @_;

return "" if @forms == 0;
return $forms[2] if @forms > 2 and $num == 0;

# Normal case:
return( $handle->numerate($num, @forms) );
}

# this is like [quant] but it also has -1 case
# usage: [negquant,_1,<neg case>,<singular>,<plural>,<optional zero>]

sub negquant {
my($handle, $num, @forms) = @_;

return $num if @forms == 0;

my $negcase = shift @forms;
return $negcase if $num < 0;

return $forms[2] if @forms > 2 and $num == 0;
return( $handle->numf($num) . ' ' . $handle->numerate($num, @forms) );
}

%Lexicon = (
'_AUTO' => 1,
);

package WeBWorK::Localize::I18N;
use base(WeBWorK::Localize);

1;
245 changes: 245 additions & 0 deletions lib/WeBWorK/lib/WeBWorK/Localize/en.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
#
# Translators:
msgid ""
msgstr ""
"Project-Id-Version: webwork2\n"
"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
"PO-Revision-Date: 2021-03-09 17:00-0600\n"
"Last-Translator: \n"
"Language: en_US\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. (wwRound(0, $answerScore*100)
#: WeBWorK/lib/WeBWorK/Utils/AttemptsTable.pm:255
msgid "%1% correct"
msgstr ""

#. ($numBlanks)
#: WeBWorK/lib/WeBWorK/Utils/AttemptsTable.pm:395
msgid "%quant(%1,of the questions remains,of the questions remain) unanswered."
msgstr ""

#: PG/macros/PGbasicmacros.pl:1277 PG/macros/PGbasicmacros.pl:1286
msgid ""
"(Instructor hint preview: show the student hint after the following number "
"of attempts:"
msgstr ""

#: WeBWorK/lib/WeBWorK/Utils/AttemptsTable.pm:386
msgid "All of the answers above are correct."
msgstr ""

#: WeBWorK/lib/WeBWorK/Utils/AttemptsTable.pm:384
msgid "All of the gradeable answers above are correct."
msgstr ""

#: WeBWorK/lib/WeBWorK/Utils/AttemptsTable.pm:289
msgid "Answer Preview"
msgstr ""

#: WeBWorK/lib/WeBWorK/Utils/AttemptsTable.pm:391
msgid "At least one of the answers above is NOT correct."
msgstr ""

#: WeBWorK/lib/WeBWorK/Utils/AttemptsTable.pm:291
msgid "Correct Answer"
msgstr ""

#: WeBWorK/lib/WeBWorK/Utils/AttemptsTable.pm:288
msgid "Entered"
msgstr ""

#: WeBWorK/lib/WeBWorK/Utils/AttemptsTable.pm:238
msgid "FeedbackMessage"
msgstr ""

#: PG/macros/problemRandomize.pl:185 PG/macros/problemRandomize.pl:186
msgid "Get a new version of this problem"
msgstr ""

#: PG/macros/compoundProblem.pl:470
msgid "Go back to Part 1"
msgstr ""

#: PG/macros/compoundProblem.pl:291 PG/macros/compoundProblem.pl:480
#: PG/macros/compoundProblem.pl:491
msgid "Go on to next part"
msgstr ""

#: PG/macros/problemRandomize.pl:409
msgid "Hardcopy will always print the original version of the problem."
msgstr ""

#: PG/macros/PGbasicmacros.pl:1558
msgid "Hint:"
msgstr ""

#: PG/macros/PGbasicmacros.pl:1558
msgid "Hint: "
msgstr ""

#: PG/macros/problemRandomize.pl:408
msgid "If you come back to it later, it may revert to its original version."
msgstr ""

#: PG/macros/PGbasicmacros.pl:1226
msgid "Instructor solution preview: show the student solution after due date."
msgstr ""

#: WeBWorK/lib/WeBWorK/Utils/AttemptsTable.pm:292
msgid "Message"
msgstr ""

#: PG/macros/problemRandomize.pl:382 PG/macros/problemRandomize.pl:407
msgid "Note:"
msgstr ""

#: RenderApp/Controller/FormatRenderedProblem.pm:276
msgid "Preview My Answers"
msgstr ""

#: WeBWorK/lib/WeBWorK/Utils/AttemptsTable.pm:290
msgid "Result"
msgstr ""

#: WeBWorK/lib/WeBWorK/Utils/AttemptsTable.pm:302
msgid "Results for this submission"
msgstr ""

#: PG/macros/problemRandomize.pl:187
msgid "Set random seed to:"
msgstr ""

#: RenderApp/Controller/FormatRenderedProblem.pm:277
msgid "Show correct answers"
msgstr ""

#: PG/macros/PGbasicmacros.pl:1554 PG/macros/PGbasicmacros.pl:1555
msgid "Solution:"
msgstr ""

#: PG/macros/PGbasicmacros.pl:1553
msgid "Solution: "
msgstr ""

#: WeBWorK/lib/WeBWorK/Utils/AttemptsTable.pm:377
msgid "Some answers will be graded later."
msgstr ""

#: RenderApp/Controller/FormatRenderedProblem.pm:278
msgid "Submit Answers"
msgstr ""

#: PG/macros/compoundProblem.pl:502
msgid "Submit your answers again to go on to the next part."
msgstr ""

#: WeBWorK/lib/WeBWorK/Utils/AttemptsTable.pm:379
msgid "The answer above is NOT correct."
msgstr ""

#: WeBWorK/lib/WeBWorK/Utils/AttemptsTable.pm:375
msgid "The answer above is correct."
msgstr ""

#: PG/macros/problemRandomize.pl:407
msgid "This is a new (re-randomized) version of the problem."
msgstr ""

#: PG/macros/PGbasicmacros.pl:3084
msgid "This problem contains a video which must be viewed online."
msgstr ""

#: PG/macros/compoundProblem.pl:602
msgid "This problem has more than one part."
msgstr ""

#: WeBWorK/lib/WeBWorK/Utils/AttemptsTable.pm:248
msgid "Ungraded"
msgstr ""

#: PG/macros/PGanswermacros.pl:1693
msgid "You can earn partial credit on this problem."
msgstr ""

#: PG/macros/problemRandomize.pl:383
msgid "You can get a new version of this problem after the due date."
msgstr ""

#: PG/macros/compoundProblem.pl:610
msgid "You may not change your answers when going on to the next part!"
msgstr ""

#: PG/macros/PGbasicmacros.pl:3079
msgid "Your browser does not support the video tag."
msgstr ""

#: PG/macros/compoundProblem.pl:603
msgid "Your score for this attempt is for this part only;"
msgstr ""

#. (wwRound(0, $problemResult->{score} * 100)
#: RenderApp/Controller/FormatRenderedProblem.pm:215
msgid "Your score on this attempt is %1"
msgstr ""

#: RenderApp/Controller/FormatRenderedProblem.pm:217
msgid "Your score was not recorded."
msgstr ""

#: PG/macros/PGbasicmacros.pl:645 PG/macros/PGbasicmacros.pl:656
msgid "answer"
msgstr ""

#: PG/macros/PGbasicmacros.pl:669
msgid "column"
msgstr ""

#: WeBWorK/lib/WeBWorK/Utils/AttemptsTable.pm:244
msgid "correct"
msgstr ""

#. ('j','k','_0')
#. ('j','k')
#: PG/lib/Parser/List/Vector.pm:35 PG/lib/Value/Vector.pm:278
#: PG/macros/contextLimitedVector.pl:94
msgid "i"
msgstr ""

#: PG/macros/contextPiecewiseFunction.pl:774
msgid "if"
msgstr ""

#: WeBWorK/lib/WeBWorK/Utils/AttemptsTable.pm:253
msgid "incorrect"
msgstr ""

#: PG/macros/contextPiecewiseFunction.pl:777
msgid "otherwise"
msgstr ""

#: PG/macros/PGbasicmacros.pl:662
msgid "part"
msgstr ""

#: PG/macros/PGbasicmacros.pl:651
msgid "problem"
msgstr ""

#: PG/macros/PGbasicmacros.pl:668
msgid "row"
msgstr ""

#: PG/macros/compoundProblem.pl:470 PG/macros/compoundProblem.pl:480
msgid "when you submit your answers"
msgstr ""

#: PG/macros/compoundProblem.pl:604
msgid "your overall score is for all the parts combined."
msgstr ""
Loading