-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Qute message bundles: fix localization of enums
- support constants with underscores - fixes #44866
- Loading branch information
Showing
8 changed files
with
167 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...t/src/test/java/io/quarkus/qute/deployment/i18n/MessageBundleInvalidEnumConstantTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package io.quarkus.qute.deployment.i18n; | ||
|
||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.qute.TemplateEnum; | ||
import io.quarkus.qute.deployment.MessageBundleException; | ||
import io.quarkus.qute.i18n.Message; | ||
import io.quarkus.qute.i18n.MessageBundle; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class MessageBundleInvalidEnumConstantTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot(root -> root | ||
.addClasses(Messages.class, UnderscoredEnum.class) | ||
.addAsResource("messages/enu_invalid.properties")) | ||
.setExpectedException(MessageBundleException.class, true); | ||
|
||
@Test | ||
public void testMessages() { | ||
fail(); | ||
} | ||
|
||
@TemplateEnum | ||
public enum UnderscoredEnum { | ||
|
||
A_B, | ||
|
||
} | ||
|
||
@MessageBundle(value = "enu_invalid") | ||
public interface Messages { | ||
|
||
@Message | ||
String underscored(UnderscoredEnum constants); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
extensions/qute/deployment/src/test/resources/messages/enu_invalid.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
underscored_$A_B=A/B | ||
underscored_$FOO_BAR_BAZ=Foo/Bar/Baz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters