Skip to main content
summaryrefslogtreecommitdiffstats
blob: 38681f913f723dfbedad8b4011e0438ab70a0164 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*******************************************************************************
 * Copyright (c) 2005, 2007 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

package org.eclipse.wst.ws.internal.explorer.platform.util;

import java.util.Locale;
import org.eclipse.core.runtime.Platform;

public final class DirUtils
{
  public static boolean isRTL()
  {
    return "rtl".equals(getDir());
  }

  public static String getDir()
  {
    String rtl = "rtl";
    String ltr = "ltr";

    // from system property
    String orientation = System.getProperty("eclipse.orientation"); //$NON-NLS-1$
    if (rtl.equals(orientation)) //$NON-NLS-1$
      return rtl;
    else if (ltr.equals(orientation)) //$NON-NLS-1$
      return ltr;

    // from command line
    String[] args = Platform.getCommandLineArgs();
    for (int i = 0; i < args.length; i++)
    {
      if ("-dir".equalsIgnoreCase(args[i])) //$NON-NLS-1$
      {
        if ((i + 1) < args.length && "rtl".equalsIgnoreCase(args[i + 1])) //$NON-NLS-1$
        {
          return rtl;
        }
        return ltr;
      }
    }

    // Check if the user property is set. If not do not
    // rely on the vm.
    if (System.getProperty("osgi.nl.user") == null) //$NON-NLS-1$
      return ltr;

    // guess from default locale
    String locale = Platform.getNL();
    if (locale == null)
    {
      locale = Locale.getDefault().toString();
    }
    if (locale.startsWith("ar") || locale.startsWith("fa") //$NON-NLS-1$//$NON-NLS-2$
        || locale.startsWith("he") || locale.startsWith("iw") //$NON-NLS-1$//$NON-NLS-2$
        || locale.startsWith("ur")) //$NON-NLS-1$
    {
      return rtl;
    }
    return ltr;
  }
}

Back to the top