Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7904075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:54:17+00:00 2026-06-03T09:54:17+00:00

I have an application in witch I am trying to set a internationalization availability.

  • 0

I have an application in witch I am trying to set a internationalization availability.

This is my faces-config.xml:

<application>
    <locale-config>
        <default-locale>lt</default-locale>
        <supported-locale>en</supported-locale>
        <supported-locale>de</supported-locale>
    </locale-config>
    <resource-bundle>
        <base-name>application</base-name>
        <var>msg</var>
    </resource-bundle>
</application>

I have three property files:

application_lt.properties
application_en.properties
application_de.properties

The bean class:

@ManagedBean(name = Beans.LOCALE_BEAN)
@SessionScoped
public class LocaleBean extends BaseBean implements Serializable {

    private String lang;

    public String getLang() {
        return lang;
    }

    public void setLang(String lang) {
        this.lang = lang;
    }
}

The action class:

@ManagedBean(name = "localeAction")
@SessionScoped
public class LocaleAction extends BaseAction implements Serializable {

    public void changeLocale() {
        LocaleBean localeBean = getBean(Beans.LOCALE_BEAN);
        String language = localeBean.getLang();
        FacesContext.getCurrentInstance().getViewRoot().setLocale(new Locale(language));
    }

}

To change locale I am using commandLink:

<h:commandLink action="#{localeAction.changeLocale}">
    <f:setPropertyActionListener target="#{localeBean.lang}" value="en"/>
    English
</h:commandLink>

<h:commandLink action="#{localeAction.changeLocale}">
    <f:setPropertyActionListener target="#{localeBean.lang}" value="lt"/>
    Lithuanian
</h:commandLink>

First problem:

I have defined that my default locale is “lt”: lt. Why when I start up my application text values is loaded from application_en.properties and not from application_lt.properties?

Second problem:

When I execute commandLink action, the locale changes depending on which locale I have selected. But executing the action was one click, the second click on any other link of application is OK as well and when I click on any link of application for a third time, the text values are locaded from application_en.properties. It seems that locale changes somehow…

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T09:54:19+00:00Added an answer on June 3, 2026 at 9:54 am

    I have defined that my default locale is “lt”: lt. Why when I start up my application text values is loaded from application_en.properties and not from application_lt.properties?

    Apparently because your browser identifies itself with locale en as preferred locale by the Accept-Language request header. JSF will then automatically use it because it’s among the supported languages. You’d need to change the preferred language in the browser’s settings.


    When I execute commandLink action, the locale changes depending on which locale I have selected. But executing the action was one click, the second click on any other link of application is OK as well and when I click on any link of application for a third time, the text values are locaded from application_en.properties. It seems that locale changes somehow.

    Apparently you changed the view. Your action method only changes the locale of the current view. You need to make sure that you set the locale form the LocaleBean in the <f:view> of the master template or at least all views.

    <f:view locale="#{localeBean.lang}">
    

    See also:

    • Localization in JSF, how to remember selected locale per session instead of per request/view
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an MFC application compiled with /clr and I'm trying to implement a
I'm trying to develop a web application with Novell LDAP Authentication . I have
I have an application that I'm trying to build with at least a nominally
I have a php application , and I'm trying to integrate with paypal payment
I have a Spring MVC application trying to use a rich domain model, with
I have a simple rails 2.3.4 application I am trying to get running with
I am trying to diagnose a problem with an internal production application. We have
I'm trying to create an Hello World JSF application. I have a bean with
i have an iOS application witch uses the current location of the user. I
I have a desktop .NET WPF application witch uses an embedded database (SQLite). Where

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.