Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Display level name and author translations

Enable translation of level names and authors. This involves
1) extracting the strings from default.xml, and
2) wrapping them in i18n() within the code.

Messages.sh changes suggested by Yuri Chornoivan.
  • Loading branch information...
commit 508ed86bf7ae40dfe3b62db97890ef29c30ea57d 1 parent bb32937
@schuay authored
View
2  Messages.sh
@@ -1,5 +1,7 @@
#!bin/sh
+# extract level names for translation
+$EXTRACTATTR --attr=board,name --attr=board,author levels/default.xml >> rc.cpp
# invoke the extractrc script on all .ui, .rc, and .kcfg files in the sources
# the results are stored in a pseudo .cpp file to be picked up by xgettext.
$EXTRACTRC `find . -name \*.rc -o -name \*.ui -o -name \*.kcfg` >> rc.cpp
View
2  levels/default.xml
@@ -1,3 +1,5 @@
+<?xml version="1.0"?>
+
<picmi name="Default">
<board name="Baby Chick" author="Moni Linke" difficulty="5">
View
11 src/logic/levelloader.cpp
@@ -25,6 +25,7 @@
#include <QFile>
#include <QSettings>
#include <kglobal.h>
+#include <klocale.h>
#include <kstandarddirs.h>
#include "src/systemexception.h"
@@ -67,6 +68,16 @@ QString Level::visibleName() const
return QString(name().length(), QChar(0x26AB));
}
+QString Level::name() const {
+ QByteArray bytes = m_name.toUtf8();
+ return i18n(bytes.constData());
+}
+
+QString Level::author() const {
+ QByteArray bytes = m_author.toUtf8();
+ return i18n(bytes.constData());
+}
+
QString Level::key() const {
return QString("preset_scores/%1_%2").arg(m_levelset, m_name);
}
View
4 src/logic/levelloader.h
@@ -37,8 +37,8 @@ class Level
public:
Level();
- QString name() const { return m_name; }
- QString author() const { return m_author; }
+ QString name() const;
+ QString author() const;
QString levelset() const { return m_levelset; }
int difficulty() const { return m_difficulty; }
int width() const { return m_width; }
Please sign in to comment.
Something went wrong with that request. Please try again.