SlideShare a Scribd company logo
www.SunilOS.com 1
www.sunilos.com
www.raystec.com
Resource Bundle
www.SunilOS.com 2
Introduction
It is used to support multi-language in an
Application that is called internationalization
(i18n).
It is used to remove hard coding from an
application by making configuration files and
read from resource bundle.
It moves all configurable parameters into a
text file in form of key=value pairs.
Class Hierarchy
www.SunilOS.com
3
Resource Bundle
PropertyResourceBundle ListResourceBundle
www.SunilOS.com 4
app.properties – create file
Create a text file having extension .properties.
Add key=value pairs of configurable data. Entries
will look like:
o #Database connection Parameters
o url=jdbc:mysql://localhost:3306/ocha
o driver=com.mysql.jdbc.Driver
o username=root
o password=pwd
Read from ResourceBundle
 Assuming that text file app.properties file is kept in
in.co.sunrays.rb package.
 public static void main(String[] args) {
 ResourceBundle rb =
 ResourceBundle.getBundle("in.co.sunrays.rb.app");
 //Pass key and get value
 String url = rb.getString("url");
 String driver = rb.getString("driver");
 String user = rb.getString("username");
 String password = rb.getString("password");
 }
www.SunilOS.com 5
Multilanguage Support
Can be achieved by setting Locale to resource
bundle.
For each locale you have to create a separate
.properties file.
Suppose you have to support three languages
English ( default ), Hindi and Spanish then you will
create:
o app.properties (default is English)
o app_hi.properties ( for Hindi )
o app_sp.properties ( for Spanish )
www.SunilOS.com 6
Create Property Files
app.properties
o greeting=Hello, how are you?
app_hi.properties
o greeting=हैलो, कै से हो?
app_sp.properties
o greeting=Hola, cómo estás?
www.SunilOS.com 7
www.SunilOS.com 8
Run and see the output
 //Default Locale
 ResourceBundle rb = ResourceBundle.getBundle("in.co.sunrays.rb.app");
 System.out.println(rb.getString("greeting"));
 //Set Locale to Spanish
 rb = ResourceBundle.getBundle("in.co.sunrays.rb.app", new Locale("sp"));
 System.out.println(rb.getString("greeting"));
 //Set Locale to Hindi
 rb = ResourceBundle.getBundle("in.co.sunrays.rb.app", new Locale("hi"));
 System.out.println(rb.getString("greeting"));
 Output
o Hello, how are you?
 Hola, cómo estás?
 हैलो, कै से हो?
Multi-Language Support
www.SunilOS.com 9
What is Locale?
A Locale object represents a specific geographical,
political, or cultural region.
Locale has three constructors that accepts:
o Language : uses two character code to represent a
language
 i.e. en : English, sp: Spanish, hi : Hindi
o Country : accepts valid international country code
 i.e. US: USA, IN : India, UK : United Kingdom.
o Variant: any arbitrary value used to indicate a variation
of a Locale, say state name MP, UP, HP, NY, TX, CT
etc.
www.SunilOS.com 10
Locale Constructors
Constructors:
o Locale(String language)
o Locale(String language, String country)
o Locale(String language, String country, String variant)
Locale locale = new Locale(“hi", “IN");
o It searches key in app_hi_IN.properties file.
Locale locale = new Locale(“hi", “IN“,”UP”);
o It searches key in app_hi_IN_UP.properties file.
www.SunilOS.com 11
Say NO to
Hard Coding
www.SunilOS.com 12
Say YES to
Resource Bundle
www.SunilOS.com 13
Disclaimer
This is an educational presentation to enhance the
skill of computer science students.
This presentation is available for free to computer
science students.
Some internet images from different URLs are
used in this presentation to simplify technical
examples and correlate examples with the real
world.
We are grateful to owners of these URLs and
pictures.
www.SunilOS.com 14
Thank You!
www.SunilOS.com 15
www.SunilOS.com

More Related Content

What's hot

Collection v3
Collection v3Collection v3
Collection v3
Sunil OS
 
Java Basics V3
Java Basics V3Java Basics V3
Java Basics V3
Sunil OS
 
Java 8 - CJ
Java 8 - CJJava 8 - CJ
Java 8 - CJ
Sunil OS
 
OOP V3.1
OOP V3.1OOP V3.1
OOP V3.1
Sunil OS
 
JAVA Variables and Operators
JAVA Variables and OperatorsJAVA Variables and Operators
JAVA Variables and Operators
Sunil OS
 
Collections Framework
Collections FrameworkCollections Framework
Collections Framework
Sunil OS
 
Java Basics
Java BasicsJava Basics
Java Basics
Sunil OS
 
JUnit 4
JUnit 4JUnit 4
JUnit 4
Sunil OS
 
PDBC
PDBCPDBC
PDBC
Sunil OS
 
Java Input Output and File Handling
Java Input Output and File HandlingJava Input Output and File Handling
Java Input Output and File Handling
Sunil OS
 
JAVA OOP
JAVA OOPJAVA OOP
JAVA OOP
Sunil OS
 
Node.js Express
Node.js  ExpressNode.js  Express
Node.js Express
Eyal Vardi
 
Java Threads and Concurrency
Java Threads and ConcurrencyJava Threads and Concurrency
Java Threads and Concurrency
Sunil OS
 
Machine learning ( Part 3 )
Machine learning ( Part 3 )Machine learning ( Part 3 )
Machine learning ( Part 3 )
Sunil OS
 
DJango
DJangoDJango
DJango
Sunil OS
 
Node.js Express Framework
Node.js Express FrameworkNode.js Express Framework
Node.js Express Framework
TheCreativedev Blog
 
Machine learning ( Part 1 )
Machine learning ( Part 1 )Machine learning ( Part 1 )
Machine learning ( Part 1 )
Sunil OS
 
Angular 2.0 Pipes
Angular 2.0 PipesAngular 2.0 Pipes
Angular 2.0 Pipes
Eyal Vardi
 
Java RMI
Java RMIJava RMI
Java RMI
Sunil OS
 
Java Networking
Java NetworkingJava Networking
Java Networking
Sunil OS
 

What's hot (20)

Collection v3
Collection v3Collection v3
Collection v3
 
Java Basics V3
Java Basics V3Java Basics V3
Java Basics V3
 
Java 8 - CJ
Java 8 - CJJava 8 - CJ
Java 8 - CJ
 
OOP V3.1
OOP V3.1OOP V3.1
OOP V3.1
 
JAVA Variables and Operators
JAVA Variables and OperatorsJAVA Variables and Operators
JAVA Variables and Operators
 
Collections Framework
Collections FrameworkCollections Framework
Collections Framework
 
Java Basics
Java BasicsJava Basics
Java Basics
 
JUnit 4
JUnit 4JUnit 4
JUnit 4
 
PDBC
PDBCPDBC
PDBC
 
Java Input Output and File Handling
Java Input Output and File HandlingJava Input Output and File Handling
Java Input Output and File Handling
 
JAVA OOP
JAVA OOPJAVA OOP
JAVA OOP
 
Node.js Express
Node.js  ExpressNode.js  Express
Node.js Express
 
Java Threads and Concurrency
Java Threads and ConcurrencyJava Threads and Concurrency
Java Threads and Concurrency
 
Machine learning ( Part 3 )
Machine learning ( Part 3 )Machine learning ( Part 3 )
Machine learning ( Part 3 )
 
DJango
DJangoDJango
DJango
 
Node.js Express Framework
Node.js Express FrameworkNode.js Express Framework
Node.js Express Framework
 
Machine learning ( Part 1 )
Machine learning ( Part 1 )Machine learning ( Part 1 )
Machine learning ( Part 1 )
 
Angular 2.0 Pipes
Angular 2.0 PipesAngular 2.0 Pipes
Angular 2.0 Pipes
 
Java RMI
Java RMIJava RMI
Java RMI
 
Java Networking
Java NetworkingJava Networking
Java Networking
 

Viewers also liked

C# Variables and Operators
C# Variables and OperatorsC# Variables and Operators
C# Variables and Operators
Sunil OS
 
C# Basics
C# BasicsC# Basics
C# Basics
Sunil OS
 
Java Swing JFC
Java Swing JFCJava Swing JFC
Java Swing JFC
Sunil OS
 
Cvl bundle presentation
Cvl bundle presentationCvl bundle presentation
Cvl bundle presentation
maternity & children's hospital, moh
 
Eschool erp School Management System SMS System School Software
Eschool erp School Management System SMS System School SoftwareEschool erp School Management System SMS System School Software
Eschool erp School Management System SMS System School Software
Mayank Jain
 
Développer avec le sylius resourcebundle (Symfony live Paris 2015)
Développer avec le sylius resourcebundle (Symfony live Paris 2015) Développer avec le sylius resourcebundle (Symfony live Paris 2015)
Développer avec le sylius resourcebundle (Symfony live Paris 2015)
Arnaud Langlade
 

Viewers also liked (6)

C# Variables and Operators
C# Variables and OperatorsC# Variables and Operators
C# Variables and Operators
 
C# Basics
C# BasicsC# Basics
C# Basics
 
Java Swing JFC
Java Swing JFCJava Swing JFC
Java Swing JFC
 
Cvl bundle presentation
Cvl bundle presentationCvl bundle presentation
Cvl bundle presentation
 
Eschool erp School Management System SMS System School Software
Eschool erp School Management System SMS System School SoftwareEschool erp School Management System SMS System School Software
Eschool erp School Management System SMS System School Software
 
Développer avec le sylius resourcebundle (Symfony live Paris 2015)
Développer avec le sylius resourcebundle (Symfony live Paris 2015) Développer avec le sylius resourcebundle (Symfony live Paris 2015)
Développer avec le sylius resourcebundle (Symfony live Paris 2015)
 

Similar to Resource Bundle

Android App Development 08 : Support Multiple Devices
Android App Development 08 : Support Multiple DevicesAndroid App Development 08 : Support Multiple Devices
Android App Development 08 : Support Multiple Devices
Anuchit Chalothorn
 
Internationalization
InternationalizationInternationalization
Internationalization
Kashyap Parmar
 
Multi Lingual Websites In Umbraco
Multi Lingual Websites In UmbracoMulti Lingual Websites In Umbraco
Multi Lingual Websites In Umbraco
Paul Marden
 
Internationlization
InternationlizationInternationlization
Internationlization
Tuan Ngo
 
147 341-1-pb baik
147 341-1-pb baik147 341-1-pb baik
147 341-1-pb baik
IKalamkudus Orchid
 
Android structure
Android structureAndroid structure
Android structure
Kumar
 
MIDP Internalization
MIDP InternalizationMIDP Internalization
MIDP Internalization
Jussi Pohjolainen
 
Globalization and accessibility
Globalization and accessibilityGlobalization and accessibility
Globalization and accessibility
aspnet123
 
NetBase API Presentation
NetBase API PresentationNetBase API Presentation
NetBase API Presentation
Netbase Solutions Inc.
 
Your Business. Your Language. Your Code - dpc13
Your Business. Your Language. Your Code - dpc13Your Business. Your Language. Your Code - dpc13
Your Business. Your Language. Your Code - dpc13
Stephan Hochdörfer
 
Android resource
Android resourceAndroid resource
Android resource
Krazy Koder
 
Practical Internationalization Improvement for Sakai CLE
Practical Internationalization Improvement for Sakai CLEPractical Internationalization Improvement for Sakai CLE
Practical Internationalization Improvement for Sakai CLE
jfl_101010
 
Localization
LocalizationLocalization
Localization
lokesh s
 
Application fundamentals
Application fundamentalsApplication fundamentals
Application fundamentals
maamir farooq
 
Data Science Amsterdam - Massively Parallel Processing with Procedural Languages
Data Science Amsterdam - Massively Parallel Processing with Procedural LanguagesData Science Amsterdam - Massively Parallel Processing with Procedural Languages
Data Science Amsterdam - Massively Parallel Processing with Procedural Languages
Ian Huston
 
Drupal 8 Multilingual - what to look forward to
Drupal 8 Multilingual - what to look forward toDrupal 8 Multilingual - what to look forward to
Drupal 8 Multilingual - what to look forward to
Gábor Hojtsy
 
Unit 4 lecture-3
Unit 4 lecture-3Unit 4 lecture-3
Unit 4 lecture-3
vishal choudhary
 
Drupal 8's Multilingual APIs: Building for the Entire World
Drupal 8's Multilingual APIs: Building for the Entire WorldDrupal 8's Multilingual APIs: Building for the Entire World
Drupal 8's Multilingual APIs: Building for the Entire World
Christian López Espínola
 
A whole new world for multilingual sites in Drupal 8 - jam's Drupal Camp session
A whole new world for multilingual sites in Drupal 8 - jam's Drupal Camp sessionA whole new world for multilingual sites in Drupal 8 - jam's Drupal Camp session
A whole new world for multilingual sites in Drupal 8 - jam's Drupal Camp session
Jeffrey McGuire
 
Submission_36
Submission_36Submission_36
Submission_36
Harsh Singh
 

Similar to Resource Bundle (20)

Android App Development 08 : Support Multiple Devices
Android App Development 08 : Support Multiple DevicesAndroid App Development 08 : Support Multiple Devices
Android App Development 08 : Support Multiple Devices
 
Internationalization
InternationalizationInternationalization
Internationalization
 
Multi Lingual Websites In Umbraco
Multi Lingual Websites In UmbracoMulti Lingual Websites In Umbraco
Multi Lingual Websites In Umbraco
 
Internationlization
InternationlizationInternationlization
Internationlization
 
147 341-1-pb baik
147 341-1-pb baik147 341-1-pb baik
147 341-1-pb baik
 
Android structure
Android structureAndroid structure
Android structure
 
MIDP Internalization
MIDP InternalizationMIDP Internalization
MIDP Internalization
 
Globalization and accessibility
Globalization and accessibilityGlobalization and accessibility
Globalization and accessibility
 
NetBase API Presentation
NetBase API PresentationNetBase API Presentation
NetBase API Presentation
 
Your Business. Your Language. Your Code - dpc13
Your Business. Your Language. Your Code - dpc13Your Business. Your Language. Your Code - dpc13
Your Business. Your Language. Your Code - dpc13
 
Android resource
Android resourceAndroid resource
Android resource
 
Practical Internationalization Improvement for Sakai CLE
Practical Internationalization Improvement for Sakai CLEPractical Internationalization Improvement for Sakai CLE
Practical Internationalization Improvement for Sakai CLE
 
Localization
LocalizationLocalization
Localization
 
Application fundamentals
Application fundamentalsApplication fundamentals
Application fundamentals
 
Data Science Amsterdam - Massively Parallel Processing with Procedural Languages
Data Science Amsterdam - Massively Parallel Processing with Procedural LanguagesData Science Amsterdam - Massively Parallel Processing with Procedural Languages
Data Science Amsterdam - Massively Parallel Processing with Procedural Languages
 
Drupal 8 Multilingual - what to look forward to
Drupal 8 Multilingual - what to look forward toDrupal 8 Multilingual - what to look forward to
Drupal 8 Multilingual - what to look forward to
 
Unit 4 lecture-3
Unit 4 lecture-3Unit 4 lecture-3
Unit 4 lecture-3
 
Drupal 8's Multilingual APIs: Building for the Entire World
Drupal 8's Multilingual APIs: Building for the Entire WorldDrupal 8's Multilingual APIs: Building for the Entire World
Drupal 8's Multilingual APIs: Building for the Entire World
 
A whole new world for multilingual sites in Drupal 8 - jam's Drupal Camp session
A whole new world for multilingual sites in Drupal 8 - jam's Drupal Camp sessionA whole new world for multilingual sites in Drupal 8 - jam's Drupal Camp session
A whole new world for multilingual sites in Drupal 8 - jam's Drupal Camp session
 
Submission_36
Submission_36Submission_36
Submission_36
 

More from Sunil OS

OOP v3
OOP v3OOP v3
OOP v3
Sunil OS
 
Threads v3
Threads v3Threads v3
Threads v3
Sunil OS
 
Exception Handling v3
Exception Handling v3Exception Handling v3
Exception Handling v3
Sunil OS
 
Machine learning ( Part 2 )
Machine learning ( Part 2 )Machine learning ( Part 2 )
Machine learning ( Part 2 )
Sunil OS
 
Python Pandas
Python PandasPython Pandas
Python Pandas
Sunil OS
 
Python part2 v1
Python part2 v1Python part2 v1
Python part2 v1
Sunil OS
 
Angular 8
Angular 8 Angular 8
Angular 8
Sunil OS
 
Python Part 1
Python Part 1Python Part 1
Python Part 1
Sunil OS
 
Rays Technologies
Rays TechnologiesRays Technologies
Rays Technologies
Sunil OS
 
C++ oop
C++ oopC++ oop
C++ oop
Sunil OS
 
C++
C++C++
C Basics
C BasicsC Basics
C Basics
Sunil OS
 

More from Sunil OS (12)

OOP v3
OOP v3OOP v3
OOP v3
 
Threads v3
Threads v3Threads v3
Threads v3
 
Exception Handling v3
Exception Handling v3Exception Handling v3
Exception Handling v3
 
Machine learning ( Part 2 )
Machine learning ( Part 2 )Machine learning ( Part 2 )
Machine learning ( Part 2 )
 
Python Pandas
Python PandasPython Pandas
Python Pandas
 
Python part2 v1
Python part2 v1Python part2 v1
Python part2 v1
 
Angular 8
Angular 8 Angular 8
Angular 8
 
Python Part 1
Python Part 1Python Part 1
Python Part 1
 
Rays Technologies
Rays TechnologiesRays Technologies
Rays Technologies
 
C++ oop
C++ oopC++ oop
C++ oop
 
C++
C++C++
C++
 
C Basics
C BasicsC Basics
C Basics
 

Recently uploaded

Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
deepaannamalai16
 
CIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdfCIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdf
blueshagoo1
 
Simple-Present-Tense xxxxxxxxxxxxxxxxxxx
Simple-Present-Tense xxxxxxxxxxxxxxxxxxxSimple-Present-Tense xxxxxxxxxxxxxxxxxxx
Simple-Present-Tense xxxxxxxxxxxxxxxxxxx
RandolphRadicy
 
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
Kalna College
 
NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...
NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...
NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...
Payaamvohra1
 
A Free 200-Page eBook ~ Brain and Mind Exercise.pptx
A Free 200-Page eBook ~ Brain and Mind Exercise.pptxA Free 200-Page eBook ~ Brain and Mind Exercise.pptx
A Free 200-Page eBook ~ Brain and Mind Exercise.pptx
OH TEIK BIN
 
Juneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School DistrictJuneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School District
David Douglas School District
 
Data Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsxData Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsx
Prof. Dr. K. Adisesha
 
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
ImMuslim
 
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
220711130083 SUBHASHREE RAKSHIT  Internet resources for social science220711130083 SUBHASHREE RAKSHIT  Internet resources for social science
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
Kalna College
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
nitinpv4ai
 
220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx
Kalna College
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
deepaannamalai16
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
Iris Thiele Isip-Tan
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
zuzanka
 
BPSC-105 important questions for june term end exam
BPSC-105 important questions for june term end examBPSC-105 important questions for june term end exam
BPSC-105 important questions for june term end exam
sonukumargpnirsadhan
 
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
EduSkills OECD
 
MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025
khuleseema60
 
Accounting for Restricted Grants When and How To Record Properly
Accounting for Restricted Grants  When and How To Record ProperlyAccounting for Restricted Grants  When and How To Record Properly
Accounting for Restricted Grants When and How To Record Properly
TechSoup
 
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGHKHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
shreyassri1208
 

Recently uploaded (20)

Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
 
CIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdfCIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdf
 
Simple-Present-Tense xxxxxxxxxxxxxxxxxxx
Simple-Present-Tense xxxxxxxxxxxxxxxxxxxSimple-Present-Tense xxxxxxxxxxxxxxxxxxx
Simple-Present-Tense xxxxxxxxxxxxxxxxxxx
 
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
 
NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...
NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...
NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...
 
A Free 200-Page eBook ~ Brain and Mind Exercise.pptx
A Free 200-Page eBook ~ Brain and Mind Exercise.pptxA Free 200-Page eBook ~ Brain and Mind Exercise.pptx
A Free 200-Page eBook ~ Brain and Mind Exercise.pptx
 
Juneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School DistrictJuneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School District
 
Data Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsxData Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsx
 
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
 
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
220711130083 SUBHASHREE RAKSHIT  Internet resources for social science220711130083 SUBHASHREE RAKSHIT  Internet resources for social science
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
 
220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
 
BPSC-105 important questions for june term end exam
BPSC-105 important questions for june term end examBPSC-105 important questions for june term end exam
BPSC-105 important questions for june term end exam
 
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
 
MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025
 
Accounting for Restricted Grants When and How To Record Properly
Accounting for Restricted Grants  When and How To Record ProperlyAccounting for Restricted Grants  When and How To Record Properly
Accounting for Restricted Grants When and How To Record Properly
 
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGHKHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
 

Resource Bundle

  • 2. www.SunilOS.com 2 Introduction It is used to support multi-language in an Application that is called internationalization (i18n). It is used to remove hard coding from an application by making configuration files and read from resource bundle. It moves all configurable parameters into a text file in form of key=value pairs.
  • 4. www.SunilOS.com 4 app.properties – create file Create a text file having extension .properties. Add key=value pairs of configurable data. Entries will look like: o #Database connection Parameters o url=jdbc:mysql://localhost:3306/ocha o driver=com.mysql.jdbc.Driver o username=root o password=pwd
  • 5. Read from ResourceBundle  Assuming that text file app.properties file is kept in in.co.sunrays.rb package.  public static void main(String[] args) {  ResourceBundle rb =  ResourceBundle.getBundle("in.co.sunrays.rb.app");  //Pass key and get value  String url = rb.getString("url");  String driver = rb.getString("driver");  String user = rb.getString("username");  String password = rb.getString("password");  } www.SunilOS.com 5
  • 6. Multilanguage Support Can be achieved by setting Locale to resource bundle. For each locale you have to create a separate .properties file. Suppose you have to support three languages English ( default ), Hindi and Spanish then you will create: o app.properties (default is English) o app_hi.properties ( for Hindi ) o app_sp.properties ( for Spanish ) www.SunilOS.com 6
  • 7. Create Property Files app.properties o greeting=Hello, how are you? app_hi.properties o greeting=हैलो, कै से हो? app_sp.properties o greeting=Hola, cómo estás? www.SunilOS.com 7
  • 8. www.SunilOS.com 8 Run and see the output  //Default Locale  ResourceBundle rb = ResourceBundle.getBundle("in.co.sunrays.rb.app");  System.out.println(rb.getString("greeting"));  //Set Locale to Spanish  rb = ResourceBundle.getBundle("in.co.sunrays.rb.app", new Locale("sp"));  System.out.println(rb.getString("greeting"));  //Set Locale to Hindi  rb = ResourceBundle.getBundle("in.co.sunrays.rb.app", new Locale("hi"));  System.out.println(rb.getString("greeting"));  Output o Hello, how are you?  Hola, cómo estás?  हैलो, कै से हो?
  • 10. What is Locale? A Locale object represents a specific geographical, political, or cultural region. Locale has three constructors that accepts: o Language : uses two character code to represent a language  i.e. en : English, sp: Spanish, hi : Hindi o Country : accepts valid international country code  i.e. US: USA, IN : India, UK : United Kingdom. o Variant: any arbitrary value used to indicate a variation of a Locale, say state name MP, UP, HP, NY, TX, CT etc. www.SunilOS.com 10
  • 11. Locale Constructors Constructors: o Locale(String language) o Locale(String language, String country) o Locale(String language, String country, String variant) Locale locale = new Locale(“hi", “IN"); o It searches key in app_hi_IN.properties file. Locale locale = new Locale(“hi", “IN“,”UP”); o It searches key in app_hi_IN_UP.properties file. www.SunilOS.com 11
  • 12. Say NO to Hard Coding www.SunilOS.com 12
  • 13. Say YES to Resource Bundle www.SunilOS.com 13
  • 14. Disclaimer This is an educational presentation to enhance the skill of computer science students. This presentation is available for free to computer science students. Some internet images from different URLs are used in this presentation to simplify technical examples and correlate examples with the real world. We are grateful to owners of these URLs and pictures. www.SunilOS.com 14