comahe-de / i18n4k

Internationalization for Kotlin
Apache License 2.0
78 stars 9 forks source link

Strings with '%' in them cause the build to fail #31

Closed arpsmack closed 1 year ago

arpsmack commented 1 year ago

Putting a % character in a string causes the build to fail with this exception:

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':generateI18n4kFiles'.
....
Caused by: java.lang.IllegalArgumentException: index 1 for '% ' not in range (received 0 arguments)
    at com.squareup.kotlinpoet.CodeBlock$Builder.add(CodeBlock.kt:312)
    at com.squareup.kotlinpoet.Documentable$Builder.addKdoc(Documentable.kt:27)
    at com.squareup.kotlinpoet.PropertySpec$Builder.addKdoc(PropertySpec.kt:278)
    at de.comahe.i18n4k.generator.I18n4kGenerator.generateMessagesObject(I18n4kGenerator.kt:188)
    at de.comahe.i18n4k.generator.I18n4kGenerator.generateSourceCode(I18n4kGenerator.kt:137)
    at de.comahe.i18n4k.generator.I18n4kGenerator.run(I18n4kGenerator.kt:115)
    at de.comahe.i18n4k.generator.I18n4kProcessor.execute(I18n4kProcessor.kt:68)
    ....

It's coming from the kotlinpoet library which has some specific syntax it looks for: https://github.com/square/kotlinpoet/blob/main/kotlinpoet/src/main/java/com/squareup/kotlinpoet/CodeBlock.kt#L32-L59

I don't think there's any need for i18n4k to use these placeholder sequences, so maybe all text passed into the PropertSpec should replace all % characters with %%?

comahe-de commented 1 year ago

Hi @arpsmack

Thank you for bug report. It will be fixed in the upcoming release.