-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support additional file formats in ReloadableResourceBundleMessageSource
#18990
Comments
Bulk closing outdated, unresolved issues. Please, reopen if still relevant. |
I would say it's relevant! |
I think this is relevant too. All my application is YAML configured (properties, liquibase..) excepted messages. It's really frustrating. |
Is it possible to reopen an issue? |
i think it is relevant too |
It's relevant! |
any updates on this? |
Really waiting for it!!! It's relevant! |
At least tell us when will this be resolved. |
This issue still relevant |
I am here too. Seems relevant to me |
Nice issue |
I really like this issue! 💕 |
look forward |
I would really appreciate this feature! |
@christian-kocke I found a repo with a work around of this issue, hope it helps. |
it is relevant for sure! |
yes, it's relevant |
From which version of Spring Boot is this feature available ? Any resource available with example of its usage would be nice. |
@Thanthu, this issue is still open, which means that the feature has not been released yet. |
ResourceBundleMessageSource
[SPR-14419]ResourceBundleMessageSource
This commit allows to configure custom file extensions in ReloadableResourceBundleMessageSource thanks to a new setFileExtensions setter. Combined with setPropertiesPersister, it allows custom implementations supporting any kind of property file. Closes spring-projectsgh-18990
ResourceBundleMessageSource
ReloadableResourceBundleMessageSource
ReloadableResourceBundleMessageSource
ReloadableResourceBundleMessageSource
Thanks everybody for your patience, this issue should be be fixed by this commit. I was a bit confused initially by the fact that the description of the changes proposed looked irrelevant to In Since it seems to be a popular use case, I have implemented an example of YAML resource bundle support in https://github.com/sdeleuze/demo-yaml-message-source. The important bits are the @Bean
public MessageSource messageSource() {
ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
messageSource.setBasename("classpath:messages");
messageSource.setPropertiesPersister(new YamlPropertiesLoader());
messageSource.setFileExtensions(List.of(".yml", ".yaml"));
return messageSource;
} Spring does not provide such out-of-the box YAML support yet, but hopefully that can serve as an example for the community for how to leverage this feature, and will allow the Spring team to observe how the community leverages those capabilities, which implementations get traction, etc. |
this issue has been closed. does that mean Spring framework out of the box finally support yaml format for message source? |
if out the box is supported, does spring boot able to autoconfigure to support both yaml and properties, instead of developer having to write codes to configure them. |
@hannah23280, please read the closing comments for an issue before asking a question. This was answered in the comment immediately preceding yours.
|
Currently is already 6.1.x, i look through the changes , but could not see anything mentioning this. |
@hannah23280 we don't list all changes on this page. This feature has been delivered with milestone 4 as listed on this page and the release notes: https://github.com/spring-projects/spring-framework/releases/tag/v6.1.0-M4 |
Thanks! Saw it. That means ReloadableResourceBundleMessageSource can support additional file formats. Hopefully spring boot will autoconfigure it to include yaml , without us developer having to manually do it |
@hannah23280 I'm not sure what feature you're expecting in Spring Boot, but there's nothing scheduled at the moment in that area. |
Since it is possible for ReloadableResourceBundleMessageSource to support additional file formats, and given the popular usage of yaml, so i thought i'ts might be a matter of time Spring Boot will autoconfigure the ReloadableResourceBundleMessageSource to include yaml as well, so that developers don't have to do it themselves. |
I tried your implementation and it works IFF one uses the yml with a flat list of attributes. But isn't the entire point of yml vs. properties file to have a more object oriented way to specify i8n texts? So working with this:
Only the first one works with Thymeleaf using |
@sascha08-15 public class YamlPropertiesLoader implements PropertiesPersister {
@Override
public void load(Properties props, InputStream is) {
// YamlMapFactoryBean yaml = new YamlMapFactoryBean();
YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
yaml.setResources(new InputStreamResource(is));
props.putAll(yaml.getObject());
} |
@Aniokrait Thanks for the quick answer! Works like a charm now! |
Loïc Dreux opened SPR-14419 and commented
ReloadableResourceBundleMessageSource
could store and load Properties with a custom implementation of the PropertiesPersister like YamlPropertiesPersister.java but the extensions ".properties" and ".xml" are hard coded in Java Source.A good solution could be to add a property "customExtension" to support other file format like yaml.
Affects: 4.2.6
The text was updated successfully, but these errors were encountered: