Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/content/docs/adventure/localization.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class MyTranslator implements Translator {
public @Nullable MessageFormat translate(final String key, final Locale locale) {
// You could retrieve a string from a properties file, a config file, or some other system.
// As an example, we will hard-code a check for a specific key here.
if (key.equals("mytranslation.key") && locale == Locale.US) {
if (key.equals("mytranslation.key") && Locale.US.equals(locale)) {
return new MessageFormat("Hello {0}!", locale);
} else {
// If you only want to use component translation, you can override this method and always return `null`.
Expand All @@ -84,7 +84,7 @@ public class MyTranslator implements Translator {
@Override
public @Nullable Component translate(final TranslatableComponent component, final Locale locale) {
// As above, we will hard-code a check here, but you should be reading this from elsewhere.
if (component.key().equals("mytranslation.colorful") && locale == Locale.US) {
if (component.key().equals("mytranslation.colorful") && Locale.US.equals(locale)) {
return Component.text("Hello, ", NamedTextColor.GREEN)
.append(component.arguments().stream().map(it -> it.asComponent().color(NamedTextColor.RED)).toList())
.append(component.children()) // Always make sure to copy the children over!
Expand Down
Loading