Introduction to I18N Applications in JSF

Ratings:
(4)
Views:435
Banner-Img
  • Share this blog:

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”)); } }

You liked the article?

Like : 0

Vote for difficulty

Current difficulty (Avg): Medium

Recommended Courses

1/15

About Author
Authorlogo
Name
TekSlate
Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.


Stay Updated


Get stories of change makers and innovators from the startup ecosystem in your inbox