Skip to content

Commit

Permalink
1.5.4: Better encoding errors for i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
gdude2002 committed Oct 27, 2024
1 parent 632e970 commit 4c97e06
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 17 deletions.
7 changes: 7 additions & 0 deletions changes/1.5.4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Gradle Plugins 1.5.3

This version includes a small change for the KordEx plugin.

## KordEx Plugin

- For the `i18n` builder, attempt to throw a more useful error when the source translation bundle isn't using the UTF-8 encoding.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ kotlin.incremental=true
org.gradle.jvmargs=-XX:MaxMetaspaceSize=1024m
org.gradle.parallel=true

projectVersion=1.5.3
projectVersion=1.5.4
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import dev.kordex.i18n.generator.TranslationsClass
import org.gradle.api.Project
import org.gradle.api.tasks.SourceSetContainer
import org.gradle.kotlin.dsl.*
import java.nio.charset.MalformedInputException
import java.nio.file.Files
import java.util.Properties

Expand Down Expand Up @@ -45,24 +46,31 @@ object I18nHelper {
inputs.file(inputFile)

doLast {
val props = Properties()

props.load(
Files.newBufferedReader(
inputFile.toPath(),
Charsets.UTF_8
try {
val props = Properties()

props.load(
Files.newBufferedReader(
inputFile.toPath(),
Charsets.UTF_8
)
)
)

val translationsClass = TranslationsClass(
bundle = bundle.joinToString("."),
allProps = props,
className = extension.i18n.className.get(),
classPackage = extension.i18n.classPackage.get(),
publicVisibility = extension.i18n.publicVisibility.get()
)
val translationsClass = TranslationsClass(
bundle = bundle.joinToString("."),
allProps = props,
className = extension.i18n.className.get(),
classPackage = extension.i18n.classPackage.get(),
publicVisibility = extension.i18n.publicVisibility.get()
)

translationsClass.writeTo(outputDirectory)
translationsClass.writeTo(outputDirectory)
} catch (e: MalformedInputException) {
error(
"Malformed input exception: ${e.message} - " +
"Check that your translation bundle is UTF-8 encoded!",
)
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion testModule/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pluginManagement {
plugins {
val pluginVersion = "1.5.3"
val pluginVersion = "1.5.4"

kotlin("jvm") version "2.0.21"

Expand Down

0 comments on commit 4c97e06

Please sign in to comment.