@Target({PACKAGE,TYPE})
@Retention(SOURCE)
@Repeatable(RepeatableMessages.class)
public @interface Messages
Annotation for
GenerateMessagesFromProperties
.
// EXAMPLE ANNOTATION
// planets.properties
// planet-event=At {1,time} on {1,date}, there was {2} on planet {0,number,integer}.
// planets_de.properties
// planet-event=Am {1,time} um {1,date} Uhr gab es {2} auf Planet {0,number,integer}.
@Messages("planets.properties")
// EXAMPLE CODE
var time = ZonedDateTime.now();
String event = Planets.planetEvent(locale, 4, time, "an attack");
See Backing a ResourceBundle
with Properties Files for more information on localization.
This annotation is strict by default.
This helps build systems detect missing translations and bugs in translated format strings.
However, developers are likely add or modify strings during development before translations are available.
The missingKey()
and incompatibleFormat()
properties can be set to Severity.WARN
or Severity.IGNORE
during development to avoid breaking builds.
Create a single static final Severity
variable and reference it in annotations to control this globally.
Set these to Severity.ERROR
prior to release and/or in a "smoke test" branch.
-
Optional Element Summary
Modifier and TypeOptional ElementDescriptionboolean
Generate format signatures.How to handle incompatible format string in localized files.boolean
Generated code visibility.boolean
Search for localized properties.How to handle missing keys in localized files.Common processing instructions.String[]
Resource files.
-
Element Details
-
value
String[] valueResource files.- Returns:
- resources
- Default:
{}
-
processing
Processing processingCommon processing instructions.- Returns:
- instruction annotation
- Default:
@uk.autores.Processing(namer=uk.autores.naming.IdiomaticNamer.class)
-
isPublic
boolean isPublicGenerated code visibility.- Returns:
- visibility
- Default:
false
-
localize
boolean localizeSearch for localized properties.- Returns:
- whether to localize
- Default:
true
-
format
boolean formatGenerate format signatures.- Returns:
- whether to format
- Default:
true
-
missingKey
Severity missingKeyHow to handle missing keys in localized files. Only applies whenlocalize()
is true.- Returns:
- error severity
- Default:
ERROR
-
incompatibleFormat
Severity incompatibleFormatHow to handle incompatible format string in localized files. Only applies whenformat()
is true.- Returns:
- error severity
- Default:
ERROR
-