Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/porscheinformatik/zanata-spring
Provides a Spring MessageSource backed by a Zanata Server.
https://github.com/porscheinformatik/zanata-spring
i18n spring translation zanata
Last synced: 8 days ago
JSON representation
Provides a Spring MessageSource backed by a Zanata Server.
- Host: GitHub
- URL: https://github.com/porscheinformatik/zanata-spring
- Owner: porscheinformatik
- License: apache-2.0
- Archived: true
- Created: 2017-06-14T08:22:19.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-09-25T12:04:30.000Z (over 2 years ago)
- Last Synced: 2024-12-22T20:39:12.933Z (about 1 month ago)
- Topics: i18n, spring, translation, zanata
- Language: Java
- Size: 70.3 KB
- Stars: 4
- Watchers: 6
- Forks: 5
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Zanata Spring
This is a (very) small library providing an Spring `MessageSource` that
delagates to the [Zanata REST API](https://zanata.ci.cloudbees.com/job/zanata-api-site/site/zanata-common-api/rest-api-docs/index.html).## Usage
Add the Maven dependency to your project (find the current version on [Maven Central](https://search.maven.org/search?q=g:at.porscheinformatik.zanata%20AND%20a:zanata-spring&core=gav)):
```xml
at.porscheinformatik.zanata
zanata-spring
${zanata-spring.version}```
Then declare the `ZanataMessageSource` as a bean. You can configure the `MessageSource` via:
- zanataBaseUrl (required) - the base URL of your Zanaza instance
- project (required) - the project id
- iteration - the iteration/version of the project, if not specified "master" will be used
- baseNames - the message bundle names, if not specified ["messages"] will be usedUsually you might want to have the local message bundles as a backup when Zanata is not running. Therefore you can set
a `ResourceBundleMessageSource` as the parent of the `ZanataMessageSource`.Here is a full example bean configuration for a Spring Boot app (with "messages" as the default bundle):
```java
@Bean
public MessageSource messageSource() {
ReloadableResourceBundleMessageSource localMessageSource = new ReloadableResourceBundleMessageSource();
localMessageSource.setBasename("messages");
localMessageSource.setFallbackToSystemLocale(false);ZanataMessageSource zanataMessageSource = new ZanataMessageSource();
zanataMessageSource.setZanataBaseUrl("https://my-zanata.internal");
zanataMessageSource.setProject("MY-ZANAZA-PROJECT");
zanataMessageSource.setParentMessageSource(localMessageSource);
return zanataMessageSource;
}
```## Authentication
If your Zanata instance needs authentication for accessing translations you can call `ZanataMessageSource#useAuthentcation` or provide your own `RestTemplate` and add a `ZanataAuthenticationInterceptor`.
## Changes / Releases
See [changelog](CHANGELOG.md).