@@ -977,7 +977,11 @@ QString StelSkyCultureMgr::createCulturalLabel(const StelObject::CulturalName &c
977977 const QString &commonNameI18n,
978978 const QString &abbrevI18n) const
979979{
980- // Each element may be in an RTL language (e.g. Arab). However, we want a canonical order of left to right elements.
980+ // rtl tracks the right-to-left status of the text in the current position.
981+ const bool rtl = StelApp::getInstance ().getLocaleMgr ().isSkyRTL ();
982+ // Each element may be in an RTL language (e.g. Arab). However,
983+ // - for most (left-to-right) languages we want a canonical order of left to right elements.
984+ // - for Arab and other right-to-left user languages, we set a canonical order of right-to-left elements.
981985 // This requires building Unicode isolation cells.
982986 // Unicode constants from Unicode Standard Annex #9, section 2.
983987 // static const QString LRE{"\u202a"}; // Left-to-right embedding: Treat following text as embedded left-to-right
@@ -1082,11 +1086,24 @@ QString StelSkyCultureMgr::createCulturalLabel(const StelObject::CulturalName &c
10821086 braced.removeOne (QString ());
10831087 braced.removeOne (label); // avoid repeating the main thing if it was used as fallback!
10841088
1085- if (!braced.isEmpty ()) label.append (QString (" %1%3%2" ).arg (QChar (0x2997 ), QChar (0x2998 ), braced.join (" , " )));
1089+ if (!braced.isEmpty ())
1090+ {
1091+ QString pronTrans=QString (" %1%3%2" ).arg (QChar (0x2997 ), QChar (0x2998 ), braced.join (" , " ));
1092+ if (rtl)
1093+ label.prepend (pronTrans);
1094+ else
1095+ label.append (pronTrans);
1096+ }
10861097
10871098 // Add IPA (where possible)
10881099 if ((styleInt & int (StelObject::CulturalDisplayStyle::IPA)) && (!lName.IPA .isEmpty ()) && (label != lName.IPA ))
1089- label.append (QString (" [%1]" ).arg (lName.IPA ));
1100+ {
1101+ QString ipa=QString (" [%1]" ).arg (lName.IPA );
1102+ if (rtl)
1103+ label.prepend (ipa);
1104+ else
1105+ label.append (ipa);
1106+ }
10901107
10911108 // Add translation and optional byname in brackets
10921109
@@ -1104,12 +1121,24 @@ QString StelSkyCultureMgr::createCulturalLabel(const StelObject::CulturalName &c
11041121 if ( (styleInt & int (StelObject::CulturalDisplayStyle::Byname)) && (!lName.bynameI18n .isEmpty ()))
11051122 bracketed.append (lName.bynameI18n );
11061123 if (!bracketed.isEmpty ())
1107- label.append (QString (" (%1)" ).arg (bracketed.join (" , " )));
1124+ {
1125+ QString transBy=QString (" (%1)" ).arg (bracketed.join (" , " ));
1126+ if (rtl)
1127+ label.prepend (transBy);
1128+ else
1129+ label.append (transBy);
1130+ }
11081131
11091132
11101133 // Add an explanatory modern name in decorative angle brackets
11111134 if ((styleInt & int (StelObject::CulturalDisplayStyle::Modern)) && (!commonNameI18n.isEmpty ()) && (!label.startsWith (lCommonNameI18n)) && (lCommonNameI18n!=lName.translatedI18n ))
1112- label.append (QString (" %1%3%2" ).arg (QChar (0x29FC ), QChar (0x29FD ), lCommonNameI18n));
1135+ {
1136+ QString modern=QString (" %1%3%2" ).arg (QChar (0x29FC ), QChar (0x29FD ), lCommonNameI18n);
1137+ if (rtl)
1138+ label.prepend (modern);
1139+ else
1140+ label.append (modern);
1141+ }
11131142 if ((styleInt & int (StelObject::CulturalDisplayStyle::Modern)) && label.isEmpty ()) // if something went wrong?
11141143 label=lCommonNameI18n;
11151144
0 commit comments