You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package com.fr.base.i18n;
|
|
|
|
|
|
|
|
import java.awt.Component;
|
|
|
|
import java.awt.ComponentOrientation;
|
|
|
|
import java.util.Locale;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 根据国际化获取组件方向
|
|
|
|
*
|
|
|
|
* @author obo
|
|
|
|
* @since 11.0
|
|
|
|
* Created on 2024/07/17
|
|
|
|
*/
|
|
|
|
public class BidiUtils {
|
|
|
|
|
|
|
|
private static final Locale ar = new Locale("ar", "SA");
|
|
|
|
private static final Locale cn = Locale.CHINA;
|
|
|
|
|
|
|
|
private BidiUtils() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public static ComponentOrientation getOrientationByLocale() {
|
|
|
|
return ComponentOrientation.getOrientation(ar);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static <T extends Component> T applyOrientationByLocale(T component) {
|
|
|
|
component.applyComponentOrientation(ComponentOrientation.getOrientation(ar));
|
|
|
|
return component;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void applyOrientationByLocale(Component... components) {
|
|
|
|
for (Component component : components) {
|
|
|
|
component.applyComponentOrientation(ComponentOrientation.getOrientation(ar));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean rtl() {
|
|
|
|
return ComponentOrientation.getOrientation(ar) == ComponentOrientation.RIGHT_TO_LEFT;
|
|
|
|
}
|
|
|
|
}
|