Skip to content

Commit

Permalink
Remove UTF8 multiplication and degree symbol macros
Browse files Browse the repository at this point in the history
- Switch to using prime and double prime for minutes/seconds
- Regenerate translations
  • Loading branch information
ajtribick committed Nov 21, 2024
1 parent bd70127 commit ffc07db
Show file tree
Hide file tree
Showing 33 changed files with 3,205 additions and 3,223 deletions.
212 changes: 106 additions & 106 deletions po/ar.po

Large diffs are not rendered by default.

228 changes: 114 additions & 114 deletions po/be.po

Large diffs are not rendered by default.

228 changes: 114 additions & 114 deletions po/bg.po

Large diffs are not rendered by default.

208 changes: 104 additions & 104 deletions po/celestia.pot

Large diffs are not rendered by default.

208 changes: 104 additions & 104 deletions po/de.po

Large diffs are not rendered by default.

212 changes: 106 additions & 106 deletions po/el.po

Large diffs are not rendered by default.

208 changes: 104 additions & 104 deletions po/es.po

Large diffs are not rendered by default.

220 changes: 110 additions & 110 deletions po/fr.po

Large diffs are not rendered by default.

222 changes: 111 additions & 111 deletions po/gl.po

Large diffs are not rendered by default.

208 changes: 104 additions & 104 deletions po/hu.po

Large diffs are not rendered by default.

218 changes: 109 additions & 109 deletions po/it.po

Large diffs are not rendered by default.

222 changes: 111 additions & 111 deletions po/ja.po

Large diffs are not rendered by default.

234 changes: 117 additions & 117 deletions po/ka.po

Large diffs are not rendered by default.

208 changes: 104 additions & 104 deletions po/ko.po

Large diffs are not rendered by default.

236 changes: 118 additions & 118 deletions po/lt.po

Large diffs are not rendered by default.

208 changes: 104 additions & 104 deletions po/lv.po

Large diffs are not rendered by default.

236 changes: 118 additions & 118 deletions po/nb.po

Large diffs are not rendered by default.

208 changes: 104 additions & 104 deletions po/nl.po

Large diffs are not rendered by default.

220 changes: 110 additions & 110 deletions po/pl.po

Large diffs are not rendered by default.

208 changes: 104 additions & 104 deletions po/pt.po

Large diffs are not rendered by default.

208 changes: 104 additions & 104 deletions po/pt_BR.po

Large diffs are not rendered by default.

212 changes: 106 additions & 106 deletions po/ro.po

Large diffs are not rendered by default.

228 changes: 114 additions & 114 deletions po/ru.po

Large diffs are not rendered by default.

208 changes: 104 additions & 104 deletions po/sk.po

Large diffs are not rendered by default.

208 changes: 104 additions & 104 deletions po/sv.po

Large diffs are not rendered by default.

222 changes: 111 additions & 111 deletions po/tr.po

Large diffs are not rendered by default.

208 changes: 104 additions & 104 deletions po/uk.po

Large diffs are not rendered by default.

307 changes: 150 additions & 157 deletions po/zh_CN.po

Large diffs are not rendered by default.

208 changes: 104 additions & 104 deletions po/zh_TW.po

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions src/celestia/hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,16 +261,16 @@ angleToStr(double angle, const std::locale& loc)

if (degrees > 0)
{
return fmt::format(loc, "{}" UTF8_DEGREE_SIGN "{:02d}' {:.1f}\"",
return fmt::format(loc, "{}° {:02d} {:.1f}",
degrees, std::abs(minutes), std::abs(seconds));
}

if (minutes > 0)
{
return fmt::format(loc, "{:02d}' {:.1f}\"", std::abs(minutes), std::abs(seconds));
return fmt::format(loc, "{:02d} {:.1f}", std::abs(minutes), std::abs(seconds));
}

return fmt::format(loc, "{:.2f}\"", std::abs(seconds));
return fmt::format(loc, "{:.2f}", std::abs(seconds));
}

void
Expand All @@ -295,9 +295,8 @@ displayDeclination(Overlay& overlay, double angle, const std::locale& loc)
double seconds;
astro::decimalToDegMinSec(angle, degrees, minutes, seconds);

overlay.print(loc, _("Dec: {:+d}{} {:02d}' {:.1f}\"\n"),
std::abs(degrees), UTF8_DEGREE_SIGN,
std::abs(minutes), std::abs(seconds));
overlay.print(loc, _("Dec: {:+d}° {:02d}′ {:.1f}″\n"),
std::abs(degrees), std::abs(minutes), std::abs(seconds));
}

void
Expand Down Expand Up @@ -608,7 +607,7 @@ displayPlanetInfo(const util::NumberFormatter& formatter,
sunVec.normalize();
double cosPhaseAngle = std::clamp(sunVec.dot(viewVec.normalized()), -1.0, 1.0);
double phaseAngle = acos(cosPhaseAngle);
overlay.print(loc, _("Phase angle: {:.1f}{}\n"), math::radToDeg(phaseAngle), UTF8_DEGREE_SIGN);
overlay.print(loc, _("Phase angle: {:.1f}°\n"), math::radToDeg(phaseAngle));
}
}

Expand Down
29 changes: 9 additions & 20 deletions src/celestia/qt/qtinfopanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ namespace celestia::qt
namespace
{

const QString DegreeSign = QString::fromUtf8(UTF8_DEGREE_SIGN);

astro::KeplerElements
CalculateOsculatingElements(const celestia::ephem::Orbit& orbit,
double t,
Expand Down Expand Up @@ -319,26 +317,21 @@ void InfoPanel::buildSolarSystemBodyPage(const Body* body,

stream << QString(_("<b>Semi-major axis:</b> %L1 %2")).arg(sma).arg(units) << "<br>\n";
stream << QString(_("<b>Eccentricity:</b> %L1")).arg(elements.eccentricity) << "<br>\n";
stream << QString(_("<b>Inclination:</b> %L1%2")).arg(math::radToDeg(elements.inclination))
.arg(DegreeSign) << "<br>\n";
stream << QString(_("<b>Inclination:</b> %L1°")).arg(math::radToDeg(elements.inclination)) << "<br>\n";
stream << QString(_("<b>Pericenter distance:</b> %L1 %2")).arg(sma * (1 - elements.eccentricity)).arg(units) << "<br>\n";
if (elements.eccentricity < 1.0)
stream << QString(_("<b>Apocenter distance:</b> %L1 %2")).arg(sma * (1 + elements.eccentricity)).arg(units) << "<br>\n";

stream << QString(_("<b>Ascending node:</b> %L1%2")).arg(math::radToDeg(elements.longAscendingNode))
.arg(DegreeSign) << "<br>\n";
stream << QString(_("<b>Argument of periapsis:</b> %L1%2")).arg(math::radToDeg(elements.argPericenter))
.arg(DegreeSign) << "<br>\n";
stream << QString(_("<b>Mean anomaly:</b> %L1%2")).arg(math::radToDeg(elements.meanAnomaly))
.arg(DegreeSign) << "<br>\n";
stream << QString(_("<b>Ascending node:</b> %L1°")).arg(math::radToDeg(elements.longAscendingNode)) << "<br>\n";
stream << QString(_("<b>Argument of periapsis:</b> %L1°")).arg(math::radToDeg(elements.argPericenter)) << "<br>\n";
stream << QString(_("<b>Mean anomaly:</b> %L1°")).arg(math::radToDeg(elements.meanAnomaly)) << "<br>\n";
if (elements.eccentricity < 1.0)
{
stream << QString(_("<b>Period (calculated):</b> %L1 %2")).arg(elements.period).arg(_("days")) << "<br>\n";
}
else
{
stream << QString(_("<b>Mean motion (calculated):</b> %L1%2/day")).arg(360.0 / elements.period)
.arg(DegreeSign) << "<br>\n";
stream << QString(_("<b>Mean motion (calculated):</b> %L1°/day")).arg(360.0 / elements.period) << "<br>\n";
}
}

Expand All @@ -365,8 +358,7 @@ InfoPanel::buildStarPage(const Star* star, const Universe* universe, double tdb,

int degrees = 0;
astro::decimalToDegMinSec(math::radToDeg(sph.y()), degrees, minutes, seconds);
stream << QString(_("<b>Dec:</b> %L1%2 %L3' %L4\"")).arg(degrees).arg(DegreeSign)
.arg(abs(minutes)).arg(abs(seconds)) << "<br>\n";
stream << QString(_("<b>Dec:</b> %L1° %L2′ %L3″")).arg(degrees).arg(abs(minutes)).arg(abs(seconds)) << "<br>\n";
}


Expand All @@ -388,20 +380,17 @@ void InfoPanel::buildDSOPage(const DeepSkyObject* dso,

int degrees = 0;
astro::decimalToDegMinSec(math::radToDeg(sph.y()), degrees, minutes, seconds);
stream << QString(_("<b>Dec:</b> %L1%2 %L3' %L4\"")).arg(degrees).arg(DegreeSign)
.arg(abs(minutes)).arg(abs(seconds)) << "<br>\n";
stream << QString(_("<b>Dec:</b> %L1° %L2′ %L3″")).arg(degrees).arg(abs(minutes)).arg(abs(seconds)) << "<br>\n";

Eigen::Vector3d galPos = astro::equatorialToGalactic(eqPos);
sph = rectToSpherical(galPos);

astro::decimalToDegMinSec(math::radToDeg(sph.x()), degrees, minutes, seconds);
// TRANSLATORS: Galactic longitude
stream << QString(_("<b>L:</b> %L1%2 %L3' %L4\"")).arg(degrees).arg(DegreeSign)
.arg(abs(minutes)).arg(abs(seconds)) << "<br>\n";
stream << QString(_("<b>L:</b> %L1° %L2′ %L3″")).arg(degrees).arg(abs(minutes)).arg(abs(seconds)) << "<br>\n";
astro::decimalToDegMinSec(math::radToDeg(sph.y()), degrees, minutes, seconds);
// TRANSLATORS: Galactic latitude
stream << QString(_("<b>B:</b> %L1%2 %L3' %L4\"")).arg(degrees).arg(DegreeSign)
.arg(abs(minutes)).arg(abs(seconds)) << "<br>\n";
stream << QString(_("<b>B:</b> %L1° %L2′ %L3″")).arg(degrees).arg(abs(minutes)).arg(abs(seconds)) << "<br>\n";
}


Expand Down
21 changes: 12 additions & 9 deletions src/celrender/skygridrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <cmath>
#include <iterator>
#include <string>
#include <string_view>
#include <utility>

#include <Eigen/Geometry>
Expand All @@ -32,6 +33,8 @@
#include <celutil/color.h>
#include "linerenderer.h"

using namespace std::string_view_literals;

namespace celestia::render
{

Expand Down Expand Up @@ -233,15 +236,15 @@ latitudeLabel(int latitude, int latitudeStep)
if (latitudeStep % DEG == 0)
return result;

fmt::format_to(std::back_inserter(result), " {:02}'", (latitude / MIN) % 60);
fmt::format_to(std::back_inserter(result), " {:02}", (latitude / MIN) % 60);
if (latitudeStep % MIN == 0)
return result;

fmt::format_to(std::back_inserter(result), " {:02}", (latitude / SEC) % 60);
if (latitudeStep % SEC != 0)
fmt::format_to(std::back_inserter(result), ".{:03}", latitude % SEC);

result.push_back('"');
result.append(""sv);
return result;
}

Expand All @@ -254,17 +257,17 @@ longitudeLabel(int longitude, int longitudeStep,
{
int totalUnits = HOUR_MIN_SEC_TOTAL;
int baseUnit = HR;
const char* baseUnitSymbol = "h";
char minuteSymbol = 'm';
char secondSymbol = 's';
std::string_view baseUnitSymbol = "°"sv;
std::string_view minuteSymbol = "m"sv;
std::string_view secondSymbol = "s"sv;

if (longitudeUnits == engine::SkyGrid::LongitudeDegrees)
{
totalUnits = DEG_MIN_SEC_TOTAL * 2;
baseUnit = DEG;
baseUnitSymbol = "°";
minuteSymbol = '\'';
secondSymbol = '"';
baseUnitSymbol = "°"sv;
minuteSymbol = ""sv;
secondSymbol = ""sv;
}

// Produce a sexigesimal string
Expand All @@ -289,7 +292,7 @@ longitudeLabel(int longitude, int longitudeStep,
if (longitudeStep % SEC != 0)
fmt::format_to(std::back_inserter(result), ".{:03}", longitude % SEC);

result.push_back(secondSymbol);
result.append(secondSymbol);
return result;
}

Expand Down
4 changes: 1 addition & 3 deletions src/celutil/utf8.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
#include <string>
#include <string_view>

#define UTF8_DEGREE_SIGN "\302\260"
#define UTF8_MULTIPLICATION_SIGN "\303\227"
#define UTF8_REPLACEMENT_CHAR "\357\277\275"
#define UTF8_REPLACEMENT_CHAR "\357\277\275"

bool UTF8Decode(std::string_view str, std::int32_t &ch);
bool UTF8Decode(std::string_view str, std::int32_t &pos, std::int32_t &ch);
Expand Down

0 comments on commit ffc07db

Please sign in to comment.