Java国际化资源文件的选择

 

如果Locale为:language_country,操作系统的Locale为xx_YY则选择资源文件的顺序为:

              (一)如果存在message_language_country.properties,查找key值的顺序为:

             message_language_country.properties

             message_language.properties

             message.properties

 (二)否则,如果存在message_language.properties,查找key值的顺序为:

             message_language.properties

             message.properties

 (三)否则,如果存在message_xx_YY.properties,查找key值的顺序为:

 message_xx_YY.properties

 message_xx.properites

 message.properties

 (四)否则,如果存在message_xx.properties,查找key值的顺序为:

 message_xx.properites

 message.properties

 (五)否则,如果存在message.properties,查找key值的顺序为:

 message.properties

如果Locale为language,操作系统的Locale为xx_YY则选择资源文件的顺序为:

  1. message_language.properties
  2. message_xx_YY.properties
  3. message_xx.properties
  4. message.properties

ps:首先需要确定使用哪个系列的资源文件(基本名称相同,语言和国家不同),其次确定优先使用哪个资源文件中的资源,再次确定当该资源文件中没有资源时查找其他资源文件的顺序

原文地址:https://www.cnblogs.com/chunchengwuchu/p/4029641.html