Skip to content

Commit

Permalink
Adjust TRANSLATOR strings
Browse files Browse the repository at this point in the history
Do a better job of placing TRANSLATOR strings so they are picked
up by xgettext (and the upcoming xtext).
  • Loading branch information
cpeel committed Apr 9, 2024
1 parent f76f31c commit 690ae5d
Show file tree
Hide file tree
Showing 15 changed files with 60 additions and 31 deletions.
4 changes: 1 addition & 3 deletions locale/translators/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ function main_form()
echo date("F d Y H:i:s", $po_file->last_modified);
echo "</td>";
echo "<td style='text-align: right'>";
// TRANSLATORS: This shows the number of strings translated with a percentage
$total_strings = $po_file->messages_count;
$translated_strings = $po_file->messages_translated_count;
if ($total_strings) {
Expand All @@ -288,6 +287,7 @@ function main_form()
$percent_translated = 0;
}
echo sprintf(
// TRANSLATORS: This shows the number of strings translated with a percentage
_('%1$s of %2$s translated (%3$d%%)'),
$translated_strings,
$total_strings,
Expand Down Expand Up @@ -326,7 +326,6 @@ function main_form()
. "</a> | <a href='$translate_url?func=download&amp;locale=template'>"
. _("Download") . "</a> ";
echo " (" . _("Last modified") . ": "
// TRANSLATORS: This is a date-formatted string
. date("F d Y H:i:s", $pot_file->last_modified) . ")";
$total_strings = $pot_file->messages_count;
$translated_strings = $pot_file->messages_translated_count;
Expand Down Expand Up @@ -380,7 +379,6 @@ function manage_form($locale)
echo "<a href='$translate_url?func=view&amp;locale=$locale'>"
. _("View") . "</a> | <a href='$translate_url?func=download&amp;locale=$locale'>"
. _("Download") . "</a> (" . _("Last modified") . ": "
// TRANSLATORS: this is a date-formatted string
. date("F d Y H:i:s", $po_file->last_modified) . ")";

echo " - ";
Expand Down
4 changes: 2 additions & 2 deletions pastnews.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
$limit_clause = "";
} else {
$limit_clause = "LIMIT $num";
echo "<a href='pastnews.php?news_page_id=$news_page_id'>"
echo "<a href='pastnews.php?news_page_id=$news_page_id'>" .
// TRANSLATORS: %s is the news subject.
. sprintf(_("Show All %s News"), $news_subject) . "</a>";
sprintf(_("Show All %s News"), $news_subject) . "</a>";
}

$sql = sprintf(
Expand Down
2 changes: 1 addition & 1 deletion pinc/LPage.inc
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,8 @@ class LPage
// Advise PM that the page has been marked bad.
configure_gettext_for_user($this->project->username);
$body_blurb_messages[] = sprintf(_('Page %1$s of this project has been marked bad due to %2$s.'), $this->imagefile, $PAGE_BADNESS_REASONS[$reason]);
// TRANSLATORS: %s is a url
$body_blurb_messages[] = sprintf(
// TRANSLATORS: %s is a url
_("Please visit %s to make any needed changes and make the page available for proofreading again."),
"$code_url/tools/project_manager/handle_bad_page.php?projectid={$this->projectid}&image={$this->imagefile}"
);
Expand Down
35 changes: 30 additions & 5 deletions pinc/ProjectSearchResults.inc
Original file line number Diff line number Diff line change
Expand Up @@ -405,17 +405,42 @@ class ColumnData
new GenreColumn("genre", _("Genre"), '', 'left-align', true, true, 'trans_genre'),
new LinkColumn("project_manager", pgettext("project manager", "PM"), _('Project Manager'), 'left-align', true, true, 'username'),
new LinkColumn("checkedoutby", _('Checked Out By'), '', 'left-align', false, true, 'checkedoutby'),
// TRANSLATORS: Abbreviation for Post Processor
new LinkColumn("pp_er", _('PP'), _('Post-processor'), 'left-align', false, true, 'postproofer'),
// TRANSLATORS: Abbreviation for Post-processing Verifier
new LinkColumn("ppv_er", _('PPV'), _('Post-processing Verifier'), 'left-align', false, true, 'ppverifier'),
new LinkColumn(
"pp_er",
// TRANSLATORS: Abbreviation for Post Processor
_('PP'),
_('Post-processor'),
'left-align',
false,
true,
'postproofer'
),
new LinkColumn(
"ppv_er",
// TRANSLATORS: Abbreviation for Post-processing Verifier
_('PPV'),
_('Post-processing Verifier'),
'left-align',
false,
true,
'ppverifier'
),
new TimeColumn("last_proof", _('Last proofed'), '', 'right-align', true, true, 't_last_page_done', $time_format),
new PGColumn("postednum", _('PG etext number'), '', 'right-align', false, true, 'postednum'),
new Column('p_avail', _('Available pages'), '', 'right-align', false, true, 'n_available_pages'),
new Column('p_total', _('Total pages'), '', 'right-align', false, false, 'n_pages'),
new StateChangeColumn("days_avail", _('Last State Change'), '', 'right-align', true, true, 'modifieddate', $time_format),
new StateColumn('state', pgettext('project state', 'State'), '', 'left-align', true, true, 'state'),
new HoldColumn('hold', _('Hold'), _('On hold'), 'center-align', false, false, 'hold'),
new HoldColumn(
'hold',
_('Hold'),
// TRANSLATORS: string indicates that the project is "on hold"
_('On hold'),
'center-align',
false,
false,
'hold'
),
];
if (user_can_work_in_stage($pguser, 'PP') || user_is_PM()) {
$this->columns[] = new OptionsColumn('options', _('Actions'), '', 'left-align nowrap', true, false, '');
Expand Down
2 changes: 1 addition & 1 deletion pinc/list_projects.inc
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ function list_projects($where_condition, $order_clause, $group_clause, $url_base
$last = $offset + $numrows;

// Display where we are now
// TRANSLATORS: This string is of the form: Projects <first> to <last> of <total>
echo "<p>";
// TRANSLATORS: This string is of the form: Projects <first> to <last> of <total>
echo sprintf(_('Projects %1$d to %2$d of %3$d'), $first, $last, $num_found_rows);
echo "</p>\n";

Expand Down
2 changes: 1 addition & 1 deletion pinc/showavailablebooks.inc
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ function show_projects_for_smooth_reading()
<img src='$code_url/graphics/rss.gif' width='36' height='14' alt='[RSS]'></a>
";

// TRANSLATORS: %s are image links to the XML and RSS feeds
echo "<p>";
// TRANSLATORS: %s are image links to the XML and RSS feeds
echo sprintf(_("Feeds of projects currently available for Smooth Reading: %s"), $xml_rss_images);
echo "</p>";

Expand Down
4 changes: 2 additions & 2 deletions tools/authors/authors.inc
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ function format_ymd($y, $m, $d)
$year = $y;
} elseif ($y > 0) {
// TRANSLATORS: Abbreviation for 'anno Domini' (years > 0)
$year = $y . ' ' . _('A. D.');
$year = sprintf("%d %s", $y, _('A. D.'));
} elseif ($y < 0) {
// TRANSLATORS: Abbreviation for 'before Christ' (years < 0)
$year = -$y . ' ' . _('B. C.');
$year = sprintf("%d %s", -$y, _('B. C.'));
} else {
// Year unknown = Everything unknown
return null;
Expand Down
2 changes: 1 addition & 1 deletion tools/changestate.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ function fatal_error($msg)
<input type='hidden' name='next_state' value='$next_state'>
<input type='hidden' name='confirmed' value='yes'>
<input type='hidden' name='return_uri' value='$return_uri'>"
// TRANSLATORS: %1$s is a button labeled "confirm transition change".
. sprintf(
// TRANSLATORS: %1$s is a button labeled "confirm transition change".
_("If so, %1\$s, otherwise go back to <a href='%2\$s'>where you were</a>"),
"<input type='submit' value='" . attr_safe(_("confirm transition change")) . "'>",
$return_uri
Expand Down
2 changes: 1 addition & 1 deletion tools/project_manager/handle_bad_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ function show_text_update_form($projectid, $image, $prev_text, $text_column, $mo
echo sprintf(_("The text area below contains the text from the previous round (%1\$s) for %2\$s."), $round_id, $image) . "<br>";
echo _("You may use it as-is, or insert other replacement text for this page:") . "<br>";
} else {
// TRANSLATORS: %1$s is the round ID; %2$ss is the image name.
// TRANSLATORS: %1$s is the round ID; %2$s is the image name.
echo sprintf(_("The text area below contains the text from round <b>%1\$s</b> for %2\$s."), $round_id, $image) . "<br>";
}

Expand Down
6 changes: 2 additions & 4 deletions tools/project_manager/show_good_word_suggestions_detail.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@

$project_name = get_project_name($projectid);
echo "<h2>",
// TRANSLATORS: %1$s is a word and %2$s is a project name.
sprintf(
// TRANSLATORS: %1$s is a word and %2$s is a project name.
_("Suggestion context for '%1\$s' in %2\$s"),
$word,
$project_name
Expand Down Expand Up @@ -103,9 +103,7 @@
foreach ($context_strings as $lineNum => $context_string) {
$context_string = _highlight_word(html_safe($context_string, ENT_NOQUOTES), $word);
echo "<b>" . _("Line") . "</b>: ",
// TRANSLATORS: %1$d is the approximate line number, and
// %2$d is the total number of lines when displaying the
// context of a word.
// TRANSLATORS: %1$d is the approximate line number, %2$d is the total number of lines
sprintf(_('~%1$d of %2$d'), $lineNum, $totalLines),
" &nbsp; | &nbsp; ";
echo "<b>" . _("Context") . "</b>:<br><span class='mono'>$context_string</span><br>";
Expand Down
10 changes: 8 additions & 2 deletions tools/project_manager/show_word_context.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,14 @@
echo "<div style='padding: 0.5em;'>";

$project_name = get_project_name($projectid);
// TRANSLATORS: %1$s is a word, %2$s is the project name.
echo "<h2>", sprintf(_("Context for '%1\$s' in %2\$s"), $word, $project_name), "</h2>";
echo "<h2>";
echo sprintf(
// TRANSLATORS: %1$s is a word and %2$s is a project name.
_("Context for '%1\$s' in %2\$s"),
$word,
$project_name
);
echo "</h2>";

echo "<p>";
echo "<a href='javascript:void(0)' id='h_v_switch'></a>";
Expand Down
2 changes: 1 addition & 1 deletion tools/proofers/for_mentors.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
echo output_project_label($proj_obj->nameofwork, $proj_obj->authorsname, $proj_obj->t_left_mentee_round);
if (in_array($mentoring_round->project_waiting_state, $project->get_hold_states())) {
// TRANSLATORS: string indicates that the project is "on hold"
echo " <b>[" . _("On hold") . "]</b>";
echo sprintf(" <b>[%s]</b>", _("On hold"));
}
echo "</li>";
}
Expand Down
8 changes: 5 additions & 3 deletions tools/proofers/greek2ascii.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ function addChar(myChar) {
<td colspan="3">
<?php
echo "<p>" . _("The Greek glyphs above are <b>clickable</b>.") . "</p>";
// TRANSLATORS: %s is an image of a rough-breathing mark.
echo "<p>";
echo sprintf(
"<p>" . _("Diacritical marks may be ignored except for the rough-breathing mark, (%s) above the letter. For these, put '<code>h</code>' before the letter <em>unless</em> the word begins with '<code>r</code>'. For those, put '<code>h</code>' <em>after</em> the '<code>r</code>'."),
// TRANSLATORS: %s is an image of a rough-breathing mark.
_("Diacritical marks may be ignored except for the rough-breathing mark, (%s) above the letter. For these, put '<code>h</code>' before the letter <em>unless</em> the word begins with '<code>r</code>'. For those, put '<code>h</code>' <em>after</em> the '<code>r</code>'."),
"<img src='gfx/greekrough.png' height='12' width='10'>"
) . "</p>";
);
echo "</p>";
?>
</td>
</tr>
Expand Down
6 changes: 3 additions & 3 deletions tools/proofers/review_work.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,13 @@ function _echo_round_select($rounds, $selected_round)
} else {
echo "<th>" . _("Last saved by user in project") . "</th>";
}
// TRANSLATORS: %s is the round ID.
// TRANSLATORS: %s is the round ID
echo "<th>" . sprintf(_("Pages saved by user in %s"), $work_round->id) . "</th>";
// TRANSLATORS: %s is the round ID.
// TRANSLATORS: %s is the round ID
echo "<th>" . sprintf(_("Pages saved by others in %s"), $review_round->id) . "</th>";
echo "<th>" . _("Pages with differences") . "</th>";
if ($sampleLimit > 0) {
// TRANSLATORS: %s is a number of diffs.
// TRANSLATORS: %s is a number of diffs
echo "<th>" . sprintf(_("%s most recent diffs"), $sampleLimit) . "</th>";
}
echo "</tr>";
Expand Down
2 changes: 1 addition & 1 deletion tools/proofers/round.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@

echo "<i>".$rule->subject."</i><br>";
echo "<p>".$rule->rule."</p>";
// TRANSLATORS: %1$s is the linked name of a random Guideline section.
printf(
// TRANSLATORS: %1$s is the linked name of a random Guideline section.
_("See the %1\$s section of the <a href='%2\$s'>Guidelines</a>"),
"<a href='$round_doc_url#".$rule->anchor."'>".$rule->subject."</a>",
$round_doc_url
Expand Down

0 comments on commit 690ae5d

Please sign in to comment.