Change language at runtime

Hi there,
I have a rather difficult question I think.
I work with jsp and struts and I want my users to change the language of the content by clicking on a button.
I have the following method in my action:
public ActionForward execute(ActionMapping mapping,ActionForm form,     HttpServletRequest request,     HttpServletResponse response)
                                        throws Exception {
          HttpSession session= request.getSession();          
          System.out.println(request.getLocale().getLanguage()+" bla");          
          Locale locale = (Locale) session.getAttribute(Globals.LOCALE_KEY);
          System.out.println(locale.getCountry()+" "+locale.getLanguage());                         
          String language=request.getParameter("language");                         
          locale = new Locale(language);          
          session.setAttribute(Globals.LOCALE_KEY, locale);          
          Config.set(session, Config.FMT_LOCALE, locale);
          return new ActionForward("/pm_main.jsp");     
Why doesn't this work?
I just want to change the users locale, so the site gets his resources from the new resources.properties file...
I hope someone knows where I'm getting at!
Thanks

You are replacing Globals.LOCALE_KEY in the session. You are doing this in the execute method of the action. But execute is not really the first thing that happens, nor the last, in the process of receiving the request and sending the response. So if Struts for some reason sets this value in the session after execute (I'm not sure why it would) then it would overwrite whatever you put there.

Similar Messages

  • Change Language in runtime ( in the portal)

    Hi ,
    We use the personalize to change the language ,
    most of the WD application translate to 2 languages...
    When we change the languages all the menus(roles)  translated to the chosen language..except the application ( xlf files ) .
    We need to close the browser , open new one and gust then we see the translations....
    How i see the translation without closing the browser ???
    Thanks

    Faniel,
    Please read my answer to similar question:
    Re: Urgent: Internationalization
    Valery Silaev
    SaM Solutions
    http://www.sam-solutions.net

  • Change language during Runtime

    Hey,
    i have following problem: I use Resourcebundles to internationalize my Java Applet. Now i want to add two Buttons where the user can change the language.
    I changed my i18n class to the following code:
    public class Messages
         private static final String          BUNDLE_NAME     = "de.mypackage.core.messages";     //$NON-NLS-1$
         private static ResourceBundle     resBundle     = null;
         static
              try
                   resBundle = ResourceBundle.getBundle(BUNDLE_NAME);
              } catch (MissingResourceException exc)
                   System.out.println("Can not find the ressource bundle for i18n.");
         static void setLocale(Locale locale)
              resBundle = ResourceBundle.getBundle(BUNDLE_NAME, locale);
         public static String getString(String key)
              try
                   return resBundle.getString(key);
              } catch (MissingResourceException e)
                   return '!' + key + '!';
    }When pressing the "english" button following code is executed:
    Messages.setLocale(Locale.ENGLISH);
    applet.repaint();
    applet.validate();But the language doesn�t change :-( What can i do?
    Thanks alot

    But the language doesn�t change :-( What can i do?I once did it this way: the problem is that all your Components already
    had their text set (e.g. JButton.setText(...)) and all those components are
    not aware of the fact that you changed your Locale so they don't do
    anything.
    Therefore I extended all these Swing classes and added an interface:
    LanguageListener which gets invoked when a Locale has changed.
    The Language listener just extends the PropertyChangeListener.
    When the method is invoked the Component sets its text again according
    to the now current Locale. It's a bit of work but it pays off ;-)
    kind regards,
    Jos

  • Change to the runtime the logon language with ABAP

    Hello,
    I have a  question.
    Is it possible to change to the runtime the logon language?
    With the URL-parameter example it worked.
    http://www.****bsp/sap/z_page/default.htm?sap-language=en
    But I need this in the event handler with ABAP coding.
    thanks Eren

    you can either use
    CL_HTTP_UTILITY->IF_HTTP_UTILITY~SET_REQUEST_URI
    uri = sap-language=FR
    or
    CL_HTTP_REQUEST->IF_HTTP_ENTITY~SET_FORM_FIELD
    name = sap-client
    value = FR
    or
    use
    SET LOCALE LANGUAGE 'S'. within your abap coding
    Regards
    Raja

  • Localization and change language action

    Hi, I am facing the following problem... I wish to provide a web application with the option of changing the language. I have included two bundle.properties files (bundle_en and bundle_el) and both of them work fine when changing the default language in by browser. However I cannot change the language at runtime with a command button i have added. This is the relevant code..
    faces-config.xml
    <application>
    <message-bundle>javaserverfaces/Bundle</message-bundle>
    <locale-config>
    <default-locale>en</default-locale>
    <supported-locale>en</supported-locale>
    <supported-locale>el</supported-locale>
    </locale-config>
    </application>
    <managed-bean>
    <display-name>LanguageSelect</display-name>
    <managed-bean-name>LanguageSelect</managed-bean-name>
    <managed-bean-class>org.netbeans.javaserverfaces.LanguageSelect</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    header.jsp
    <h:commandButton value="#{msg.LanguageButton}" styleClass="language-select-button" actionListener="#{LanguageSelect.changeLanguage}"/>
    LanguageSelect.java
    public class LanguageSelect implements ActionListener {
    /** Creates a new instance of LanguageSelect */
    public LanguageSelect() {
    public void changeLanguage(ActionEvent event) {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    Locale locele = (Locale) facesContext.getViewRoot().getLocale();
    System.out.println("setting locale to English");
    facesContext.getViewRoot().setLocale(new Locale("en"));
    String viewId = facesContext.getViewRoot().getViewId();
    int lastSlash = viewId.lastIndexOf("/");
    try {
    facesContext.getExternalContext().redirect(viewId.substring(lastSlash+1));
    } catch (IOException ex) {
    ex.printStackTrace();
    System.out.println("locale set to English");
    public void actionPerformed(java.awt.event.ActionEvent e) {    }
    Any help would be appreciated, thanks...

    I think it's this answer comes late for you, but If anyone it's interested, we use (in version 10.1.4) this function:
    PORTAL.wwctx_app_language.set_language(p_http_language => 'es-es',
                                                           p_nls_language => PORTAL.wwnls_api.SPANISH,
                                                           p_nls_territory => PORTAL.wwnls_api.TER_SPAIN,
                                                           p_requested_url => url);
    Where 'url' is the url you want to come back.
    Remember you can call any function/procedure by the url: /portal/pls/porta/squema.name_of_the_proc, where you have to substitute squema and name_of_the_proc by tyhe ones you need to call (don't forget privileges).
    Good luck

  • What Design Pattern - Change Language functionality

    On my application, I will have a series of buttons to choose
    a language. When the user chooses a language, all control labels,
    pop-up messages and others will change at the chosen language.
    I would like to do this from an OOP point of view and use
    Design Patterns. Which one would you recommend to use?
    My guess is the Strategy Pattern. Am I right?
    Thanks for any comment or link.

    The Strategy Pattern is used to swap algorithms dynamically.
    Based on user input a decision can be made to run a (set of)
    function(s). This behaviour is encapsulated in seperate objects.
    You just want to swap data at runtime. Or maybe set some
    behaviour regarding specific functions in languages like the way
    currencies are handled, measurements and the like. The latter would
    be implemented as Interpreter Pattern.
    When it's merely data that needs to changed/loaded at
    runtime, than it's more like a change of the Model in the MVC
    design pattern, using an Observer to notify all registered
    'listeners' and using a Command to get the thing going.

  • What key(s) do i type to change language from english to other? i am writing s story in dual languages. i was told to click command and space bar together but it is not working.

    what key(s) do it type to change language from english to other? i am writing a story in dual languages. I was told to click command and space bar together but it is not working.

    Command Spacebar opens Spotlight as you have found out. If you want to change languages you need to say what app you are using to write the story in, I'm guessing you are using Pages or MS Word. If that's the case
    Pages: Open Inspector - Click the T tab - Click Language and change your language.
    MS Word: Tools Menu - Language - Choose your language.

  • How to reload the screen when changing languages in JavaFX 2?

    I'm beginner with javaFX and i need to change language of the screen. but i have no idea how to reload the screen when the language was changed. The application have a button where have the language available. I want just refresh screen when the user change language.
    Here is the start method to show the stage.
        @Override
        public void start(Stage stage) throws Exception
            this.stage = stage;
            Locale locale = Locale.getDefault();
            ResourceBundle rb = ResourceBundle.getBundle("resources/Label",locale);
            loader = new FXMLLoader(getClass().getResource("FXMLDocument.fxml"),rb);
            root = (Parent)loader.load();
            FXMLDocumentController controller = (FXMLDocumentController) loader.getController();
            controller.setMain(this);
            scene = new Scene(root);
            stage.setScene(scene);
            stage.show();
    here is the function to change the language(in the same class with start function),the rb is the new ResourceBundle:
        public void refresh(ResourceBundle rb)
              //change the language here
    1. I don't want to use the resourceBundle to get value in resource file and set label in scene one by one.like following:
    this.btnLabel.setText(rb.getString(key.test));
    2. I don't want to reload the scene,like following:
        public void refresh(ResourceBundle rb)
             try
                loader = new FXMLLoader(getClass().getResource("FXMLDocument.fxml"),rb);
                root = (Parent)loader.load();
                scene.setRoot(root);
                FXMLDocumentController controller = (FXMLDocumentController) loader.getController();
                controller.setMain(this);
            catch(Exception err)
                err.printStackTrace();
    So do we have a solution to just set the resourceBundle and reload the scene easier?
    Thanks and best regards!

    Your option 2 (reload the FXML for the scene using the new resource bundle as a parameter), is the way this would normally be done and what I would recommend.
    Failing that, you could use option 1 of individually resetting the label text of labeled items (I don't really recommend this).
    Why don't you want to use option 2?
    Perhaps it is because there is some internal state of the UI which differs from the initial state when the the UI is first loaded (e.g. user has typed text in a text field and you want to preserve that).  If that's the case you will need to either go with your option 1 of individually resetting the label text of labeled items, or implement something which preserves the UI state and user data by saving it in memory or to disk, reloading the UI via the FXMLLoader (essentially your option 2), then restoring the UI state and user data to what it was before the language change.  Preserving and restoring the modified state seems complicated to me if you have a lot of state, so I wouldn't really advise this approach unless you really needed it.

  • I changed language from EN-GB to EN-US but my keyboard is still British (only when using FF). How can I change it to EN-US? in English

    I changed language (based on an answer in this forum) from EN-GB to EN-US but my keyboard is still British (only when using FF). How can I change it to EN-US?
    Should I just export my bookmarks, uninstall and reinstall the proper version? That may just be shorter than anything else.

    GREAT!. Thanks a lot for educating me. There seem to be a million things we have to learn about our computers and when we run into them the first time they seem insurmountable. You pointed me to the solution. Thanks again. Ben

  • Changing Images at Runtime...it's sending me nuts (I'm a newbie, go easy)

    Hi all,
    I am trying change images at runtime and quite frankly it's driving me nuts. I'm pretty new to Java and don't understand some of the principles but I'm trying. I have this code below, that loads up a few images. I want to be able to change some/all of these images either on a timed even or on a button press, but all the things I've tried don't work. Can someone offer me some help....thanks in advance
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class bc extends JFrame implements ActionListener {
         public static void main(String[] args) {new bc();}
         bc() {
              //setUndecorated(true); // - this removed the titlebar!
                    setTitle("BC...");
              setSize(350,125);
              setResizable(false);
              setLocation(50,50);
              setDefaultCloseOperation(EXIT_ON_CLOSE);
              setBackground(new Color(0,0,0));
              getContentPane().setBackground(new Color(255,255,255));
              JPanel hours = new JPanel();
              hours.setLayout(new GridLayout(4,2));
              hours.add(hour14);
              hours.add(hour24);
              hours.add(hour13);
              hours.add(hour23);
              hours.add(hour12);
              hours.add(hour22);
              hours.add(hour11);
              hours.add(hour21);
              JPanel mins = new JPanel();
              mins.setLayout(new GridLayout(4,2));
              mins.add(min14);
              mins.add(min24);
              mins.add(min13);
              mins.add(min23);
              mins.add(min12);
              mins.add(min22);
              mins.add(min11);
              mins.add(min21);
              JPanel secs = new JPanel();
              secs.setLayout(new GridLayout(4,2));
              secs.add(sec14);
              secs.add(sec24);
              secs.add(sec13);
              secs.add(sec23);
              secs.add(sec12);
              secs.add(sec22);
              secs.add(sec11);
              secs.add(sec21);
              JPanel helptext = new JPanel();
              helptext.setLayout(new GridLayout(4,2));
              helptext.add(new JLabel("8"));
              helptext.add(new JLabel("4"));
              helptext.add(new JLabel("2"));
              helptext.add(new JLabel("1"));
    //add action listenters
              changeImg.addActionListener(this);
              JPanel cp = new JPanel();
              cp.setLayout(new GridLayout(1,6));
              cp.setBackground(new Color(255,255,255));
              cp.add(hours);
              cp.add(mins);
              cp.add(secs);
              cp.add(helptext);
              cp.add(changeImg);
              setContentPane(cp);
              setVisible(true);
         public void actionPerformed(ActionEvent ae) {
              hour11.PaintOff(1);
              //JOptionPane.showMessageDialog(this, "changed");
              repaint();
    JPanel hour11 = new PaintOff(0);
    JPanel hour12 = new PaintOff(0);
    JPanel hour13 = new PaintBlank();
    JPanel hour14 = new PaintBlank();
    JPanel hour21 = new PaintOff(0);
    JPanel hour22 = new PaintOff(0);
    JPanel hour23 = new PaintBlank();
    JPanel hour24 = new PaintBlank();
    JPanel min11 = new PaintOff(0);
    JPanel min12 = new PaintOff(0);
    JPanel min13 = new PaintOff(0);
    JPanel min14 = new PaintOff(0);
    JPanel min21 = new PaintOff(0);
    JPanel min22 = new PaintOff(0);
    JPanel min23 = new PaintOff(0);
    JPanel min24 = new PaintOff(0);
    JPanel sec11 = new PaintOff(0);
    JPanel sec12 = new PaintOff(0);
    JPanel sec13 = new PaintOff(0);
    JPanel sec14 = new PaintOff(0);
    JPanel sec21 = new PaintOff(0);
    JPanel sec22 = new PaintOff(0);
    JPanel sec23 = new PaintOff(0);
    JPanel sec24 = new PaintOff(0);
    JButton changeImg = new JButton("change");
    }///---------This is my PaintOff class ---------------\\\
    import javax.swing.*;
    import java.awt.*;
    import java.awt.Image.*;
    public class PaintOff extends JPanel {
    Toolkit tk = Toolkit.getDefaultToolkit();
    public Image imgOff = tk.getImage("off.jpg");
    public Image imgOn = tk.getImage("on.jpg");
    public Image paintMe = tk.getImage("off.jpg");
         PaintOff(int a) {
              if(a == 1) {
                   vOn();
              } else {
                   vOff();
         public void vOn() {
            paintMe = imgOn;
         //JOptionPane.showMessageDialog(new bc(), "shown");
         public void vOff() {
            paintMe = imgOff;
         public void paintComponent(Graphics g) {
              g.drawImage(paintMe,0,0,this);
    }PaintBlank class is not included here, it's basically just the same as PaintOff but only has one image inside.
    When I try and compile this code, I get
    C:\jdk1.4\bin\bclock>javac bc.java
    bc.java:79: cannot resolve symbol
    symbol : method PaintOff (int)
    location: class javax.swing.JPanel
    hour11.PaintOff(1);
    ^
    1 error
    I don't understand this either, I've tried replacing "PaintOff(1)" with "vOn()" but I get the same error. This is baffling to be, as I thought that the hour11 would have access to all the methods inside the PaintOff class?
    Anyway, thanks for any help you guys give me!
    Cheers
    //Chris.

    Hi!
    Your problem is that you've used a widening conversion to convert from PaintOff to a JPanel. JPanel has no such method, and so the compiler is complaining that it can't find it.
    e.g
    public class NoCompile{
         public static void main(String args[]){
              One one = new Two();
              one.methTwo();
    public class Two extends One{
         public Two(){}
         public void methTwo(){
            System.out.println("Executed 2");
    public class One{
         public One(){}
         public void meth1(){}
    } will give you the same sort of error message. To make the compiler happy, use a cast.
    Now this will compile and gives the right result.
    public class NoCompile{
         public static void main(String args[]){
              One one = new Two();
              ((Two)one).methTwo();
    }So in your case, you want to do
    ((PaintOff)hour11).vOn();
    Does that help?
    :) jen

  • Changing Language in 6120

    Hi all
    I am having trouble with changing language in 6120.
    Usually, I am use to change language by pressing the # key when i write some thing... BUT the thing is that in 6120, it will change the language only to the language you choose.
    E.G main language is English, I write a URL in english that i want to get to, now, i am in the site and wants to write in Hebrew, However, the options of changing language by pressing on # key is only 123, abc, ABC but not Hebrew, even when i have Hebrew fonts installed. thus, i need to go to the language section, choose Main language as Hebrew, go back to the site and write in hebrew ... cant i do it just with the # key ?! so i will have 123, abc, ABC, אבג ... BTW, i had this option in my old 6230i

    In July of this year, Apple made a change to the iTunes store which essentially makes this impossible (for now). Until that time, there was a workaround you could use as per their Knowledgebase which would let you set the language of the iTunes Store back to English, regardless of what country your iTunes account was based in.
    There have been repeated attempts from the user community to get Apple to acknowledge and address this issue, but the customer service staff have thusfar only referred to the KB article, which doesn't actually help. For now, your only option is to select a different country's store by selecting the flag icon/button on the lower right corner of the iTunes store and reading about applications or music in another store...of course, this actually will log out out of your itunes store account, which means you can't purchase anything, and as soon as you sign back in, you will be forced to the language of the country your account is based in.
    I find this policy of Apple's to be truly repugnant and counter everything they've strived to stand for - but it seems it's here to stay, as they won't acknowledge nor fix it.
    Apple's staff only point to:
    http://support.apple.com/kb/HT2242
    This will not fix the problem we've all been having since July.

  • How to change language in photoshop CC 2014 with rksskogo into English?

    how to change language in photoshop CC 2014 with rksskogo into English?

    go to your installed photoshop directory select locales folder "nl_NL" folder "support files" "tw10428.dat" rename to "tw10428.dat.old" press yes, and restart the tool again

  • Change language in Acrobat XI Pro - It does not work

    I installed Acrobat XI Pro using the Adobe Application Manager (AAM) on Windows 7, English. I am on a Creative Cloud subscription, so i have no .exe file to install from.
    Acrobat XI Pro defaults the  Application Language to English when installing from AAM since Windows is an English version. I want Acrobat XI Pro in Swedish language.
    If i go to Acrobat's Preferences > Language and change the Application Language from English to "Choose at application startup" i never get the dialog that should provide me with the option to change language when i re-launch Acrobat XI Pro. If i hold down Shift-Ctrl when launching Acrobat XI Pro i don't get that dialog either.
    I see the same issue on three computers, two with Win 7 and one with Win 8. Both OS versions are English.
    So, how do i change the Application Language from English to Swedish?
    /Roger

    In case anyone else run into the same issue, here is the solution:
    1. Add remove programs -> Select Acrobat
    2. Then click on Change button  present next to Uninstall option. Acrobat setup dialog will be launched.
    3. Now select Modify option in Acrobat setup dialog
    4. In the dropdown list  select View Adobe PDF
    5. Select the desired language support
    6. Install the required language packs
    When i did, i got the dialog that let me change the language next time i launched Acrobat XI.
    Special thanks goes to Rohit from Adobe!
    /Roger

  • Firefox freeze whenever tired to change language input

    Hi. Whenever I tried to change language input to enter other languages Firefox freeze (program not responding).
    It happens as soon as I hit alt+shift or when I click language bar to select other language.
    It also happens with several languages (that I tested, might be all), and I tried various input software/mode including windows default, all freeze. Reset Firefox under help does not work either.
    This issue occur with Firefox and Chrome, but not IE... Might not be Firefox problem as it happen w Chrome, but and ideas please? Thanks.
    J
    Edit:
    * regedit might be changed, but do not believe touched internet setting.
    * I can enter foreign language as long as I set that language to default, and do not change to other language in the language bar. Currently I am using foreign language input software as default, and switch to English input '''within '''that software.

    Hi. karaoke I am not sure if its the same issue. The crash at language switch on my computer was due to the IME for Eastern Language Banks (Language option -> Detail under text services and input languages -> Properties -> reset/untick auto learn).
    If you are not using Eastern Language IME... I am sure others here have more experience and can better help you. =)

  • How to change language?

    I accidently selected "English" as application language at the first startup of Adobe Reader. Now I do not know how to change it to German, Edit -> Preferences -> International -> Application Language -> "Choose at Application startup" does NOT work. Do I have to uninstall Adobe Reader and reinstall it to change language?!?
    Sorry for my broken English.
    Kind regards - Oliver
    OS: Windows Vista
    Adobe Reader: 8.1.2

    >
    Claudio González, "How to change language?" #2, 26 Mar 2008 5:31 am If you go to Preferences > International (Display in older versions of Reader), you are offered limited language options. These are between English and the language you chose when downolading (older versions), and the present language and selecting language at startup (newer versions), which will probably offer the same two lternatives.
    As I have written, selecting one of these Options does
    b not work!
    Wich means no matter what I choose here it has
    b no effect
    (even after restarting adobe reader or my notebook)!
    Other Ideas?

Maybe you are looking for