[i18n] translate more strings

pull/975/head
Hleb Valoshka 2021-05-07 18:47:18 +03:00
parent 668a6023e9
commit c906f917eb
10 changed files with 85 additions and 55 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/perl
# Extract translatable strings from a windows resource files
# Extract translatable strings from a windows resource files
# and outputs them in a C like format for use by gettext.
use strict;
@ -17,19 +17,29 @@ my %keywords = (
'CTEXT' => 1,
'LTEXT' => 1,
'GROUPBOX' => 1,
'CONTROL' => 1
'CONTROL' => 1,
'GROUPBOX' => 1,
'AUTOCHECKBOX' => 1,
'AUTORADIOBUTTON' => 1
);
while (<>) {
# Matches lines:
# KEYWORD "String" ...
if ( $_ =~ /^\s*(\w+)\s+"(.+?)"/ && $_ !~ /^\s*(\w+)\s+""/) {
next if ($_ =~ /^\s*(\w+)\s+""/);
if ($_ =~ /^\s*(\w+)\s+"(.+?)"/) {
# Excludes blank strings and strings of the form word followed by digit
# which are control names (e.g. DateTimePicker3)
if (exists($keywords{$1}) && $2 !~ /^ *$/ && $2 !~ /^\w+\d$/ && $2 !~ /^""/) {
print qq{_("$2");\n};
}
}
elsif ($_ =~ /^\s*(\w+)\s+NC_\(\s*"(.+?)"\s*,\s*"(.+?)"\s*\)/) {
if (exists($keywords{$1}) && $2 !~ /^ *$/ && $2 !~ /^\w+\d$/ && $2 !~ /^""/) {
print qq{NC_("$2", "$3");\n};
}
}
}
print qq{_("WinLangID");
_("Jan"), _("Feb"), _("Mar"), _("Apr"), _("May"), _("Jun"),

View File

@ -100,7 +100,7 @@ static bool is_valid_directory(const fs::path& dir)
std::error_code ec;
if (!fs::is_directory(dir, ec))
{
fmt::fprintf(cerr, "Path %s doesn't exist or isn't a directory", dir);
fmt::fprintf(cerr, _("Path %s doesn't exist or isn't a directory"), dir);
return false;
}
@ -1185,7 +1185,7 @@ void CelestiaCore::charEntered(const char *c_p, int modifiers)
switch (newPath)
{
case GLContext::GLPath_GLSL:
flash(_("Render path: OpenGL 2.0"));
flash(_("Render path: OpenGL 2.1"));
break;
}
context->setRenderPath(newPath);

View File

@ -27,7 +27,7 @@ BEGIN
VALUE "FileDescription", "Celestia QT - A real-time 3D space simulation"
VALUE "FileVersion", "1.7.0.0"
VALUE "InternalName", "Celestia QT"
VALUE "LegalCopyright", "Copyright 2001-2017, Celestia Development Team"
VALUE "LegalCopyright", "Copyright 2001-2021, Celestia Development Team"
VALUE "OriginalFilename", "Celestia QT.exe"
VALUE "PrivateBuild", ""
VALUE "ProductName", "Celestia QT"

View File

@ -1020,7 +1020,7 @@ void CelestiaAppWindow::slotShowAbout()
"NAIF kerners are %7<br>"
"Runtime Qt version: %6</p>"
"<p>Copyright (C) 2001-2020 by the Celestia Development Team.<br>"
"<p>Copyright (C) 2001-2021 by the Celestia Development Team.<br>"
"Celestia is free software. You can redistribute it and/or modify "
"it under the terms of the GNU General Public License as published "
"by the Free Software Foundation; either version 2 of the License, "

View File

@ -203,9 +203,9 @@ void InfoPanel::buildSolarSystemBodyPage(const Body* body,
}
if (body->getRings() != nullptr)
stream << _("<b>Has rings</b>") << "<br>\n";
stream << QString(_("<b>Has rings</b>")) << "<br>\n";
if (body->getAtmosphere() != nullptr)
stream << _("<b>Has atmosphere</b>") << "<br>\n";
stream << QString(_("<b>Has atmosphere</b>")) << "<br>\n";
// Start and end dates
double startTime = 0.0;
@ -318,9 +318,11 @@ void InfoPanel::buildDSOPage(const DeepSkyObject* dso,
sph = rectToSpherical(galPos);
astro::decimalToDegMinSec(radToDeg(sph.x()), degrees, minutes, seconds);
// TRANSLATORS: Galactic longitude
stream << QString(_("<b>L:</b> %L1%2 %L3' %L4\"")).arg(degrees).arg(QString::fromUtf8(UTF8_DEGREE_SIGN))
.arg(abs(minutes)).arg(abs(seconds)) << "<br>\n";
astro::decimalToDegMinSec(radToDeg(sph.y()), degrees, minutes, seconds);
// TRANSLATORS: Galactic latitude
stream << QString(_("<b>B:</b> %L1%2 %L3' %L4\"")).arg(degrees).arg(QString::fromUtf8(UTF8_DEGREE_SIGN))
.arg(abs(minutes)).arg(abs(seconds)) << "<br>\n";
}

View File

@ -159,7 +159,7 @@ bool ParseCommandLine()
{
if (isLastArg)
{
CommandLineError("Directory expected after --dir");
CommandLineError(_("Directory expected after --dir"));
return false;
}
i++;
@ -169,7 +169,7 @@ bool ParseCommandLine()
{
if (isLastArg)
{
CommandLineError("Configuration file name expected after --conf");
CommandLineError(_("Configuration file name expected after --conf"));
return false;
}
i++;
@ -180,7 +180,7 @@ bool ParseCommandLine()
{
if (isLastArg)
{
CommandLineError("Directory expected after --extrasdir");
CommandLineError(_("Directory expected after --extrasdir"));
return false;
}
i++;
@ -190,7 +190,7 @@ bool ParseCommandLine()
{
if (isLastArg)
{
CommandLineError("URL expected after --url");
CommandLineError(_("URL expected after --url"));
return false;
}
i++;
@ -204,7 +204,7 @@ bool ParseCommandLine()
{
if (isLastArg)
{
CommandLineError("A filename expected after --log/-l");
CommandLineError(_("A filename expected after --log/-l"));
return false;
}
i++;
@ -212,7 +212,7 @@ bool ParseCommandLine()
}
else
{
string buf = fmt::sprintf("Invalid command line option '%s'", args.at(i).toUtf8().data());
string buf = fmt::sprintf(_("Invalid command line option '%s'"), args.at(i).toUtf8().data());
CommandLineError(buf.c_str());
return false;
}

View File

@ -171,7 +171,7 @@ PreferencesDialog::PreferencesDialog(QWidget* parent, CelestiaCore* core) :
#ifdef USE_GLCONTEXT
if (glContext->renderPathSupported(GLContext::GLPath_GLSL))
ui.renderPathBox->addItem(_("OpenGL 2.0"), GLContext::GLPath_GLSL);
ui.renderPathBox->addItem(_("OpenGL 2.1"), GLContext::GLPath_GLSL);
SetComboBoxValue(ui.renderPathBox, renderPath);
#else

View File

@ -109,9 +109,9 @@ SelectionPopup::SelectionPopup(const Selection& sel,
else if (abs(distance) >= astro::kilometersToLightYears(10000000.0))
buff = fmt::sprintf("%.3f %s", astro::lightYearsToAU(distance), _("au"));
else if (abs(distance) > astro::kilometersToLightYears(1.0f))
buff = fmt::sprintf("%.3f km", astro::lightYearsToKilometers(distance));
buff = fmt::sprintf(_("%.3f km"), astro::lightYearsToKilometers(distance));
else
buff = fmt::sprintf("%.3f m", astro::lightYearsToKilometers(distance) * 1000.0f);
buff = fmt::sprintf(_("%.3f m"), astro::lightYearsToKilometers(distance) * 1000.0f);
addAction(italicTextItem(_("Distance: ") + QString::fromStdString(buff)));

View File

@ -12,6 +12,10 @@
#endif
#ifndef NC_
#define NC_(c, s) s
#endif
//
// Bitmap resources
//
@ -275,7 +279,7 @@ FONT 8, "Segoe UI", 0, 0, 0
DEFPUSHBUTTON "OK", IDOK, 131, 175, 50, 14, 0, WS_EX_LEFT
LTEXT "Celestia", IDC_STATIC, 56, 17, 30, 9, SS_LEFT, WS_EX_LEFT
LTEXT "1.7.0", IDC_STATIC, 90, 17, 40, 9, SS_LEFT, WS_EX_LEFT
LTEXT "Copyright (C) 2001-2019, Celestia Development Team", IDC_STATIC, 56, 26, 247, 9, SS_LEFT, WS_EX_LEFT
LTEXT "Copyright (C) 2001-2021, Celestia Development Team", IDC_STATIC, 56, 26, 247, 9, SS_LEFT, WS_EX_LEFT
LTEXT "https://celestia.space/", IDC_CELESTIALINK, 56, 43, 150, 9, SS_LEFT, WS_EX_LEFT
LTEXT "Celestia is free software and comes with absolutely no warranty.", IDC_STATIC, 56, 66, 247, 17, SS_LEFT, WS_EX_LEFT
LTEXT "Authors", IDC_STATIC, 56, 90, 100, 9, SS_LEFT, WS_EX_LEFT
@ -644,7 +648,7 @@ FONT 8, "Segoe UI", 0, 0, 0
AUTOCHECKBOX "Minor Moons", IDC_LABELMINORMOONS, 60, 72, 59, 10, 0, WS_EX_LEFT
AUTOCHECKBOX "Asteroids", IDC_LABELASTEROIDS, 60, 84, 60, 10, 0, WS_EX_LEFT
AUTOCHECKBOX "Comets", IDC_LABELCOMETS, 60, 96, 62, 10, 0, WS_EX_LEFT
AUTOCHECKBOX "Spacecraft", IDC_LABELSPACECRAFT, 60, 108, 59, 10, 0, WS_EX_LEFT
AUTOCHECKBOX NC_("plural", "Spacecraft"), IDC_LABELSPACECRAFT, 60, 108, 59, 10, 0, WS_EX_LEFT
AUTOCHECKBOX " ", IDC_STARORBITS, 42, 24, 14, 10, 0, WS_EX_LEFT
AUTOCHECKBOX " ", IDC_PLANETORBITS, 42, 36, 14, 10, 0, WS_EX_LEFT
AUTOCHECKBOX " ", IDC_DWARFPLANETORBITS, 42, 47, 14, 10, 0, WS_EX_LEFT
@ -759,7 +763,7 @@ VS_VERSION_INFO VERSIONINFO
VALUE "FileDescription", "Celestia - A real-time 3D space simulation"
VALUE "FileVersion", "1, 7, 0, 0"
VALUE "InternalName", "celestia"
VALUE "LegalCopyright", "Copyright 2001-2019, Celestia Development Team"
VALUE "LegalCopyright", "Copyright 2001-2021, Celestia Development Team"
VALUE "OriginalFilename", "celestia.exe"
VALUE "ProductName", "celestia"
VALUE "ProductVersion", "1, 7, 0, 0"

View File

@ -502,7 +502,7 @@ bool LoadItemTextFromFile(HWND hWnd,
if (!textFile.good())
{
SetDlgItemText(hWnd, item, "License file missing!\r\r\nSee http://www.gnu.org/copyleft/gpl.html");
SetDlgItemText(hWnd, item, _("License file missing!\nSee http://www.gnu.org/copyleft/gpl.html"));
return true;
}
@ -1455,7 +1455,8 @@ static HMENU CreatePlanetarySystemMenu(string parentName, const PlanetarySystem*
objects.push_back(planets);
menuNames.push_back(UTF8ToCurrentCP(_("Planets")));
objects.push_back(spacecraft);
menuNames.push_back(UTF8ToCurrentCP(_("Spacecraft")));
// TRANSLATORS: translate this as plural
menuNames.push_back(UTF8ToCurrentCP(C_("plural", "Spacecraft")));
// Now sort each vector and generate submenus
IntStrPairComparePredicate pred;
@ -1519,7 +1520,8 @@ static HMENU CreateAlternateSurfaceMenu(const vector<string>& surfaces)
{
HMENU menu = CreatePopupMenu();
AppendMenu(menu, MF_STRING, MENU_CHOOSE_SURFACE, "Normal");
// TRANSLATORS: normal texture in an alternative surface menu
AppendMenu(menu, MF_STRING, MENU_CHOOSE_SURFACE, _("Normal"));
for (unsigned int i = 0; i < surfaces.size(); i++)
{
AppendMenu(menu, MF_STRING, MENU_CHOOSE_SURFACE + i + 1,
@ -1722,8 +1724,8 @@ bool EnableFullScreen(const DEVMODE& dm)
DISP_CHANGE_SUCCESSFUL)
{
MessageBox(NULL,
"Unable to switch to full screen mode; running in window mode",
"Error",
_("Unable to switch to full screen mode; running in window mode"),
_("Error"),
MB_OK | MB_ICONERROR);
return false;
}
@ -1887,7 +1889,8 @@ HWND CreateOpenGLWindow(int x, int y, int width, int height,
if (RegisterClass(&wc) == 0)
{
MessageBox(NULL,
"Failed to register the window class.", "Fatal Error",
_("Failed to register the window class."),
_("Fatal Error"),
MB_OK | MB_ICONERROR);
return NULL;
}
@ -1937,7 +1940,8 @@ HWND CreateOpenGLWindow(int x, int y, int width, int height,
if (!SetDCPixelFormat(deviceContext))
{
MessageBox(NULL,
"Could not get appropriate pixel format for OpenGL rendering.", "Fatal Error",
_("Could not get appropriate pixel format for OpenGL rendering."),
_("Fatal Error"),
MB_OK | MB_ICONERROR);
return NULL;
}
@ -1960,8 +1964,8 @@ HWND CreateOpenGLWindow(int x, int y, int width, int height,
if (!gl::init(ignoreGLExtensions) || !gl::checkVersion(gl::GL_2_1))
{
MessageBox(NULL,
_("You system doesn't support OpenGL 2.1!"),
"Fatal Error",
_("Your system doesn't support OpenGL 2.1!"),
_("Fatal Error"),
MB_OK | MB_ICONERROR);
return NULL;
}
@ -1992,7 +1996,8 @@ void DestroyOpenGLWindow()
if (!ReleaseDC(mainWindow, deviceContext))
{
MessageBox(NULL,
"Releasing device context failed.", "Error",
_("Releasing device context failed."),
_("Error"),
MB_OK | MB_ICONERROR);
}
deviceContext = NULL;
@ -2262,7 +2267,7 @@ public:
MessageBox(NULL,
msg.c_str(),
"Fatal Error",
_("Fatal Error"),
MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
}
};
@ -2598,7 +2603,7 @@ static void HandleCaptureImage(HWND hWnd)
Ofn.lpstrInitialDir = (LPSTR)NULL;
// Comment this out if you just want the standard "Save As" caption.
Ofn.lpstrTitle = "Save As - Specify File to Capture Image";
Ofn.lpstrTitle = _("Save As - Specify File to Capture Image");
// OFN_HIDEREADONLY - Do not display read-only JPEG or PNG files
// OFN_OVERWRITEPROMPT - If user selected a file, prompt for overwrite confirmation.
@ -2632,7 +2637,7 @@ static void HandleCaptureImage(HWND hWnd)
{
MessageBox(hWnd,
_("Please use a name ending in '.jpg' or '.png'."),
"Error",
_("Error"),
MB_OK | MB_ICONERROR);
return;
}
@ -2641,7 +2646,10 @@ static void HandleCaptureImage(HWND hWnd)
appCore->draw();
if (!appCore->saveScreenShot(Ofn.lpstrFile))
{
MessageBox(hWnd, "Could not save image file.", "Error", MB_OK | MB_ICONERROR);
MessageBox(hWnd,
_("Could not save image file."),
_("Error"),
MB_OK | MB_ICONERROR);
}
}
}
@ -2655,7 +2663,10 @@ static void HandleCaptureMovie(HWND hWnd)
// is complete.
if (appCore->isCaptureActive())
{
MessageBox(hWnd, "Stop current movie capture before starting another one.", "Error", MB_OK | MB_ICONERROR);
MessageBox(hWnd,
_("Stop current movie capture before starting another one."),
_("Error"),
MB_OK | MB_ICONERROR);
return;
}
@ -2679,7 +2690,7 @@ static void HandleCaptureMovie(HWND hWnd)
Ofn.lpstrInitialDir = (LPSTR)NULL;
// Comment this out if you just want the standard "Save As" caption.
Ofn.lpstrTitle = "Save As - Specify Output File for Capture Movie";
Ofn.lpstrTitle = _("Save As - Specify Output File for Capture Movie");
// OFN_HIDEREADONLY - Do not display read-only video files
// OFN_OVERWRITEPROMPT - If user selected a file, prompt for overwrite confirmation.
@ -2746,14 +2757,14 @@ static void HandleCaptureMovie(HWND hWnd)
if (!success)
{
char errorMsg[64];
const char *errorMsg;
if (nFileType == 0)
sprintf(errorMsg, "Specified file extension is not recognized.");
errorMsg = _("Specified file extension is not recognized.");
else
sprintf(errorMsg, "Could not capture movie.");
errorMsg = _("Could not capture movie.");
MessageBox(hWnd, errorMsg, "Error", MB_OK | MB_ICONERROR);
MessageBox(hWnd, errorMsg, _("Error"), MB_OK | MB_ICONERROR);
}
}
}
@ -2978,7 +2989,8 @@ static bool parseCommandLine(int argc, char* argv[])
if (isLastArg)
{
MessageBox(NULL,
"Directory expected after --dir", "Celestia Command Line Error",
_("Directory expected after --dir"),
_("Celestia Command Line Error"),
MB_OK | MB_ICONERROR);
return false;
}
@ -2990,8 +3002,8 @@ static bool parseCommandLine(int argc, char* argv[])
if (isLastArg)
{
MessageBox(NULL,
"Configuration file name expected after --conf",
"Celestia Command Line Error",
_("Configuration file name expected after --conf"),
_("Celestia Command Line Error"),
MB_OK | MB_ICONERROR);
return false;
}
@ -3004,7 +3016,8 @@ static bool parseCommandLine(int argc, char* argv[])
if (isLastArg)
{
MessageBox(NULL,
"Directory expected after --extrasdir", "Celestia Command Line Error",
_("Directory expected after --extrasdir"),
_("Celestia Command Line Error"),
MB_OK | MB_ICONERROR);
return false;
}
@ -3016,7 +3029,8 @@ static bool parseCommandLine(int argc, char* argv[])
if (isLastArg)
{
MessageBox(NULL,
"URL expected after --url", "Celestia Command Line Error",
_("URL expected after --url"),
_("Celestia Command Line Error"),
MB_OK | MB_ICONERROR);
return false;
}
@ -3030,9 +3044,9 @@ static bool parseCommandLine(int argc, char* argv[])
else
{
char* buf = new char[strlen(argv[i]) + 256];
sprintf(buf, "Invalid command line option '%s'", argv[i]);
sprintf(buf, _("Invalid command line option '%s'"), argv[i]);
MessageBox(NULL,
buf, "Celestia Command Line Error",
buf, _("Celestia Command Line Error"),
MB_OK | MB_ICONERROR);
delete[] buf;
return false;
@ -3111,7 +3125,7 @@ int APIENTRY WinMain(HINSTANCE hInstance,
SetCurrentDirectory(startDirectory.c_str());
s_splash = new SplashWindow(SPLASH_DIR "\\" "splash.png");
s_splash->setMessage("Loading data files...");
s_splash->setMessage(_("Loading data files..."));
if (!skipSplashScreen)
s_splash->showSplash();
@ -3202,9 +3216,9 @@ int APIENTRY WinMain(HINSTANCE hInstance,
setlocale(LC_ALL, "");
setlocale(LC_NUMERIC, "C");
#ifdef ENABLE_NLS
bindtextdomain("celestia","locale");
bindtextdomain("celestia", "locale");
bind_textdomain_codeset("celestia", "UTF-8");
bindtextdomain("celestia_constellations","locale");
bindtextdomain("celestia_constellations", "locale");
bind_textdomain_codeset("celestia_constellations", "UTF-8");
textdomain("celestia");
@ -3252,8 +3266,8 @@ int APIENTRY WinMain(HINSTANCE hInstance,
if (appCore->getConfig() == NULL)
{
MessageBox(NULL,
"Configuration file missing!",
"Fatal Error",
_("Configuration file missing!"),
_("Fatal Error"),
MB_OK | MB_ICONERROR);
return 1;
}
@ -3325,8 +3339,8 @@ int APIENTRY WinMain(HINSTANCE hInstance,
if (hWnd == NULL)
{
MessageBox(NULL,
"Failed to create the application window.",
"Fatal Error",
_("Failed to create the application window."),
_("Fatal Error"),
MB_OK | MB_ICONERROR);
return FALSE;
}