Ignore:
Timestamp:
2014-07-12T16:48:46+02:00 (10 years ago)
Author:
Don-vip
Message:

fix #10239 - proper display of bidirectional texts (osm primitives with RTL names)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/DefaultNameFormatter.java

    r7187 r7305  
    77import static org.openstreetmap.josm.tools.I18n.trn;
    88
     9import java.awt.ComponentOrientation;
    910import java.util.ArrayList;
    1011import java.util.Arrays;
     
    1516import java.util.LinkedList;
    1617import java.util.List;
     18import java.util.Locale;
    1719import java.util.Map;
    1820import java.util.Set;
     
    220222    public String format(Way way) {
    221223        StringBuilder name = new StringBuilder();
     224
     225        char mark = 0;
     226        // If current language is left-to-right (almost all languages)
     227        if (ComponentOrientation.getOrientation(Locale.getDefault()).isLeftToRight()) {
     228            // will insert Left-To-Right Mark to ensure proper display of text in the case when object name is right-to-left
     229            mark = '\u200E';
     230        } else {
     231            // otherwise will insert Right-To-Left Mark to ensure proper display in the opposite case
     232            mark = '\u200F';
     233        }
     234        // Initialize base direction of the string
     235        name.append(mark);
     236
    222237        if (way.isIncomplete()) {
    223238            name.append(tr("incomplete"));
     
    235250                }
    236251                if (n == null) {
    237                     n =
    238                             (way.get("highway") != null) ? tr("highway") :
     252                    n =     (way.get("highway") != null) ? tr("highway") :
    239253                                (way.get("railway") != null) ? tr("railway") :
    240254                                    (way.get("waterway") != null) ? tr("waterway") :
    241255                                            (way.get("landuse") != null) ? tr("landuse") : null;
    242256                }
    243                 if(n == null)
    244                 {
     257                if (n == null) {
    245258                    String s;
    246259                    if((s = way.get("addr:housename")) != null) {
     
    276289            /* I18n: count of nodes as parameter */
    277290            String nodes = trn("{0} node", "{0} nodes", nodesNo, nodesNo);
    278             name.append(" (").append(nodes).append(")");
     291            name.append(mark).append(" (").append(nodes).append(")");
    279292        }
    280293        decorateNameWithId(name, way);
Note: See TracChangeset for help on using the changeset viewer.