forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request quarkusio#30391 from mkouba/issue-30382
Qute type-safe messages - support resource bundle naming convention
- Loading branch information
Showing
5 changed files
with
68 additions
and
8 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
53 changes: 53 additions & 0 deletions
53
...nt/src/test/java/io/quarkus/qute/deployment/i18n/LocalizedFileResourceBundleNameTest.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,53 @@ | ||
package io.quarkus.qute.deployment.i18n; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.qute.Template; | ||
import io.quarkus.qute.i18n.Localized; | ||
import io.quarkus.qute.i18n.Message; | ||
import io.quarkus.qute.i18n.MessageBundle; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class LocalizedFileResourceBundleNameTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot(root -> root.addClass(Messages1.class) | ||
.addAsResource(new StringAsset("{msg:hello}"), "templates/foo.html") | ||
.addAsResource(new StringAsset("hello=Hello!"), "messages/msg_en_US.properties") | ||
.addAsResource(new StringAsset("hello=Ahoj!"), "messages/msg_cs_CZ.properties")) | ||
.overrideConfigKey("quarkus.default-locale", "en-US"); | ||
|
||
@Inject | ||
Messages1 messages; | ||
|
||
@Localized("cs-CZ") | ||
Messages1 csMessages; | ||
|
||
@Inject | ||
Template foo; | ||
|
||
@Test | ||
public void testLocalizedFile() { | ||
assertEquals("Hello!", messages.hello()); | ||
assertEquals("Ahoj!", csMessages.hello()); | ||
|
||
assertEquals("Hello!", foo.instance().render()); | ||
assertEquals("Ahoj!", foo.instance().setAttribute("locale", "cs-CZ").render()); | ||
} | ||
|
||
@MessageBundle | ||
public interface Messages1 { | ||
|
||
@Message | ||
String hello(); | ||
|
||
} | ||
|
||
} |
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