Skip to content

Commit

Permalink
i18n fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Blake-Madden committed Dec 23, 2024
1 parent 63406fd commit b76ca43
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 72 deletions.
55 changes: 38 additions & 17 deletions demo/demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,9 @@ void MyFrame::OnQuit([[maybe_unused]] wxCommandEvent& event) { Close(); }
void MyFrame::OnAbout([[maybe_unused]] wxCommandEvent& event)
{
wxAboutDialogInfo aboutInfo;
aboutInfo.SetCopyright(L"Copyright (c) 2024");
aboutInfo.SetCopyright(_(L"Copyright (c) 2025"));
wxArrayString devs;
devs.Add(L"Blake Madden");
devs.Add(_DT(L"Blake Madden"));
aboutInfo.SetDevelopers(devs);
aboutInfo.SetName(_(L"Wisteria Dataviz Library Demo"));
aboutInfo.SetDescription(_(L"Demonstration of Wisteria Dataviz, "
Expand Down Expand Up @@ -825,7 +825,9 @@ void MyFrame::OnNewWindow(wxCommandEvent& event)
}

// change the color for any point less than 60 to red to show if failing
linePlot->SetPointColorCriteria([]([[maybe_unused]] const double x, const double y)
linePlot->SetPointColorCriteria([]([[maybe_unused]]
const double x,
const double y)
{ return (y < 60.0) ? *wxRED : wxColour(); });

// add a note
Expand Down Expand Up @@ -854,7 +856,10 @@ void MyFrame::OnNewWindow(wxCommandEvent& event)
// customize the X axis labels
for (int i = 1; i < 6; ++i)
{
linePlot->GetBottomXAxis().SetCustomLabel(i, Label(wxString::Format(_(L"Week %i"), i)));
linePlot->GetBottomXAxis().SetCustomLabel(
i, Label(wxString::Format(
/* TRANSLATORS: Week # of the school year */
_(L"Week %i"), i)));
}

// add a red background for failing grades
Expand Down Expand Up @@ -996,8 +1001,9 @@ void MyFrame::OnNewWindow(wxCommandEvent& event)
// so that there isn't a scrollbar.
// candlestickPlot->SetPointsPerDefaultCanvasSize(365);

candlestickPlot->SetData(silverFuturesData, L"Date", L"Open", L"High", L"Low",
L"Close/Last");
candlestickPlot->SetData(
silverFuturesData, L"Date", L"Open", L"High", L"Low",
_DT(L"Close/Last", DTExplanation::Syntax, L"Name of variable from dataset"));

candlestickPlot->GetTitle().SetText(_(L"Silver COMEX 2021 Trend"));

Expand Down Expand Up @@ -1340,7 +1346,7 @@ void MyFrame::OnNewWindow(wxCommandEvent& event)
plot->UseColorLabels(true);
// add a donut hole
plot->IncludeDonutHole(true);
plot->GetDonutHoleLabel().SetText(L"Enrollment\nFall 2023");
plot->GetDonutHoleLabel().SetText(_(L"Enrollment\nFall 2023"));
plot->SetDonutHoleProportion(.5);

subframe->m_canvas->SetFixedObject(0, 0, plot);
Expand Down Expand Up @@ -1436,7 +1442,7 @@ void MyFrame::OnNewWindow(wxCommandEvent& event)
plot->UseColorLabels(true);
// add a donut hole
plot->IncludeDonutHole(true);
plot->GetDonutHoleLabel().SetText(L"Enrollment\nFall 2023");
plot->GetDonutHoleLabel().SetText(_(L"Enrollment\nFall 2023"));
plot->SetDonutHoleProportion(.8);

subframe->m_canvas->SetFixedObject(0, 0, plot);
Expand Down Expand Up @@ -1491,7 +1497,10 @@ void MyFrame::OnNewWindow(wxCommandEvent& event)
appDir + L"/datasets/institutional_research/hs_graduate_matriculation.csv",
ImportInfo()
.ContinuousColumns({ L"Graduated", L"Enrolled" })
.CategoricalColumns({ { L"County" }, { L"High School" }, { L"University" } }));
.CategoricalColumns({ { L"County" },
{ _DT(L"High School", DTExplanation::Syntax,
L"Name of variable from dataset") },
{ L"University" } }));
}
catch (const std::exception& err)
{
Expand All @@ -1501,8 +1510,10 @@ void MyFrame::OnNewWindow(wxCommandEvent& event)
}

auto sankey = std::make_shared<SankeyDiagram>(subframe->m_canvas);
sankey->SetData(sankeyData, L"High School", L"University", L"Graduated", L"Enrolled",
L"County");
sankey->SetData(
sankeyData,
_DT(L"High School", DTExplanation::Syntax, L"Name of variable from dataset"),
L"University", L"Graduated", L"Enrolled", L"County");
sankey->SetGroupLabelDisplay(BinLabelDisplay::BinNameAndValue);
sankey->SetColumnHeaderDisplay(GraphColumnHeader::AsHeader);
sankey->SetColumnHeaders({ _(L"Of @COUNT@ High School Graduates"),
Expand Down Expand Up @@ -1577,7 +1588,8 @@ void MyFrame::OnNewWindow(wxCommandEvent& event)

auto roadmap = std::make_shared<LRRoadmap>(subframe->m_canvas);
roadmap->SetData(roadmapData, L"factor", L"coefficient", std::nullopt, std::nullopt,
std::nullopt, _(L"GPA"));
std::nullopt, // TRANSLATORS: Grade Point Average
_(L"GPA"));
roadmap->SetCanvasMargins(5, 5, 5, 5);
// add the default caption explaining how to read the graph
roadmap->AddDefaultCaption();
Expand Down Expand Up @@ -1855,11 +1867,16 @@ void MyFrame::OnNewWindow(wxCommandEvent& event)

// add brackets around some of the questions to group them
likertChart->AddQuestionsBracket(LikertChart::QuestionsBracket{
L"Customization is important to me", L"Extensibility is important to me",
_DT(L"Customization is important to me", DTExplanation::Syntax,
L"Name of variable from dataset"),
_DT(L"Extensibility is important to me", DTExplanation::Syntax,
L"Name of variable from dataset"),
_(L"Advanced Features") });
likertChart->AddQuestionsBracket(LikertChart::QuestionsBracket{
LR"(Standard, "out-of-the-box" graph support is important to me)",
L"Data importing features are important to me", _(L"Standard Features") });
_DT(L"Data importing features are important to me", DTExplanation::Syntax,
L"Name of variable from dataset"),
_(L"Standard Features") });

likertChart->SetCanvasMargins(5, 5, 5, 5);

Expand Down Expand Up @@ -1987,7 +2004,10 @@ void MyFrame::OnNewWindow(wxCommandEvent& event)
// customize the X axis labels
for (int i = 1; i < 6; ++i)
{
linePlot->GetBottomXAxis().SetCustomLabel(i, Label(wxString::Format(_(L"Week %i"), i)));
linePlot->GetBottomXAxis().SetCustomLabel(i,
Label(wxString::Format(
// TRANSLATORS: Week # of the school year
_(L"Week %i"), i)));
}

// instead of adding the legend to the canvas, overlay it on top of the line plot
Expand Down Expand Up @@ -2075,8 +2095,9 @@ void MyFrame::OnNewWindow(wxCommandEvent& event)
// if any outliers, make a note of it off to the side
if (ratioOutliers.size())
{
tableGraph->AddCellAnnotation({ L"Majors with the most lopsided female-to-male ratios",
ratioOutliers, Side::Right, std::nullopt, wxColour() });
tableGraph->AddCellAnnotation(
{ _(L"Majors with the most lopsided female-to-male ratios"), ratioOutliers,
Side::Right, std::nullopt, wxColour() });
}

// if you also want to place annotations on the left of the table,
Expand Down
11 changes: 9 additions & 2 deletions src/base/shapes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,10 @@ namespace Wisteria::GraphItems
const auto signRect = wxRect(rect.GetLeftTop(),
wxSize(rect.GetWidth(),
rect.GetHeight() * math_constants::two_thirds));
DrawCircularSign(signRect, ColorBrewer::GetColor(Color::KellyGreen), _(L"GO"), dc);
DrawCircularSign(signRect,
ColorBrewer::GetColor(Color::KellyGreen),
// TRANSLATORS: A GO sign, as in OK to proceed
_(L"GO"), dc);
}
}

Expand Down Expand Up @@ -1749,7 +1752,11 @@ namespace Wisteria::GraphItems
textRect.SetHeight(dcRect.GetHeight() * math_constants::half);
textRect.Offset(wxPoint(frameWidth, frameWidth));

Label boardText(GraphItemInfo(_("ABC")).FontColor(*wxWHITE).Pen(wxNullPen).
Label boardText(
GraphItemInfo(
/* TRANSLATORS: Simple placeholder text of any sort */
_("ABC")).
FontColor(*wxWHITE).Pen(wxNullPen).
DPIScaling(GetDPIScaleFactor()).Scaling(GetScaling()));
boardText.GetFont().MakeBold().SetFaceName(Label::GetFirstAvailableCursiveFont());
boardText.SetBoundingBox(textRect, dc, GetScaling());
Expand Down
6 changes: 3 additions & 3 deletions src/data/dataset.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "../import/text_matrix.h"
#include "../import/text_preview.h"
#include "../math/mathematics.h"
#include "../util/donttranslate.h"
#include "../util/frequencymap.h"
#include "excelreader.h"
#include <algorithm>
Expand Down Expand Up @@ -74,8 +75,7 @@ namespace Wisteria::Data
public:
/// @private
[[nodiscard]]
bool
operator()(const wxString& lhs, const wxString& rhs) const
bool operator()(const wxString& lhs, const wxString& rhs) const
{
return lhs.CmpNoCase(rhs) < 0;
}
Expand Down Expand Up @@ -851,7 +851,7 @@ namespace Wisteria::Data
[[nodiscard]]
static std::vector<std::wstring> GetCommonMDCodes()
{
return std::vector<std::wstring>{ L"NA", L"N/A", L"NULL" };
return std::vector<std::wstring>{ _DT(L"NA"), _DT(L"N/A"), _DT(L"NULL") };
}

/** @brief Set whether to import numeric columns with leading zeros as text.
Expand Down
69 changes: 38 additions & 31 deletions src/graphs/ganttchart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

wxIMPLEMENT_DYNAMIC_CLASS(Wisteria::Graphs::GanttChart, Wisteria::Graphs::BarChart)

using namespace Wisteria::GraphItems;
using namespace Wisteria::GraphItems;
using namespace Wisteria::Colors;
using namespace Wisteria::Icons;
using namespace Wisteria::Icons::Schemes;
Expand Down Expand Up @@ -209,35 +209,40 @@ namespace Wisteria::Graphs
const double daysFinished =
safe_divide<double>(taskInfo.m_percentFinished, 100) * daysInTask;
const double daysRemaining = daysInTask - daysFinished;
Bar br(GetBars().size(),
{ { BarBlock(BarBlockInfo(daysFinished)
.Brush(wxBrush(
ColorContrast::BlackOrWhiteContrast(taskInfo.m_color),
wxBrushStyle::wxBRUSHSTYLE_FDIAGONAL_HATCH))
.Color(taskInfo.m_color)
.SelectionLabel(GraphItems::Label(
wxString(wxString::Format(
_(L"%s\n%d days\n(%s through %s)"),
wxString(taskInfo.m_resource + L"\n" +
taskInfo.m_description)
.Trim(),
daysInTask, taskInfo.m_start.FormatDate(),
taskInfo.m_end.FormatDate()))
.Trim(true)
.Trim(false)))) },
{ BarBlock(BarBlockInfo(daysRemaining)
.Brush(taskInfo.m_color)
.SelectionLabel(GraphItems::Label(
wxString(wxString::Format(
_(L"%s\n%d days\n(%s through %s)"),
wxString(taskInfo.m_resource + L"\n" +
taskInfo.m_description)
.Trim(),
daysInTask, taskInfo.m_start.FormatDate(),
taskInfo.m_end.FormatDate()))
.Trim(true)
.Trim(false)))) } },
wxEmptyString, axisLabel, GetBarEffect(), GetBarOpacity());
Bar br(
GetBars().size(),
{ { BarBlock(
BarBlockInfo(daysFinished)
.Brush(wxBrush(ColorContrast::BlackOrWhiteContrast(taskInfo.m_color),
wxBrushStyle::wxBRUSHSTYLE_FDIAGONAL_HATCH))
.Color(taskInfo.m_color)
.SelectionLabel(GraphItems::Label(
wxString(
wxString::Format(
// TRANSLATORS: Description, # of days, then a date range
_(L"%s\n%d days\n(%s through %s)"),
wxString(taskInfo.m_resource + L"\n" +
taskInfo.m_description)
.Trim(),
daysInTask, taskInfo.m_start.FormatDate(),
taskInfo.m_end.FormatDate()))
.Trim(true)
.Trim(false)))) },
{ BarBlock(BarBlockInfo(daysRemaining)
.Brush(taskInfo.m_color)
.SelectionLabel(GraphItems::Label(
wxString(wxString::Format(
// TRANSLATORS: Description, # of days,
// then a date range
_(L"%s\n%d days\n(%s through %s)"),
wxString(taskInfo.m_resource + L"\n" +
taskInfo.m_description)
.Trim(),
daysInTask, taskInfo.m_start.FormatDate(),
taskInfo.m_end.FormatDate()))
.Trim(true)
.Trim(false)))) } },
wxEmptyString, axisLabel, GetBarEffect(), GetBarOpacity());
// remove "completed" bar block if nothing is actually completed
if (taskInfo.m_percentFinished == 0)
{
Expand Down Expand Up @@ -280,7 +285,9 @@ namespace Wisteria::Graphs
daysInTask);
break;
case TaskLabelDisplay::Days:
decalStr = wxString::Format(_(L"%d days"), daysInTask);
decalStr = wxString::Format(
// TRANSLATORS: # of days remaining in a task
_(L"%d days"), daysInTask);
break;
case TaskLabelDisplay::NoDisplay:
[[fallthrough]];
Expand Down
37 changes: 25 additions & 12 deletions src/graphs/wcurveplot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

wxIMPLEMENT_DYNAMIC_CLASS(Wisteria::Graphs::WCurvePlot, Wisteria::Graphs::LinePlot)

using namespace Wisteria;
using namespace Wisteria;
using namespace Wisteria::GraphItems;
using namespace Wisteria::Colors;
using namespace Wisteria::Colors::Schemes;
Expand Down Expand Up @@ -71,7 +71,10 @@ namespace Wisteria::Graphs
GetTopXAxis().SetLabelDisplay(AxisLabelDisplay::DisplayOnlyCustomLabels);
GetTopXAxis().GetAxisLinePen() = wxNullPen;

GetBottomXAxis().GetTitle().SetText(_(L"TIME"));
GetBottomXAxis().GetTitle().SetText(
/* TRANSLATORS: OK to translate as "Time".
This is uppercased only because that's how it appears in the original article.*/
_(L"TIME"));
GetLeftYAxis().GetTitle().SetText(_(L"Level of control, satisfaction, and effectiveness"));

ResetTimeLabels();
Expand Down Expand Up @@ -105,34 +108,44 @@ namespace Wisteria::Graphs
switch (step)
{
case 1:
return wxString::Format(_(L"First %s"), m_timeLabel);
return wxString::Format( // TRANSLATORS: %s is time interval (e.g., semester)
_(L"First %s"), m_timeLabel);
break;
case 2:
return wxString::Format(_(L"Second %s"), m_timeLabel);
return wxString::Format( // TRANSLATORS: %s is time interval (e.g., semester)
_(L"Second %s"), m_timeLabel);
break;
case 3:
return wxString::Format(_(L"Third %s"), m_timeLabel);
return wxString::Format( // TRANSLATORS: %s is time interval (e.g., semester)
_(L"Third %s"), m_timeLabel);
break;
case 4:
return wxString::Format(_(L"Fourth %s"), m_timeLabel);
return wxString::Format( // TRANSLATORS: %s is time interval (e.g., semester)
_(L"Fourth %s"), m_timeLabel);
break;
case 5:
return wxString::Format(_(L"Fifth %s"), m_timeLabel);
return wxString::Format( // TRANSLATORS: %s is time interval (e.g., semester)
_(L"Fifth %s"), m_timeLabel);
break;
case 6:
return wxString::Format(_(L"Sixth %s"), m_timeLabel);
return wxString::Format( // TRANSLATORS: %s is time interval (e.g., semester)
_(L"Sixth %s"), m_timeLabel);
break;
case 7:
return wxString::Format(_(L"Seventh %s"), m_timeLabel);
return wxString::Format( // TRANSLATORS: %s is time interval (e.g., semester)
_(L"Seventh %s"), m_timeLabel);
break;
case 8:
return wxString::Format(_(L"Eighth %s"), m_timeLabel);
return wxString::Format( // TRANSLATORS: %s is time interval (e.g., semester)
_(L"Eighth %s"), m_timeLabel);
break;
case 9:
return wxString::Format(_(L"Ninth %s"), m_timeLabel);
return wxString::Format( // TRANSLATORS: %s is time interval (e.g., semester)
_(L"Ninth %s"), m_timeLabel);
break;
case 10:
return wxString::Format(_(L"Tenth %s"), m_timeLabel);
return wxString::Format( // TRANSLATORS: %s is time interval (e.g., semester)
_(L"Tenth %s"), m_timeLabel);
break;
default:
return wxString{};
Expand Down
2 changes: 1 addition & 1 deletion src/ui/controls/formattedtextctrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1597,7 +1597,7 @@ wxString FormattedTextCtrl::GtkGetFormattedText(const GtkFormat format,
}
else if (format == GtkFormat::RtfFormat)
{
wxString defaultFontFamily(family, *wxConvCurrent);
const wxString defaultFontFamily(family);
g_free(family);
wxString headerText = wxString::Format(
L"{\\rtf1\\ansi\\deff0\\deflang1033{\\fonttbl{\\f0\\%s\\fcharset0 %s;}}\n",
Expand Down
Loading

0 comments on commit b76ca43

Please sign in to comment.