-
Notifications
You must be signed in to change notification settings - Fork 18
io microsphere i18n AbstractResourceServiceMessageSource
Type: Class | Module: microsphere-i18n-core | Package: io.microsphere.i18n | Since: 1.0.0
Source:
microsphere-i18n-core/src/main/java/io/microsphere/i18n/AbstractResourceServiceMessageSource.java
Abstract Resource ServiceMessageSource Class that loads messages from resources
keyed by Locale.
`// Typically used through DefaultServiceMessageSource
DefaultServiceMessageSource source = new DefaultServiceMessageSource("test");
source.init();
Map> messages = source.getLocalizedResourceMessages();
// messages keyed by resource name, e.g. "META-INF/i18n/test/i18n_messages_zh_CN.properties"
`
public abstract class AbstractResourceServiceMessageSource extends AbstractServiceMessageSource implementsAuthor: Mercy
-
Introduced in:
1.0.0 -
Current Project Version:
0.2.17-SNAPSHOT
This component is tested and compatible with the following Java versions:
| Java Version | Status |
|---|---|
| Java 17 | ✅ Compatible |
| Java 21 | ✅ Compatible |
| Java 25 | ✅ Compatible |
// Typically used through DefaultServiceMessageSource
DefaultServiceMessageSource source = new DefaultServiceMessageSource("test");
source.init();
Map<String, Map<String, String>> messages = source.getLocalizedResourceMessages();
// messages keyed by resource name, e.g. "META-INF/i18n/test/i18n_messages_zh_CN.properties"String resource = source.getResource(Locale.ENGLISH);
// e.g. "META-INF/i18n/test/i18n_messages_en.properties"Map<String, String> messages = source.getMessages(Locale.SIMPLIFIED_CHINESE);
// e.g. {"test.a": "测试-a", "test.hello": "您好,{}"}DefaultServiceMessageSource source = new DefaultServiceMessageSource("test");
source.init();
Map<String, Map<String, String>> all = source.getLocalizedResourceMessages();
// 2 entries for zh_CN and en localesAdd the following dependency to your pom.xml:
<dependency>
<groupId>io.github.microsphere-projects</groupId>
<artifactId>microsphere-i18n-core</artifactId>
<version>${microsphere-i18n.version}</version>
</dependency>Tip: Use the BOM (
microsphere-i18n-dependencies) for consistent version management. See the Getting Started guide.
import io.microsphere.i18n.AbstractResourceServiceMessageSource;| Method | Description |
|---|---|
getResource |
The default prefix of of message resource name |
getResources |
Builds the resource name for the given Locale. |
public String getResource(Locale locale)The default prefix of of message resource name / public static final String DEFAULT_RESOURCE_NAME_PREFIX = "i18n_messages_";
/** The default suffix of message resource name / public static final String DEFAULT_RESOURCE_NAME_SUFFIX = ".properties";
private volatile Map> localizedResourceMessages = emptyMap();
/** Constructs with the given source identifier.
public final Set<String> getResources()Builds the resource name for the given Locale.
This documentation was auto-generated from the source code of microsphere-i18n.
i18n-core
- AbstractResourceServiceMessageSource
- AbstractServiceMessageSource
- CompositeServiceMessageSource
- DefaultServiceMessageSource
- EmptyServiceMessageSource
- I18nUtils
- MessageUtils
- PropertiesResourceServiceMessageSource
- ReloadableResourceServiceMessageSource
- ResourceServiceMessageSource
- ServiceMessageException
- ServiceMessageSource
i18n-openfeign
i18n-spring
- AcceptHeaderLocaleResolverBeanPostProcessor
- DelegatingServiceMessageSource
- EnableI18n
- I18nApplicationListener
- I18nBeanUtils
- I18nConstants
- I18nImportBeanDefinitionRegistrar
- I18nLocalValidatorFactoryBeanPostProcessor
- LocaleUtils
- MessageSourceAdapter
- PropertySourcesServiceMessageSource
- ResourceServiceMessageSourceChangedEvent
- ServiceMessageSourceBeanLifecyclePostProcessor
- ServiceMessageSourceFactoryBean
i18n-spring-boot
i18n-spring-cloud
i18n-spring-cloud-server