Skip to content

Commit f1d5555

Browse files
committed
Add translation key getter
1 parent 3f67d1c commit f1d5555

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

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

+7
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,11 @@ static Translatable of(String translationKey) {
3131
* Translates this translatable to the specified locale, with a fallback to en_US.
3232
*/
3333
String translate(Locale locale);
34+
35+
/**
36+
* Returns the translation key of this translatable, allowing consumers provide a custom translation.
37+
*
38+
* <p>No guarantees about the stability of this value across major library versions are made.
39+
*/
40+
String translationKey();
3441
}

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

+5
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,10 @@ public String translate(Locale locale) {
2828
return I18n.translate(translationKey, locale);
2929
}
3030

31+
@Override
32+
public String translationKey() {
33+
return translationKey;
34+
}
35+
3136
private final String translationKey;
3237
}

0 commit comments

Comments
 (0)