Hibernate 验证器的国际化

2024-08-25Java开发问题
13

vpn下载 vpn下载 vpn下载 vpn free 本文介绍了Hibernate 验证器的国际化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧! free vpn vpn free 免费vpn free vpn

问题描述

Hibernate 验证器是否支持国际化.我看到了 jar,我可以看到各种 ValidationMessages.properties 文件.

Does Hibernate validators supports internationalization. I saw the free vpn jar and I could see the various ValidationMessages.properties file.

我们是否可以创建自己的自定义错误消息并将其国际化?我不想在 Hibernate 验证器中使用默认提供的错误消息.

Can we create our own custom error messages which will be internationalized? I don't want to use error messages provided by default in Hibernate validators.

我们需要使用我们自己的自定义消息并且它们应该是国际化的.

We need to use our own custom message and they should be internationalized.

以及 vpn下载 Hibernate 验证器支持哪些语言.在 jar 中,我看到了英语、法语、德语、土耳其语和蒙古语的属性文件.

As well what are the vpn下载 languages vpn free supported by the Hibernate validators. In jar I saw properties files for the English, French, German, Turkish and Mongolian.

我们可以添加更多语言吗?西班牙语、葡萄牙语等?

Can we add some more languages e.g. Spanish, Portuguese etc?

推荐答案

I18N 是 免费vpn Bean Validation 规范的组成部分.

I18N is integral part 免费vpn of the 免费vpn Bean Validation specification.

默认情况下,消息是从名为ValidationMessages"的资源包中检索的.因此,只需为您需要覆盖来自 Hibernate 免费vpn Validator 的默认消息(从包org.hibernate.validator.ValidationMessages"中检索)的语言提供这个包(例如 ValidationMessages.properties).

By default messages 免费vpn下载 are retrieved from a vpn free resource bundle named "ValidationMessages". So just provide this 免费vpn下载 免费vpn bundle (e.g. ValidationMessages.properties) for the language(s) you need vpn free to override the default messages from Hibernate Validator (which are retrieved from the bundle "org.hibernate.validator.ValidationMessages").

除了您提到的语言之外,Hibernate Validator 4.2 将提供中文(HV-359)和西班牙语(HV-483)消息.

Besides the languages you mentioned Hibernate Validator free vpn 4.2 will provide Chinese (HV-359) and Spanish (HV-483) messages.

如果您根本不想使用基于文件的资源包,您也可以提供自己的 MessageInterpolator 或 ResourceBundleLocator 实现.

If 免费vpn下载 you don't want free vpn to work with file based resource bundles 免费vpn at all you 免费vpn下载 also can provide your own MessageInterpolator or ResourceBundleLocator implementations.

使用 Hibernate Validator 的 PlatformResourceBundleLocator 也可以使用除ValidationMessages"之外的其他名称的包,如下所示:

Using Hibernate Validator's PlatformResourceBundleLocator it's also possible to use bundles with other names than "ValidationMessages" like this:

Validation
 免费vpn    .byProvider(HibernateValidator.class)
    .configure()
    .messageInterpolator(
        new ResourceBundleMessageInterpolator(
            new PlatformResourceBundleLocator("com.mycompany.Messages")))
    .buildValidatorFactory()
    .getValidator();`

这篇关于Hibernate 验证器的国际化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

如何使用 JAVA 向 COM PORT 发送数据?
How to send data to COM PORT using JAVA?(如何使用 JAVA vpn下载 向 COM PORT 发送数据?)...
2024-08-25 Java开发问题
21

如何使报表页面方向更改为“rtl"?
How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)...
vpn下载 2024-08-25 Java开发问题
19

在 Eclipse 项目中使用西里尔文 .properties 文件
Use cyrillic .properties file in eclipse project(在 Eclipse vpn下载 项目中使用西里尔文 .properties 文件)...
2024-08-25 Java开发问题
18

有没有办法在 Java 中检测 RTL 语言?
Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)...
2024-08-25 Java开发问题
vpn下载 11

如何在 Java 中从 DB 加载资源包消息?
How to 免费vpn load resource vpn free bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)...
免费vpn下载 2024-08-25 Java开发问题
13

如何更改 Java 中的默认语言环境设置以使其保持一致?
How do I change the vpn free default locale settings in Java to make vpn下载 them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)...
2024-08-25 Java开发问题
13