由于公司业务需求,需要支持中英两个版本的返回提示信息,使用spring的MessageSource类获取对应语种的i18n文件的提示信息。 i18n(其来源是英文单词 internationalization的首末字符i和n,18为中间的字符数)是“国际化”的简称。在资讯领域,国际化(i18n)指让产品(无需做大的改变就能够适应不同的语言和地区的需要。对程序来说,在不修改内部代码的情况下,能根据不同语言及地区显示相应的界面。 在全球化的时代,国际化尤为重要,因为产品的潜在用户可能来自世界的各个角落。通常与i18n相关的还有L10n(“本地化”的简称)。 为节省代码量使用了lombok插件,在pom.xml引入 <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </dependency> 查看MessageSource源码可以看到该接口提供了三个方法,我们使用第二个即可。 public interface MessageSource { @Nullable String...
Is this you? As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.
Claim your profile
Articles by .set UseCodeAsDefault Message
Actions
Is this you?
As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.Get in touch with .set UseCodeAsDefault
Contact .set UseCodeAsDefault, search articles and posts on X, monitor coverage, and track replies from one place.
Learn more about Muck Rack