java 中 ResourceBundle 使用

可以根据以下类进行获取国际化文件:

package org.mybatis.generator.internal.util.messages;

import java.text.MessageFormat;
import java.util.MissingResourceException;
import java.util.ResourceBundle; public class Messages {
private static final String BUNDLE_NAME = "org.mybatis.generator.internal.util.messages.messages"; //$NON-NLS-1$ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
.getBundle(BUNDLE_NAME); private Messages() {
} public static String getString(String key) {
try {
return RESOURCE_BUNDLE.getString(key);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
} public static String getString(String key, String parm1) {
try {
return MessageFormat.format(RESOURCE_BUNDLE.getString(key),
new Object[] { parm1 });
} catch (MissingResourceException e) {
return '!' + key + '!';
}
} public static String getString(String key, String parm1, String parm2) {
try {
return MessageFormat.format(RESOURCE_BUNDLE.getString(key),
new Object[] { parm1, parm2 });
} catch (MissingResourceException e) {
return '!' + key + '!';
}
} public static String getString(String key, String parm1, String parm2,
String parm3) {
try {
return MessageFormat.format(RESOURCE_BUNDLE.getString(key),
new Object[] { parm1, parm2, parm3 });
} catch (MissingResourceException e) {
return '!' + key + '!';
}
}
}

  

可以获取jar包中国际化文件:

ValidationError.0=JavaModelGenerator Target Project is Required for context {0}
ValidationError.1=SQLMapGenerator Target Project is Required for context {0}
ValidationError.2=DAOGenerator Target Project is Required for context {0}
ValidationError.3=No Tables Specified for context {0}
ValidationError.4=JDBC Driver Class Must Be Specified
ValidationError.5=JDBC Connection URL Must Be Specified
ValidationError.6=Missing table name in table configuration at index {0}
ValidationError.7=SQL Statement is required if a generated key is specified in table configuration for table {0}
ValidationError.8=JavaModelGeneratorConfiguration is required for context {0}
ValidationError.9=SqlMapGeneratorConfiguration is required for context {0}
ValidationError.10=JdbcConnectionConfiguration is required for context {0}
ValidationError.11=At least one configuration element is required
ValidationError.12={0} Target Package is Required for context {1}
ValidationError.13=If "useColumnIndexes" property is set, then either both or neither query id must be set for table {0}
ValidationError.14="searchString" is required for ColumnRenamingRule in table {0}
ValidationError.15=Generated key type must be either "pre" or "post" if the type is specified for a generated key for table {0}
ValidationError.16="id" is required in a context
ValidationError.17="type" is required in a plugin in context {0}
ValidationError.18={0} requires the {1} property
ValidationError.19=A null or empty string is not allowed for a classpath entry
ValidationError.20="type" is required for DAO Generator in context {0}
ValidationError.21="column" is required for <ignoredColumn> in table {0}
ValidationError.22="column" is required for <columnOverride> in table {0}
ValidationError.23=Generated key in table {0} cannot be both "pre" and identity
ValidationError.24=Generated key in table {0} cannot be both "post" and not identity
ValidationError.25=targetRuntime in context {0} is invalid RuntimeError.0=configfile is a required parameter
RuntimeError.1=configfile {0} does not exist
RuntimeError.2=Configuration is required
RuntimeError.3=Cannot generate unique file name in directory {0}
RuntimeError.4=XML Parser Error on line {0}: {1}
RuntimeError.5=This is not a MyBatis Generator Configuration File
RuntimeError.6=Cannot instantiate object of type {0}
RuntimeError.7=Cannot connect to database (possibly bad driver/URL combination)
RuntimeError.8=Exception getting JDBC Driver
RuntimeError.9=Cannot resolve classpath entry: {0}
RuntimeError.11=Enumerations do not have super classes
RuntimeError.12=Internal Error - Cannot calculate record type for selectByExample method
RuntimeError.13=Invalid model type: {0}
RuntimeError.14=Either resource or URL is required on the <properties> element, but not both
RuntimeError.15=<properties> resource {0} does not exist
RuntimeError.16=Cannot load properties from <properties> resource {0}
RuntimeError.17=Cannot load properties from <properties> url {0}
RuntimeError.18=Unsupported XML Node Type {0} in XML File Merger
RuntimeError.19=Value missing after {0}
RuntimeError.20=Unknown argument: {0}
RuntimeError.21=Error creating logger for class {0}. Cause: {1}
RuntimeError.22=Invalid Type Specification: {0}. Warning.0=There are no statements enabled for table {0}, this table will be ignored.
Warning.1=Table {0} does not exist, this table will be ignored
Warning.2=Existing file not overwritten, the generated file is saved as {0}
Warning.3=Column {0}, specified for override in table {1}, does not exist in the table.
Warning.4=Column {0}, specified to be ignored in table {1}, does not exist in the table.
Warning.5=Column {0}, specified as an identity column in table {1}, does not exist in the table.
Warning.6=Column {0}, specified as a generated key column in table {1}, does not exist in the table.
Warning.7=XML Parser Warning on line {0}: {1}
Warning.9=The specified target project directory {0} does not exist
Warning.10=Cannot create directory {0}
Warning.11=Existing file {0} was overwritten
Warning.12=The existing XML file {0} is not the same format as the generated file. \
The existing file will not be changed.
Warning.13=Exception while attempting to merge the XML file {0}. \
The existing file will not be changed.
Warning.14=Unsupported Data Type {0} in table {1}, column: {2}, property defaults to Object type.
Warning.15=Cannot obtain primary key information from the database, generated objects may be incomplete
Warning.16=Invalid value for exampleMethodVisibility specified ({0}), defaulting to public
Warning.17=Cannot instantiate DAO method name calculator of type {0}, using default calculator
Warning.18=Table {0} contains only LOB fields, this table will be ignored
Warning.19=Table configuration with catalog {0}, schema {1}, and table {2} did not resolve to any tables
Warning.20=Root class {0} cannot be loaded, checking for member overrides is disabled for this class
Warning.21=Property {0} exists in root class {1}, but is not of type {2}. MyBatis Generator will generate the property.
Warning.22=Property {0} exists in root class {1}, but does not have a getter. MyBatis Generator will generate the property.
Warning.23=Property {0} exists in root class {1}, but does not have a setter. MyBatis Generator will generate the property.
Warning.24=Plugin {0} in context {1} is invalid and will be ignored.
Warning.25=Table Configuration {0} matched more than one table ({1}) Progress.0=Connecting to the Database
Progress.1=Introspecting table {0}
Progress.3=XML Parser Errors occurred:
Progress.4=MyBatis Generator finished successfully.
Progress.5=MyBatis Generator finished successfully, there were warnings.
Progress.6=Generating Example class for table {0}
Progress.7=Generating Primary Key class for table {0}
Progress.8=Generating Record class for table {0}
Progress.9=Generating Record class (with BLOBs) for table {0}
Progress.12=Generating SQL Map for table {0}
Progress.13=Found SQL Statement: {0}
Progress.14=Generating DAO Interface and Implementation for table {0}
Progress.15=Saving file {0}
Progress.16=Invalid configuration. Details follow...
Progress.17=Generating Mapper Interface for table {0}
Progress.18=Generating SQL Provider for table {0} Tracing.1=Retrieving column information for table "{0}"
Tracing.2=Found column "{0}", data type {1}, in table "{2}"
Tracing.3=Removing column "{0}" in table "{1}" because it is ignored by configuration
Tracing.4=Found override for column "{0}" in table "{1}" Usage.Lines=27
Usage.0=MyBatis Generator - a code generator for MyBatis and iBATIS. Usage:
Usage.1=\ java -jar mybatis-generator-core-x.x.x.jar -configfile file_name
Usage.2=\ [-overwrite] [-contextids ids] [-tables tableNames]
Usage.3=\ [-forceJavaLogging] [-verbose] [-?|-h]
Usage.4=
Usage.5=Where:
Usage.6=\ -configfile: Specifies the name of the XML configuration file (required)
Usage.7=
Usage.8=\ -overwrite: If specified then existing Java files will be overwritten.
Usage.9=\ If not specified, then the generator will not overwrite
Usage.10=\ existing Java files (will save results in uniquely named files)
Usage.11=
Usage.12=\ -contextids: Used to specify a comma delimited list of contexts to use in
Usage.13=\ this invocation. If not specified, all contexts will be used.
Usage.14=
Usage.15=\ -tables: Used to specify a comma delimited list of tables to use in this
Usage.16=\ invocation. If not specified, all tables will be used. Table
Usage.17=\ names must be fully qualified (e.g. schema.tablename). Table names
Usage.18=\ must exactly match the case specified in the configuration file.
Usage.19=
Usage.20=\ -forceJavaLogging: Force the use of standard Java logging even if Log4J is
Usage.21=\ is available in the runtime classpath. If not specified,
Usage.22=\ Log4J will be used if it is available at runtime.
Usage.23=
Usage.24=\ -verbose: If specified, write progress messages to the console.
Usage.25=
Usage.26=\ -?|-h: Display this help text and exit.

  

java 中 ResourceBundle 使用 国际化使用的更多相关文章

  1. Java中resourceBundle和Properties的区别

    第一种办法InputStream is = Test.class.getResourceAsStream("DbConfig.properties");Properties p = ...

  2. java.util.ResourceBundle 读取国际化资源或配置文件

    1.定义三个资源文件,放到src的根目录下面 命名规范是: 自定义名_语言代码_国别代码.properties 默认 : 自定义名.properties   2.资源文件都必须是ISO-8859-1编 ...

  3. [Java 进阶]Java中的国际化

    背景知识 现代软件开发,往往做出的应用程序不止给一个国家的人去使用.不同国家的人往往存在语言文字不通的问题.由此产生了国际化(internationalization).多语言(multi-langu ...

  4. 国际化,java.util.ResourceBundle使用详解

    java.util.ResourceBundle使用详解   一.认识国际化资源文件   这个类提供软件国际化的捷径.通过此类,可以使您所编写的程序可以:          轻松地本地化或翻译成不同的 ...

  5. Java中的国际化

    一.什么是国际化? 国际化是指应用程序运行时,可根据客户端请求来自的国家/地区.语言的不同而显示不同的界面. 二.Java如何实现国际化? Java程序的国际化思路是将程序中的标签.提示等信息放在资源 ...

  6. JAVA WEB开发中的资源国际化

    为什么要国际化? 不同国家与地区语言,文化,生活习惯等差异.在数字,时间,语言,货币,日期,百分数等的不同. 两个名词: I18N:即资源国际化,全称为Internationalization,因为首 ...

  7. Java 中的国际化

    国际化 ,英文叫 internationalization 单词太长 ,又被简称为 i18n(取头取尾中间有18个字母)不经大声呼喊 ,这都行 !接着看什么是国际化 , 国际化是指让产品或是程序在无需 ...

  8. java基础---->java中国际化的实现

    应用程序的功能和代码设计考虑在不同地区运行的需要,其代码简化了不同本地版本的生产.开发这样的程序的过程,就称为国际化.今天,我们就开始学习java中国际化的代码实现. Java国际化主要通过如下3个类 ...

  9. java:jsp: ResourceBundle国际化多语言

    java提供了一个资源类java.util.ResourceBundle来试下多国语言版本.其实ResourceBundle只是一个抽象的类,她有两个子类:ListResourceBundle,和,P ...

随机推荐

  1. emoji

    嗯...闲的... emoji:(博客园的markdown支持emoji编码...惊了) http://getemoji.com/ http://www.fhdq.net/emoji/emojifuh ...

  2. 上海交大ACM总教头俞勇讲述“最聪明人的故事”

    这是一场世界大学生之间"最强大脑"的较量:这是拥有数十年历史的ACM国际大学生计算机程序设计大赛的赛场:斯坦福.加州理工.麻省理工.哈佛--当一个又一个在计算机科学领域拥有世界顶尖 ...

  3. error: RPC failed

    error: RPC failed error: RPC failed; curl 56 GnuTLS recv error (-54): Error in the pull function. fa ...

  4. [NOIP2018]普及组初赛题解

    老师布置的作业,借博客这个平台一用 [总体感觉]对我而言比去年的难度大……特别是最后一题. 选择题 1.D 打印机属于输出设备 2.D 将全部进制转换为10进制进行对比,我的方法是每一位乘以进制的位数 ...

  5. [jzoj]3760.【BJOI2014】Euler

    Link https://jzoj.net/senior/#main/show/3760 Description 欧拉函数  φ(n)  定义为不超过正整数 n 并且与 n 互素的整数的数目. 可以证 ...

  6. 新浪SAE创建微信模板消息应用与SVN的使用

    本地项目源文件必须放在应用名目录下面的数字目录里面.如:D:\SVN\xtmp1\1 我们在前面讲述在新浪SAE中如何建站,今天我们来详解如何上传文件.新浪SAE中是不允许用FTP来上传的.我们只能用 ...

  7. HTML5上传下载

    前言 HTML5 中提供的文件API在前端中有着丰富的应用,上传.下载.读取内容等在日常的交互中很常见.而且在各个浏览器的兼容也比较好,包括移动端,除了 IE 只支持 IE10 以上的版本.想要更好地 ...

  8. poj3258 River Hopscotch(二分最小值,好题)

    https://vjudge.net/problem/POJ-3258 二分最小值,判断需要删去的点的个数,如果大于给定,则直接return 0,则说明该数需要再小. 最后注意,起点是0终点是l,起点 ...

  9. 唯美PS转手绘之SAI篇_百度经验

    唯美PS转手绘之SAI篇 https://jingyan.baidu.com/article/fd8044fad3d5c05030137a5f.html

  10. APP中的图片如何长按可以下载并保存图片到相册

    直接上图 方式一: 实现方式二: 方式三: