1、java本地化
class="java">public class App { public static void main( String[] args ) { Locale china = new Locale("zh", "CN"); Locale hongkong = new Locale("zh", "HK"); Locale taiwan = new Locale("zh", "TW"); Locale usa = new Locale("en", "US"); Locale england = new Locale("en", "GB"); Locale france = new Locale("fr", "FR"); NumberFormat fmt = NumberFormat.getCurrencyInstance(france); double price = 12.88; System.out.println(fmt.format(price)); } }
?
public static void messageFormat(Locale locale, Object...params) { String msg = "hello {0}, welcome here to {1}"; MessageFormat msgFmt = new MessageFormat(msg, locale); String localeMsg = msgFmt.format(params); System.out.println(localeMsg); }
?2、资源命名
资源名_语言代码_国家地区代码.properties
资源名.properties:默认的资源文件
?
3、spring中的MessageSource
org.springframework.context.support.ResourceBundleMessageSource
?
?