Results 1 to 9 of 9
  1. #1
    paddala is offline Member
    Join Date
    Jul 2008
    Posts
    11
    Rep Power
    0

    Default localization....help needed badly

    say i have a message with some html tags and \n(i.e. new line) or \t(tab)
    i want to include these tags in the property resource bundle...is it possible to do so?....is there some kind of different representation to be used in a property resource bundles for these tags?

    Ex: <html>"My name is \n" + name + "\t blah blah"</html>

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,899
    Rep Power
    25

    Default

    Have you tried using the escape character to escape the \
    ie \\n?

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  4. #4
    paddala is offline Member
    Join Date
    Jul 2008
    Posts
    11
    Rep Power
    0

    Default

    i have tried it but what happens is this, if i have
    key = core \\n name in my resource bundle
    and if i print bundle.getString("key")
    it prints core \n name
    i want it to print like this:
    core
    name

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,899
    Rep Power
    25

    Default

    Do a replace on the string \n with a lineend before printing.
    Does the property resource bundle support lineend characters?
    Have you looked at the file to see if its allowed? Try editting the file and adding a lineend and see what happens.

  6. #6
    paddala is offline Member
    Join Date
    Jul 2008
    Posts
    11
    Rep Power
    0

    Default

    this property resource bundle has been created from scratch by myself....can i support end line characters?....what do i have to do to support this?

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,899
    Rep Power
    25

    Default

    Did a quick test. Inserted the chars \n in a resouce boundle file, read it and printed it. The \n caused a line break.
    Can you post the code, the name of the properties file and its contents?

    Java Code:
    import java.util.*;
    
    public class ResourceBundleTest {
    
       public static String mymethod(String ss) {
          ResourceBundle resources = ResourceBundle.getBundle(ss);
          String s = resources.getString("USER");
           return s;
       }
       
       public static void main(String[] args) {
          String st = mymethod("DBase");
          System.out.println(st);
       }
    }
    /*
    Following is contents of DBase.properties
    key=value
    USER=DBase only\nadfg
    
    Following is output from program:
    DBase only
    adfg
    */

  8. #8
    paddala is offline Member
    Join Date
    Jul 2008
    Posts
    11
    Rep Power
    0

    Default

    oh god yea it works when i do this
    key = core \n name
    String s = bundle.getString("key");
    System.out.println(s);

    it prints:
    core
    name


    norm...thanks a lot...

    now abt the html tags i guess they would also be accepted....
    so can i include the html tags in the same way?

  9. #9
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,899
    Rep Power
    25

Similar Threads

  1. need you help badly!
    By sheena06 in forum New To Java
    Replies: 4
    Last Post: 07-09-2008, 10:15 AM
  2. help needed!!! :S
    By mark-mlt in forum Networking
    Replies: 1
    Last Post: 04-14-2008, 10:27 AM
  3. Object ArrayList - increment solution needed badly!!
    By rugbyGeek in forum New To Java
    Replies: 4
    Last Post: 03-08-2008, 01:47 AM
  4. help needed.
    By dirtycash in forum New To Java
    Replies: 3
    Last Post: 12-03-2007, 10:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •