2017-09-22 21:01 GMT+02:00 Klaus Tachtler <kl...@tachtler.net>: > Hi, > > thank you once again for your support, Łukasz and Adam! > > @Łukasz: you're absolutly right to say: > "I would rather pass a localised string to the bean (if possible), this > creates a dependency on Struts in non-Struts related bean" > > Depending on that I ONLY want to use the same resource bundle as struts, so > i decided to do it that way... > > public class FileReader { > > private static Locale locale = null; > private static ResourceBundle resourceBundle = null; > > public static BrowscapBean determineBrowscapFileReader(String > userAgentString) { > > locale = ActionContext.getContext().getLocale(); > resourceBundle = > ResourceBundle.getBundle(Globals.RESOURCE_BUNDLE_GLOBAL, locale); > > /* > * Get the i18n text for "string" from ActionContext. > */ > String i18nString = > resourceBundle.getString("global.unknown"); > > myBean.setPropertyName(i18nString); > > ... > > } > }
You can always use container to fetch the current instance of LocalizedTextProvider (ancesor of the LocalizedTextUtil): LocalizedTextProvider ltp = ActionContext.getContext().getInstance(LocalizedTextProvider.class); String i18nstring = ltp.findDefaultText("global.unknown", ActionContext.getContext().getLocale()); Regards -- Łukasz + 48 606 323 122 http://www.lenart.org.pl/ --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org