Skip to content

Commit 3f67d1c

Browse files
committed
Some API changes
1 parent b36e543 commit 3f67d1c

File tree

5 files changed

+14
-13
lines changed

5 files changed

+14
-13
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
- Made `OuterClassNamePropagator` configurable
88
- Made Enigma writer always output destination names if visited explicitly, establishing consistency across all writers
99
- Added a simplified `MappingNsCompleter` constructor for completing all destination names with the source names
10-
- Added translatable `MappingFormat#getName()`
10+
- Added `MappingFormat#translatableName()`
1111

1212
## [0.7.1] - 2025-01-07
1313
- Restored the ability to read source-namespace-only mapping files, even if not spec-compliant

src/main/java/net/fabricmc/mappingio/format/MappingFormat.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import net.fabricmc.mappingio.format.FeatureSet.FeaturePresence;
2525
import net.fabricmc.mappingio.format.FeatureSet.MetadataSupport;
2626
import net.fabricmc.mappingio.i18n.Translatable;
27-
import net.fabricmc.mappingio.i18n.TranslatableImpl;
2827

2928
/**
3029
* Represents a supported mapping format. Every format can be assumed to have an associated reader available.
@@ -281,7 +280,7 @@ public enum MappingFormat {
281280

282281
MappingFormat(@Nullable String fileExt, boolean hasWriter, FeatureSetBuilder featureBuilder) {
283282
this.translationKey = "format." + name().toLowerCase(Locale.ROOT);
284-
this.name = getName().translate(Locale.US);
283+
this.name = translatableName().translate(Locale.US);
285284
this.fileExt = fileExt;
286285
this.hasWriter = hasWriter;
287286
this.features = featureBuilder.build();
@@ -292,8 +291,8 @@ public enum MappingFormat {
292291
this.supportsLocals = features.supportsVars();
293292
}
294293

295-
public Translatable getName() {
296-
return new TranslatableImpl(translationKey);
294+
public Translatable translatableName() {
295+
return Translatable.of(translationKey);
297296
}
298297

299298
public FeatureSet features() {
@@ -314,7 +313,7 @@ public String getGlobPattern() {
314313
private final String translationKey;
315314
private final FeatureSet features;
316315
/**
317-
* @deprecated Use {@link #getName()} instead.
316+
* @deprecated Use {@link #translatableName()} instead.
318317
*/
319318
@Deprecated
320319
public final String name;

src/main/java/net/fabricmc/mappingio/i18n/Translatable.java

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222

2323
@ApiStatus.NonExtendable
2424
public interface Translatable {
25+
@ApiStatus.Internal
26+
static Translatable of(String translationKey) {
27+
return new TranslatableImpl(translationKey);
28+
}
29+
2530
/**
2631
* Translates this translatable to the specified locale, with a fallback to en_US.
2732
*/

src/main/java/net/fabricmc/mappingio/i18n/TranslatableImpl.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@
1818

1919
import java.util.Locale;
2020

21-
import org.jetbrains.annotations.ApiStatus;
22-
23-
@ApiStatus.Internal
24-
public final class TranslatableImpl implements Translatable {
25-
public TranslatableImpl(String translationKey) {
21+
final class TranslatableImpl implements Translatable {
22+
TranslatableImpl(String translationKey) {
2623
this.translationKey = translationKey;
2724
}
2825

src/test/java/net/fabricmc/mappingio/test/tests/i18n/I18nTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ public static void init() throws Exception {
5454
@SuppressWarnings("deprecation")
5555
public void mappingFormatNames() {
5656
for (MappingFormat format : MappingFormat.values()) {
57-
String enUsName = format.getName().translate(Locale.US);
57+
String enUsName = format.translatableName().translate(Locale.US);
5858
assertEquals(enUsName, format.name);
5959

6060
for (Locale locale : supportedLocales) {
61-
String translatedName = format.getName().translate(locale);
61+
String translatedName = format.translatableName().translate(locale);
6262
assertFalse(translatedName.startsWith("format."), "Translated name for " + format + " in " + locale + " is missing");
6363
}
6464
}

0 commit comments

Comments
 (0)