Introduction to I18N Applications in JSF

In java applications, we are able to provide I18N Supported in the form of the following 3 areas.

  1. Number formations
  2. Date formations
  3. Message formations

 

1.Number formations

  • To represent a number w.r.to a particular local we have to use a predefined class java. Text. Number format
  • To use number format class in java applications. We have to use the following steps
  1. Prepare number format class object

To prepare number format class object, we have to use the following static factory method public static number format get instance(Local l) 

 

2.Format a number w.r.to a local

To  format number, we have to use the following method public string format(XXX NUMBER)Where xxx may be byte, short, int, float,…

Import java. Text*;

Import java. util*;

Public class Test

{

Public static void main(strin[]args) throws exception

{

Local l=new local(“it”,”It”);

Number format nf=number format. Get instance(l);

s.o.p(nf.format(12345.234567));

}

}

 

  1. Date formations

If we want to represent date w.r.to a particular local. We have to use a predefined class java.text. date formal

  • It we want to use data format in java applications we have to use the following steps
  1. prepare local object –

Local i= new locale(“en”,”us”);

  1. Create data format object 

To create data format object, we have to use the following static factory method. Public static data format get data insurance

(int data- sty, local i)

  1. Format data w.r.t the specified local

To represent data. W.r.t the specified local, public string format(date d)

àImport java. text.*;

Import java. util.*;

Public class test

{

p.s.v.m() throws exception

{

Locale l=new locale(“It”,”IT”);

Data format dt= Date format. Get date insurance.col);

s.o.p(dt. format; new date())));

}

}

  1. Message formations

To represent a message w.r.to a particular local we have to use a predefined class provided by java java. util. Resource bundle

It we want to use resource bundle in java application  we have to use the following steps

  • Prepare properties files with the local messages

To prepare properties files we have to take a text file and provide locale messages in the from of key- value pairs and we must save properties file with the following naming conversion

<base-name>-<long>-<country><sys-var>. prepare files

Abc-en-us. Properties

Uname= user name

Upwd= password

  • prepare locale object

Local I = new locale(“en”,”us”);

 

  • prepare resource bundle object

To prepare resource bundle class object we have to  use the following static factory method public static resource bundle[string base – name locale()

  • Get message from resource bundle object on basis of key

To get a message on the basis of a key, we have to use the following method public string get string(string key)

Abc-en-us. Properties

Welcome=welcome to en us users

Abc –it IT Properties

Welcome=welcome to it It USERS.

Public class test

{

p.S.V.M()THROWS Exception

{

Locate I = new locale(“it”,”IT”);

Resource bundle rb = resourceBundle. GetBundle(“abc”,i);

s.o.p(rb. get string(“welcome”));

}

}

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on Introduction to I18N Applications in JSF"

    Leave a Message

    Your email address will not be published. Required fields are marked *

    Support


    Please leave a message and we'll get back to you soon.
    Three + 6