[Kstars-devel] KDE/kdeedu/kstars/kstars

Akarsh Simha akarshsimha at gmail.com
Fri Dec 26 11:14:46 CET 2008


SVN commit 901615 by asimha:

Positions of planets in localized versions were not correct because
KStars was looking for orbit data files using the localized names of
planets, whereas the data files' names are not to be localized.

This commit fixes that temporarily by introducing an ugly
KSPlanet::untranslatedName() which returns the non-localized name.

The real way to fix this is to change the way KStars handles localized
object names, which should be done post KDE 4.2 release.

CCMAIL: kstars-devel at kde.org



 M  +23 -3     ksplanet.cpp  
 M  +6 -0      ksplanet.h  


--- trunk/KDE/kdeedu/kstars/kstars/ksplanet.cpp #901614:901615
@@ -121,7 +121,7 @@
     : KSPlanetBase(kd) {
     switch ( n ) {
         case MERCURY:
-					KSPlanetBase::init( i18n("Mercury"), "mercury.png", KSPlanetBase::planetColor[KSPlanetBase::MERCURY], 4879.4 );
+            KSPlanetBase::init( i18n("Mercury"), "mercury.png", KSPlanetBase::planetColor[KSPlanetBase::MERCURY], 4879.4 );
             break;
         case VENUS:
             KSPlanetBase::init( i18n("Venus"), "venus.png", KSPlanetBase::planetColor[KSPlanetBase::VENUS], 12103.6 );
@@ -147,10 +147,30 @@
     }
 }
 
+// TODO: Get rid of this dirty hack post KDE 4.2 release
+QString KSPlanet::untranslatedName() const {
+    if( name() == i18n( "Mercury" ) )
+        return "Mercury";
+    else if( name() == i18n( "Venus" ) )
+        return "Venus";
+    else if( name() == i18n( "Mars" ) )
+        return "Mars";
+    else if( name() == i18n( "Jupiter" ) )
+        return "Jupiter";
+    else if( name() == i18n( "Saturn" ) )
+        return "Saturn";
+    else if( name() == i18n( "Uranus" ) )
+        return "Uranus";
+    else if( name() == i18n( "Neptune" ) )
+        return "Neptune";
+    else
+        return name();
+}
+
 //we don't need the reference to the ODC, so just give it a junk variable
 bool KSPlanet::loadData() {
     OrbitDataColl odc;
-    return odm.loadData( odc, name() );
+    return odm.loadData( odc, untranslatedName() );
 }
 
 void KSPlanet::calcEcliptic(double Tau, EclipticPosition &epret) const {
@@ -163,7 +183,7 @@
         Tpow[i] = Tpow[i-1] * Tau;
     }
 
-    if ( ! odm.loadData( odc, name() ) ) {
+    if ( ! odm.loadData( odc, untranslatedName() ) ) {
         epret.longitude = 0.0;
         epret.latitude = 0.0;
         epret.radius = 0.0;
--- trunk/KDE/kdeedu/kstars/kstars/ksplanet.h #901614:901615
@@ -65,6 +65,12 @@
      */
     virtual ~KSPlanet() {}
 
+    /**@short return the untranslated name
+     *This is a dirty way to solve a lot of localization-related trouble for the KDE 4.2 release
+     *TODO: Change the whole architecture for names later
+     */
+    QString untranslatedName( void ) const;
+
     /**@short Preload the data used by findPosition.
     	*/
     virtual bool loadData();


More information about the Kstars-devel mailing list