1. Trang chủ
  2. » Giáo Dục - Đào Tạo

165 12 13InternationalizationSpringMVC kho tài liệu training

12 5 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 12
Dung lượng 269,27 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

i18n with Spring MVC• i18n in a Spring MVC context generally is looking at support for languages • Driven by ‘accept-language’ request header • ‘en-US’ - ‘en’ is the language code, ‘US’

Trang 2

Internationalization

Spring MVC

Trang 3

• Often abbreviated as i18n (I18N)

• i + 18 characters in ‘internationalization’ + n

• Localization - l10n (L10N)

• Fairly broad topic

• Languages, Currencies, Layouts

Trang 4

i18n with Spring MVC

• i18n in a Spring MVC context generally is looking

at support for languages

• Driven by ‘accept-language’ request header

• ‘en-US’ - ‘en’ is the language code, ‘US’ is the

country code

Trang 5

i18n Standards

• Language identifiers were established by RFC 3066

in 2001

• Language Codes are governed by ISO 639

• ISO - International Organization for Standardization

• Region codes are governed by ISO 3166

• Can refer to countries, regions, territories, etc.

Trang 6

International Standards

• Language identifiers were established by RFC 3066

in 2001

• Language Codes are governed by ISO 639

• ISO - International Organization for Standardization

• Region codes are governed by ISO 3166

• Can refer to countries, regions, territories, etc.

Trang 7

Locale Detection

• Default behavior is to use Accept-Language

header

• Can be configured to use system, a cookie, or a

custom parameter

• Custom Parameter is useful to allow user to

select language

Trang 8

Locale Resolvers

• AcceptHeaderLocaleResolver is the Spring Boot

Default

• Optionally, can use FixedLocaleResolver

• Uses the locale of the JVM

• Available: CookieLocaleResolver,

SessionLocaleResolver

Trang 9

Changing Locale

• Browsers are typically tied to the Locale of the

operating system

• Locale changing plugins are available

• Spring MVC provides as

LocaleChangeInterceptor to allow you to

configure a custom parameter to use to change the locale

Trang 10

Resource Bundles

• Resource bundles (aka messages.properties) are

selected on highest match order

• First selected will be on language region

• ie en-US would match

messages_en_US.properties

Trang 11

Resource Bundles

• If no exact match is found, just the language code

is used

• en-GB would match messages_en_GB.properties

• OR if no file found, would match

messages_en.properties

• Finally would match messages.properties

Ngày đăng: 17/11/2019, 08:22

🧩 Sản phẩm bạn có thể quan tâm

w