Java: detect language RTL in a Spring web application without using AWT component? -
i doing spring web application.
i have access locale , need whether rtl (right-to-left).
i found post:
is there way detect rtl language in java?
it appears can solve problem. however, solution there:
componentorientation.getorientation(new locale(system.getproperty("user.language"))).islefttoright();
uses java awt's componenent (componentorientation).
i wondering whether can rtl info locale without using awt components.
thanks help!
best.
you check if locale's .getlanguage()
1 of right-to-left languages (hebrew, arabic, etc). how function implemented in awt.
public static componentorientation getorientation(locale locale) { // more flexible implementation consult resourcebundle // find appropriate orientation. until pluggable locales // introduced however, flexiblity isn't needed. // choose efficiency instead. string lang = locale.getlanguage(); if( "iw".equals(lang) || "ar".equals(lang) || "fa".equals(lang) || "ur".equals(lang) ) { return right_to_left; } else { return left_to_right; } }
Comments
Post a Comment