forked from MinecraftFreecam/Freecam
-
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.
Move name & description to lang files
Introduce `ModNameProcessor` & `ModDescriptionProcessor`, along with a new method `LangTask.getTranslation()` which can be used to get a specific translation after the task has finished running. Make use of this in `:data` to get the name & description from the translations into the mod metadata file. Fixes MinecraftFreecam#172
- Loading branch information
1 parent
4d2f91c
commit 2713803
Showing
6 changed files
with
111 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class ModDescriptionProcessor : LangProcessor { | ||
override fun process( | ||
modID: String, | ||
variant: String, | ||
translations: Map<String, String>, | ||
fallback: Map<String, String>? | ||
): Map<String, String> { | ||
val map = translations.toMutableMap() | ||
val firstID = "${modID}.description" | ||
val secondID = "${modID}.description.${variant}" | ||
|
||
val first = translations[firstID] ?: fallback?.get(firstID) | ||
val second = secondID.let { translations[it] ?: fallback?.get(it) } | ||
val full = listOfNotNull(first, second).joinToString(" ") | ||
|
||
map[firstID] = full | ||
map["modmenu.descriptionTranslation.${modID}"] = full | ||
first?.let { map["modmenu.summaryTranslation.${modID}"] = it } | ||
map.remove(secondID) | ||
|
||
return map | ||
} | ||
} |
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,22 @@ | ||
class ModNameProcessor : LangProcessor { | ||
override fun process( | ||
modID: String, | ||
variant: String, | ||
translations: Map<String, String>, | ||
fallback: Map<String, String>? | ||
): Map<String, String> { | ||
val map = translations.toMutableMap() | ||
val firstID = "${modID}.name" | ||
val secondID = "${modID}.name.${variant}" | ||
|
||
val first = translations[firstID] ?: fallback?.get(firstID) | ||
val second = secondID.let { translations[it] ?: fallback?.get(it) } | ||
val full = listOfNotNull(first, second).joinToString(" ") | ||
|
||
map[firstID] = full | ||
map["modmenu.nameTranslation.${modID}"] = full | ||
map.remove(secondID) | ||
|
||
return map | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
freecam.name=Freecam | ||
freecam.name.modrinth=(Modrinth Edition) | ||
freecam.description=A highly customizable freecam mod. | ||
freecam.description.modrinth=Some features have been restricted to comply with Modrinth's Content Rules. |
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