{"id":19893067,"url":"https://github.com/alaugks/spring-messagesource-catalog","last_synced_at":"2026-05-05T08:35:28.006Z","repository":{"id":239627977,"uuid":"798825272","full_name":"alaugks/spring-messagesource-catalog","owner":"alaugks","description":"This package extends the AbstractMessageSource and therefore the MessageSource interface.","archived":false,"fork":false,"pushed_at":"2025-02-18T22:21:53.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"0.4","last_synced_at":"2025-02-18T22:34:16.423Z","etag":null,"topics":["internationalization","messagesource","spring","spring-boot","springboot"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alaugks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-10T14:51:26.000Z","updated_at":"2024-10-23T11:30:39.000Z","dependencies_parsed_at":"2024-05-13T18:28:01.118Z","dependency_job_id":"0509a03d-b353-4916-b8de-dc2b468ce536","html_url":"https://github.com/alaugks/spring-messagesource-catalog","commit_stats":null,"previous_names":["alaugks/spring-messagesource-base","alaugks/spring-messagesource-catalog"],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alaugks%2Fspring-messagesource-catalog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alaugks%2Fspring-messagesource-catalog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alaugks%2Fspring-messagesource-catalog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alaugks%2Fspring-messagesource-catalog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alaugks","download_url":"https://codeload.github.com/alaugks/spring-messagesource-catalog/tar.gz/refs/heads/0.4","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241321872,"owners_count":19944033,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["internationalization","messagesource","spring","spring-boot","springboot"],"created_at":"2024-11-12T18:27:16.115Z","updated_at":"2026-05-05T08:35:22.965Z","avatar_url":"https://github.com/alaugks.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Package to create a custom Spring MessageSource\n\nThis package extends the AbstractMessageSource and therefore the MessageSource interface. \n\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=alaugks_spring-messagesource-base\u0026metric=alert_status\u0026token=3d2b79af1f0f0ab6089e565495b4db6f621e9a13)](https://sonarcloud.io/summary/overall?id=alaugks_spring-messagesource-base)\n[![Maven Central](https://img.shields.io/maven-central/v/io.github.alaugks/spring-messagesource-catalog.svg?label=Maven%20Central)](https://central.sonatype.com/artifact/io.github.alaugks/spring-messagesource-catalog/0.4.0)\n\n## Dependency\n\n\u003e [!IMPORTANT]  \n\u003e There may still be a breaking change in the [CatalogInterface.build()](src/main/java/io/github/alaugks/spring/messagesource/catalog/catalog/CatalogInterface.java) up to version 1.0.0.\n\n### Maven\n\n```xml\n\u003cdependencies\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003eio.github.alaugks\u003c/groupId\u003e\n        \u003cartifactId\u003espring-messagesource-catalog\u003c/artifactId\u003e\n        \u003cversion\u003e0.4.0\u003c/version\u003e\n    \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\n### Gradle\n\n```\nimplementation group: 'io.github.alaugks', name: 'spring-messagesource-catalog', version: '0.4.0'\n```\n\n## Packages that use the catalog as a base package\n\n* [spring-messagesource-xliff](https://github.com/alaugks/spring-messagesource-xliff): MessageSource for translations from XLIFF files.\n* [spring-messagesource-db-example](https://github.com/alaugks/spring-messagesource-db-example): Example custom Spring MessageSource from database\n* [spring-messagesource-json-example](https://github.com/alaugks/spring-messagesource-json-example): Example custom Spring MessageSource from JSON\n\n## CatalogMessageSource Configuration\n\n### Options\n\n`builder(CatalogInterface catalogSource, Locale defaultLocale)` (required)\n\n* Argument `CatalogInterface catalogSource`: CatalogInterface\u003cbr\u003e\n* Argument `Locale defaultLocale`: Default Locale\n\n`defaultDomain(String defaultDomain)`\n* If the default domain not set, the default is **messages**.\n\n### TransUnit Record\n\nIf the `String domain` argument is not set, the default is the **messages** domain.\n\n```java\nTransUnit(Locale locale, String code, String value);\n\nTransUnit(Locale locale, String code, String value, String domain);\n```\n\n\n### Configuration example\n\n#### MessageConfig with List of TransUnits \n\n```java\nimport io.github.alaugks.spring.messagesource.catalog.catalog.CatalogHandler;\nimport io.github.alaugks.spring.messagesource.catalog.records.TransUnitInterface;\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.Locale;\nimport org.springframework.context.MessageSource;\nimport org.springframework.context.annotation.Bean;\nimport org.springframework.context.annotation.Configuration;\n\n@Configuration\npublic class MessageConfig {\n    \n    List\u003cTransUnitInterface\u003e transUnits = new ArrayList\u003c\u003e() {{\n        // en\n        add(new TransUnit(Locale.forLanguageTag(\"en\"), \"headline\", \"Headline\"));\n        add(new TransUnit(Locale.forLanguageTag(\"en\"), \"postcode\", \"Postcode\"));\n        add(new TransUnit(Locale.forLanguageTag(\"en\"), \"headline\", \"Payment\", \"payment\"));\n        add(new TransUnit(Locale.forLanguageTag(\"en\"), \"expiry_date\", \"Expiry date\", \"payment\"));\n\n        // en-US\n        add(new TransUnit(Locale.forLanguageTag(\"en-US\"), \"postcode\", \"Zip code\"));\n        add(new TransUnit(Locale.forLanguageTag(\"en-US\"), \"expiry_date\", \"Expiration date\", \"payment\"));\n\n        // de\n        add(new TransUnit(Locale.forLanguageTag(\"de\"), \"headline\", \"Überschrift\"));\n        add(new TransUnit(Locale.forLanguageTag(\"de\"), \"postcode\", \"Postleitzahl\"));\n        add(new TransUnit(Locale.forLanguageTag(\"de\"), \"headline\", \"Zahlung\", \"payment\"));\n        add(new TransUnit(Locale.forLanguageTag(\"de\"), \"expiry_date\", \"Ablaufdatum\", \"payment\"));\n    }};\n\n    @Bean\n    public MessageSource messageSource() {\n        return CatalogMessageSourceBuilder\n            .builder(this.transUnits, Locale.forLanguageTag(\"en\"))\n            .build();\n\t}\n}\n```\n\n#### With custom CatalogInterface\n\n##### CatalogInterface\n\n```java\nimport java.util.List;\n\nimport io.github.alaugks.spring.messagesource.catalog.catalog.AbstractCatalog;\nimport io.github.alaugks.spring.messagesource.catalog.catalog.Abstractcatalog;\nimport io.github.alaugks.spring.messagesource.catalog.records.TransUnitInterface;\n\npublic class MyCustomCatalog extends AbstractCatalog {\n\n\tList\u003cTransUnitInterface\u003e transUnits;\n\n\t@Override\n\tpublic List\u003cTransUnitInterface\u003e getTransUnits() {\n\t\treturn this.transUnits;\n\t}\n\n\t@Override\n\tpublic void build() {\n\t\t// Build a list with TransUnit from any kind of source.\n\t\tthis.transUnits = new ArrayList\u003c\u003e() {{\n\t\t\t// ...\n\t\t}};\n\t}\n}\n```\n\n##### MessageConfig\n\n```java\nimport io.github.alaugks.spring.messagesource.catalog.catalog.CatalogHandler;\nimport io.github.alaugks.spring.messagesource.catalog.records.TransUnit;\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.Locale;\nimport org.springframework.context.MessageSource;\nimport org.springframework.context.annotation.Bean;\nimport org.springframework.context.annotation.Configuration;\n\n@Configuration\npublic class MessageConfig {\n    @Bean\n    public MessageSource messageSource() {\n        return CatalogMessageSourceBuilder\n            .builder(new MyCustomCatalog(), Locale.forLanguageTag(\"en\"))\n            .build();\n\t}\n}\n```\n\n### Target values\n\nThe behaviour of resolving the target value based on the code is equivalent to the ResourceBundleMessageSource or ReloadableResourceBundleMessageSource.\n\n\u003ctable\u003e\n  \u003cthead\u003e\n  \u003ctr\u003e\n    \u003cth\u003ecode\u003c/th\u003e\n    \u003cth\u003een\u003c/th\u003e\n    \u003cth\u003een-US\u003c/th\u003e\n    \u003cth\u003ede\u003c/th\u003e\n    \u003cth\u003ejp***\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eheadline*\u003cbr\u003emessages.headline\u003c/td\u003e\n    \u003ctd\u003eHeadline\u003c/td\u003e\n    \u003ctd\u003eHeadline**\u003c/td\u003e\n    \u003ctd\u003eÜberschrift\u003c/td\u003e\n    \u003ctd\u003eHeadline\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003epostcode*\u003cbr\u003emessages.postcode\u003c/td\u003e\n    \u003ctd\u003ePostcode\u003c/td\u003e\n    \u003ctd\u003eZip code\u003c/td\u003e\n    \u003ctd\u003ePostleitzahl\u003c/td\u003e\n    \u003ctd\u003ePostcode\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003epayment.headline\u003c/td\u003e\n    \u003ctd\u003ePayment\u003c/td\u003e\n    \u003ctd\u003ePayment**\u003c/td\u003e\n    \u003ctd\u003eZahlung\u003c/td\u003e\n    \u003ctd\u003ePayment\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003epayment.form.expiry_date\u003c/td\u003e\n    \u003ctd\u003eExpiry date\u003c/td\u003e\n    \u003ctd\u003eExpiration date\u003c/td\u003e\n    \u003ctd\u003eAblaufdatum\u003c/td\u003e\n    \u003ctd\u003eExpiry date\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003e *Default domain is `messages`.\n\u003e\n\u003e **Example of a fallback from Language_Region (`en-US`) to Language (`en`). The `id` does not exist in `en-US`, so it tries to select the translation with locale `en`.\n\u003e \n\u003e ***There is no translation for Japanese (`jp`). The default locale transUnits (`en`) are selected.\n\n\n## Support\n\nIf you have questions, comments or feature requests please use the [Discussions](https://github.com/alaugks/spring-messagesource-catalog/discussions) section.\n\n\u003ca name=\"a8\"\u003e\u003c/a\u003e\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falaugks%2Fspring-messagesource-catalog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falaugks%2Fspring-messagesource-catalog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falaugks%2Fspring-messagesource-catalog/lists"}