Skip to content

Commit

Permalink
Finish porting to the new i18n API. Whew!
Browse files Browse the repository at this point in the history
  • Loading branch information
gdude2002 committed Sep 18, 2024
1 parent 866d914 commit 4990e3a
Show file tree
Hide file tree
Showing 13 changed files with 509 additions and 244 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import dev.kordex.core.checks.types.CheckWithCache
import dev.kordex.core.commands.Command
import dev.kordex.core.commands.application.slash.SlashCommand
import dev.kordex.core.extensions.Extension
import dev.kordex.core.i18n.generated.CoreTranslations.NsfwLevel.default
import dev.kordex.core.i18n.types.Key
import dev.kordex.core.koin.KordExKoinComponent
import dev.kordex.core.utils.MutableStringKeyedMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import dev.kordex.core.i18n.TranslationsProvider
import dev.kordex.core.i18n.types.Key
import dev.kordex.core.koin.KordExKoinComponent
import io.github.oshai.kotlinlogging.KotlinLogging
import org.apache.commons.validator.GenericValidator.maxLength
import org.koin.core.component.inject
import java.util.*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ public data class Key(
copy(bundle = null, locale = null)

public fun translate(vararg replacements: Any?): String =
translateArray(replacements.toList().toTypedArray())
if (replacements.isNotEmpty() || ordinalPlaceholders.isNotEmpty()) {
translateArray(replacements.toList().toTypedArray())
} else {
translateNamed()
}

public fun translateArray(replacements: Array<Any?>): String {
val allReplacements = when (presetPlaceholderPosition) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import dev.kord.core.entity.VoiceState
import kotlin.reflect.KClass
import kotlin.reflect.KProperty

@Suppress("ERROR_SUPPRESSION")
public class ChangeSet(public val clazz: KClass<*>) {
private val changes: MutableMap<KProperty<*>, Change<*>> = mutableMapOf()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ class MappingsExtension : Extension() {
val pagesObj = Pages()
val pageTitle = MappingsTranslations.Response.Info.title
.withLocale(locale)
.translateNamed("mappings" to "Mojang")
.translateNamed("mappings" to "Hashed Mojang")

pages.forEach {
pagesObj.addPage(
Expand Down Expand Up @@ -535,7 +535,7 @@ class MappingsExtension : Extension() {
val pagesObj = Pages()
val pageTitle = MappingsTranslations.Response.Info.title
.withLocale(locale)
.translateNamed("mappings" to "Mojang")
.translateNamed("mappings" to "Yarn")

pages.forEach {
pagesObj.addPage(
Expand Down
7 changes: 7 additions & 0 deletions modules/functionality/func-tags/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ metadata {
description = "KordEx extra module that provides a set of commands for storing and retrieving tagged text snippets"
}

getTranslations(
"func-tags",
"dev.kordex.modules.func.tags.i18n",
"kordex.func-tags",
"TagsTranslations"
)

repositories {
maven {
name = "Sonatype Snapshots"
Expand Down
Loading

0 comments on commit 4990e3a

Please sign in to comment.