Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Freemarker/JSP/Spring

Posted on 2013-11-17
4
Medium Priority
?
570 Views
Last Modified: 2013-11-19
Hi All,
I want to know that If a am changing a Locale from a GUI then If I am trying to print  all the Key value pair of properties file It was giving as  a  ??????? in a console but while debugging it is coming as a some language which I have been selected.
Same If  I am trying to show in freemarker page again it is coming like ??????


Please suggest me What to do for this?
0
Comment
Question by:I-Admin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 1000 total points
ID: 39656040
Ordinarily, a console (especially a Windows console) is not good at dealing with arbitrary charsets. You will need normally to look at the correct charset through the gui. The locale for a particular client will need to be stored on the server and applied for that client.

That is the general position. Specifically for Freemarker (something i don't do) it looks like you should be doing something like:
http://freemarker.org/docs/ref_directive_include.html#ref_directive_include_localized
0
 

Author Comment

by:I-Admin
ID: 39658340
public class SpringBean  {

      
      public Map display() {
            UserSession us;
//lang is coming from GUI from the previous page
            String lang = (String) Catalog.getRequest().getSession()
                        .getAttribute("lang");
      
            
            Locale currentLocale;
            
            currentLocale = new Locale(Constant.SESSION_LANG, i18prop);
            ResourceBundle labels = ResourceBundle.getBundle(i18prop);
            Enumeration bundleKeys = labels.getKeys();
            Map map = new HashMap();

            while (bundleKeys.hasMoreElements()) {
                  String key = (String) bundleKeys.nextElement();
                  String value = labels.getString(key);
                  map.put(key, value);
                        }
            System.out.println(map);
            return map;
            
       }


Now This map I want to use in freemarker page It is showing like ????
same for the console
But If i am debugging it and using (ctrl+shift+i) for map it is giving the same character for the language
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39659022
 i18prop

Open in new window

What is that?

  System.out.println(map);

Open in new window

(see my earlier comments about the console)
0
 

Author Comment

by:I-Admin
ID: 39659043
i18prop is a properties file. I.e for Taiwan it is coming like i18n_zh_TW.

 Unicode is written in i18 according to country.

  String value = labels.getString(key);

When I am writing System.out.println(value);
It was giving format of Taiwan but when I am writing System.out.println(map)
it was giving correct code but value are coming like ??????;
 and because I am using This map to my freemarker page to get value to the corresponding key in that also it was coming as ?????


Hope I have explained all you want!
here It is getting a data from a i18 file
0

Featured Post

How To Install Bash on Windows 10

Windows’ budding partnership with Canonical has certainly led to some great improvements. One of them being the ability to use Bash on your Windows machine without third party applications! This might be one of the greatest things a cloud engineer in a Windows environment can do!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question