Wed, 03 Jul 2013 00:43:27 +0300
Apply tr() for possible future translations
src/aboutDialog.cpp | file | annotate | diff | comparison | revisions | |
src/colors.cpp | file | annotate | diff | comparison | revisions | |
src/common.h | file | annotate | diff | comparison | revisions | |
src/config.cpp | file | annotate | diff | comparison | revisions | |
src/file.cpp | file | annotate | diff | comparison | revisions | |
src/gldraw.cpp | file | annotate | diff | comparison | revisions | |
src/gui.cpp | file | annotate | diff | comparison | revisions | |
src/gui_editactions.cpp | file | annotate | diff | comparison | revisions | |
src/historyDialog.cpp | file | annotate | diff | comparison | revisions | |
src/primitives.cpp | file | annotate | diff | comparison | revisions |
--- a/src/aboutDialog.cpp Tue Jul 02 23:40:27 2013 +0300 +++ b/src/aboutDialog.cpp Wed Jul 03 00:43:27 2013 +0300 @@ -32,12 +32,11 @@ icon->setPixmap (getIcon ("ldforge")); // Heading - application label and copyright information - QLabel* title = new QLabel (fmt ("<b>" APPNAME " %1</b><br />" - "Copyright (C) 2013 Santeri Piippo", - qchars (fullVersionString ()))); + QLabel* title = new QLabel( fmt( tr( "<b>" APPNAME " %1</b><br />" + "Copyright (C) 2013 Santeri Piippo" ), fullVersionString ())); // Body text - QLabel* info = new QLabel ( + QLabel* info = new QLabel (tr ( "<p>This software is intended for usage as a parts<br />" "authoring tool for the <a href=\"http://ldraw.org/\">LDraw</a> parts library.</p>" @@ -53,10 +52,10 @@ "The application icon is derived from <a href=\"http://en.wikipedia.org/wiki/File:Anvil,_labelled_en.svg\">this image</a>. The<br />" "linked image (retrieved 22 May 2013) was released<br />" "into the public domain.</p>" - ); + )); // Rest in peace, James. - QLabel* memorial = new QLabel ("In living memory of James Jessiman."); + QLabel* memorial = new QLabel( tr( "In living memory of James Jessiman." )); QDialogButtonBox* buttons = new QDialogButtonBox (QDialogButtonBox::Close); QPushButton* helpButton = new QPushButton;
--- a/src/colors.cpp Tue Jul 02 23:40:27 2013 +0300 +++ b/src/colors.cpp Wed Jul 03 00:43:27 2013 +0300 @@ -80,14 +80,16 @@ void parseLDConfig () { File* f = openLDrawFile ("LDConfig.ldr", false); - if (!*f) { - critical (fmt ("Unable to open LDConfig.ldr for parsing! (%1)", strerror (errno))); + if ( !f ) + { + critical( fmt( QObject::tr( "Unable to open LDConfig.ldr for parsing! (%1)" ), strerror( errno ))); delete f; return; } // Read in the lines - for (str line : *f) { + for( str line : *f ) + { if (line.length () == 0 || line[0] != '0') continue; // empty or illogical
--- a/src/common.h Tue Jul 02 23:40:27 2013 +0300 +++ b/src/common.h Wed Jul 03 00:43:27 2013 +0300 @@ -46,11 +46,11 @@ #define RELEASE #endif // BUILD_ID -#define BUILD_INTERNAL 0 -#define BUILD_ALPHA 1 -#define BUILD_BETA 2 -#define BUILD_RC 3 -#define BUILD_RELEASE 4 +#define BUILD_INTERNAL 0 +#define BUILD_ALPHA 1 +#define BUILD_BETA 2 +#define BUILD_RC 3 +#define BUILD_RELEASE 4 #ifndef RELEASE # define devf(...) doDevf (__func__, __VA_ARGS__); @@ -59,6 +59,7 @@ #endif // RELEASE #define elif else if +#define G_TR QObject::tr extern File g_file_stdout; extern File g_file_stderr;
--- a/src/config.cpp Tue Jul 02 23:40:27 2013 +0300 +++ b/src/config.cpp Wed Jul 03 00:43:27 2013 +0300 @@ -28,15 +28,6 @@ config* g_configPointers[MAX_CONFIG]; static ushort g_cfgPointerCursor = 0; -static const char* g_ConfigTypeNames[] = { - "None", - "Integer", - "String", - "Float", - "Boolean", - "Key sequence", -}; - // ============================================================================= // Load the configuration from file bool config::load () { @@ -143,7 +134,8 @@ print ("writing cfg to %1\n", filepath ()); if (!f) { - critical (fmt ("Cannot save configuration, cannot open %1 for writing\n", filepath ())); + critical( fmt( QObject::tr( "Cannot save configuration, cannot open %1 for writing: %2\n" ), + filepath(), strerror( errno ))); return false; }
--- a/src/file.cpp Tue Jul 02 23:40:27 2013 +0300 +++ b/src/file.cpp Wed Jul 03 00:43:27 2013 +0300 @@ -354,7 +354,6 @@ ulong numWarnings; bool ok; vector<LDObject*> objs = loadFileContents( f, &numWarnings, &ok ); - print( "ok: %1\n", ok ); if( !ok ) { @@ -411,7 +410,7 @@ } if( !save () ) { - message = fmt( "Failed to save %1: %2\nDo you still want to close?", + message = fmt( QObject::tr( "Failed to save %1: %2\nDo you still want to close?" ), name(), strerror( errno )); if( QMessageBox::critical( g_win, "Save Failure", message, @@ -529,7 +528,7 @@ { // Tell the user loading failed. setlocale( LC_ALL, "C" ); - critical( fmt( "Failed to open %1: %2", path, strerror( errno ))); + critical( fmt( QObject::tr( "Failed to open %1: %2" ), path, strerror( errno ))); } g_loadingMainFile = false;
--- a/src/gldraw.cpp Tue Jul 02 23:40:27 2013 +0300 +++ b/src/gldraw.cpp Wed Jul 03 00:43:27 2013 +0300 @@ -59,7 +59,16 @@ cfg (bool, gl_axes, false); cfg (bool, gl_wireframe, false); -const char* g_CameraNames[7] = { "Top", "Front", "Left", "Bottom", "Back", "Right", "Free" }; +// argh +const char* g_CameraNames[7] = { + QT_TRANSLATE_NOOP( "GLRenderer", "Top" ), + QT_TRANSLATE_NOOP( "GLRenderer", "Front" ), + QT_TRANSLATE_NOOP( "GLRenderer", "Left" ), + QT_TRANSLATE_NOOP( "GLRenderer", "Bottom" ), + QT_TRANSLATE_NOOP( "GLRenderer", "Back" ), + QT_TRANSLATE_NOOP( "GLRenderer", "Right" ), + QT_TRANSLATE_NOOP( "GLRenderer", "Free" ) +}; const GL::Camera g_Cameras[7] = { GL::Top, @@ -104,7 +113,7 @@ // Init camera icons for (const GL::Camera cam : g_Cameras) { - str iconname = fmt ("camera-%1", str (g_CameraNames[cam]).toLower ()); + str iconname = fmt ("camera-%1", tr (g_CameraNames[cam]).toLower ()); CameraIcon* info = &m_cameraIcons[cam]; info->img = new QPixmap (getIcon (iconname)); @@ -495,7 +504,7 @@ } // Paint the coordinates onto the screen. - str text = fmt ("X: %1, Y: %2, Z: %3", m_hoverpos[X], m_hoverpos[Y], m_hoverpos[Z]); + str text = fmt( tr( "X: %1, Y: %2, Z: %3" ), m_hoverpos[X], m_hoverpos[Y], m_hoverpos[Z] ); QFontMetrics metrics = QFontMetrics (font ()); QRect textSize = metrics.boundingRect (0, 0, m_width, m_height, Qt::AlignCenter, text); @@ -586,12 +595,14 @@ paint.drawPixmap (info.destRect, *info.img, info.srcRect); } + str fmtstr = tr( "%1 Camera" ); + // Draw a label for the current camera in the top left corner { const ushort margin = 4; str label; - label = fmt ("%1 Camera", g_CameraNames[camera ()]); + label = fmt( fmtstr, tr( g_CameraNames[camera ()] )); paint.setPen (m_darkbg ? Qt::white : Qt::black); paint.drawText (QPoint (margin, margin + metrics.ascent ()), label); } @@ -608,7 +619,7 @@ ushort x0 = m_pos.x (), y0 = m_pos.y (); - str label = fmt ("%1 Camera", g_CameraNames[m_toolTipCamera]); + str label = fmt( fmtstr, tr( g_CameraNames[m_toolTipCamera] )); const ushort textWidth = metrics.width (label), textHeight = metrics.height (), @@ -1374,7 +1385,7 @@ if( img->isNull() ) { - critical ("Failed to load overlay image!"); + critical( tr( "Failed to load overlay image!" )); delete img; return false; }
--- a/src/gui.cpp Tue Jul 02 23:40:27 2013 +0300 +++ b/src/gui.cpp Wed Jul 03 00:43:27 2013 +0300 @@ -1016,7 +1016,7 @@ connect (hidetimer, SIGNAL (timeout ()), m_primLoaderWidget, SLOT (hide ())); hidetimer->setSingleShot (true); hidetimer->start (1500); - m_primLoaderBar->setFormat ("Done"); + m_primLoaderBar->setFormat( tr( "Done" )); } // ============================================================================= @@ -1027,8 +1027,8 @@ str path = f->name (); if (path.length () == 0 || saveAs) { - path = QFileDialog::getSaveFileName (g_win, "Save As", - g_curfile->name (), "LDraw files (*.dat *.ldr)"); + path = QFileDialog::getSaveFileName (g_win, tr( "Save As" ), + g_curfile->name (), tr( "LDraw files (*.dat *.ldr)" )); if (path.length () == 0) { // User didn't give a file name. This happens if the user cancelled @@ -1048,14 +1048,14 @@ { setlocale( LC_ALL, "C" ); - str message = fmt ("Failed to save to %1\nReason: %2", path, strerror (errno)); + str message = fmt( tr( "Failed to save to %1: %2" ), path, strerror (errno)); // Tell the user the save failed, and give the option for saving as with it. - QMessageBox dlg( QMessageBox::Critical, "Save Failure", message, + QMessageBox dlg( QMessageBox::Critical, tr( "Save Failure" ), message, QMessageBox::Close, g_win ); // Add a save-as button - QPushButton* saveAsBtn = new QPushButton( "Save As" ); + QPushButton* saveAsBtn = new QPushButton( tr( "Save As" )); saveAsBtn->setIcon( getIcon( "file-save-as" )); dlg.addButton( saveAsBtn, QMessageBox::ActionRole ); dlg.setDefaultButton( QMessageBox::Close ); @@ -1090,7 +1090,7 @@ // ============================================================================= void critical (str msg) { - QMessageBox::critical (g_win, "Error", msg, + QMessageBox::critical (g_win, QObject::tr( "Error" ), msg, (QMessageBox::Close), QMessageBox::Close); }
--- a/src/gui_editactions.cpp Tue Jul 02 23:40:27 2013 +0300 +++ b/src/gui_editactions.cpp Wed Jul 03 00:43:27 2013 +0300 @@ -626,7 +626,8 @@ colnum++; if (colnum >= 512) { - critical ("Out of unused colors! What are you doing?!"); + //: Auto-colorer error message + critical( QObject::tr( "Out of unused colors! What are you doing?!" )); return; }
--- a/src/historyDialog.cpp Tue Jul 02 23:40:27 2013 +0300 +++ b/src/historyDialog.cpp Wed Jul 03 00:43:27 2013 +0300 @@ -18,6 +18,7 @@ #include <qboxlayout.h> #include <qmessagebox.h> +#include <QGridLayout> #include "historyDialog.h" #include "history.h" #include "colors.h"
--- a/src/primitives.cpp Tue Jul 02 23:40:27 2013 +0300 +++ b/src/primitives.cpp Wed Jul 03 00:43:27 2013 +0300 @@ -31,6 +31,8 @@ static bool g_primListerMutex = false; vector<Primitive> g_primitives; +static const str g_Other = QObject::tr( "Other" ); + static void populateCategories (); static void loadPrimitiveCatgories (); @@ -166,13 +168,12 @@ for (PrimitiveCategory& cat : g_PrimitiveCategories) cat.prims.clear (); - PrimitiveCategory* unmatched = findCategory ("Other"); + PrimitiveCategory* unmatched = findCategory( g_Other ); if (!unmatched) { // Shouldn't happen.. but catch it anyway. - print ("No `Other` category found! Creating one...\n"); PrimitiveCategory cat; - cat.setName ("Other"); + cat.setName( g_Other ); unmatched = &(g_PrimitiveCategories << cat); } @@ -227,7 +228,7 @@ f.open (":/data/primitive-categories.cfg", File::Read); if (!f) - critical ("Failed to open primitive categories!"); + critical( QObject::tr( "Failed to open primitive categories!" )); if (f) { PrimitiveCategory cat; @@ -268,7 +269,7 @@ // Add a category for unmatched primitives PrimitiveCategory cat; - cat.setName ("Other"); + cat.setName( g_Other ); g_PrimitiveCategories << cat; } @@ -398,6 +399,7 @@ str primitiveTypeName( PrimitiveType type ) { + // Not translated as primitives are in English. return type == Circle ? "Circle" : type == Cylinder ? "Cylinder" : type == Disc ? "Disc" :