Skip to content

fix: use Locale.US for float formatting to prevent syntax errors - #39

Merged
kingsword09 merged 1 commit into
mainfrom
fix-locale-1
Dec 23, 2025
Merged

kingsword09 merged 1 commit into
mainfrom
fix-locale-1

Conversation

@kingsword09

Copy link
Copy Markdown
Owner

Closes: #38

@dosubot

dosubot Bot commented Dec 23, 2025

Copy link
Copy Markdown

Related Documentation

Checked 3 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @kingsword09, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical bug where the generated Compose code could fail to compile due to locale-dependent formatting of floating-point numbers. By explicitly setting the locale to Locale.US during float formatting, it guarantees that decimal points are consistently represented as periods, thereby preventing syntax errors and improving the reliability of the code generation process. Additionally, a new test case for external icons has been introduced to validate the fix.

Highlights

  • Locale-Dependent Float Formatting Fix: The primary change addresses GitHub issue Simple icons generated icons contain syntax errors #38 by explicitly using Locale.US when formatting floating-point numbers in generated Compose code. This ensures that the decimal separator is always a period (.), preventing syntax errors that could arise in environments where the default locale uses a comma (,) for decimals.
  • Enhanced Code Generation Robustness: By standardizing the float formatting, the generated Kotlin code becomes more robust and less prone to compilation failures due to varying locale settings across different build environments.
  • Added Test Case for External Icons: Configuration for externalIcons has been added to the build.gradle.kts file in the example app, specifically for 'simple-icons' (GitHub icon). This serves as a test case to ensure the fix works as expected for external SVG assets.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly fixes a locale-dependent float formatting bug by explicitly using Locale.US when formatting numbers, which will prevent syntax errors in generated code on systems with different locales. The fix itself is solid. However, the pull request also includes test-specific configurations and generated files in the example project. These artifacts should be removed before merging to ensure the commit is focused solely on the bug fix and to keep the example project clean.

Comment on lines +139 to +142
// Simple Icons - for testing Locale issue (GitHub issue #38)
externalIcons("github", libraryName = "simple-icons") {
urlTemplate = "https://simpleicons.org/icons/{name}.svg"
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This configuration for simple-icons was added for testing the locale fix. While useful for verification, such test-specific setup should not be committed to the main branch. Please remove this block to keep the example project's configuration clean and focused on demonstrating the library's intended usage.

Comment on lines +1 to +18
package io.github.kingsword09.example.icons.`simple-icons`

import androidx.compose.ui.graphics.vector.ImageVector
import io.github.kingsword09.example.icons.`simple-icons`.icons.GithubSimpleIcons
import kotlin.collections.List as ____KtList

public object Icons

private var __AllIcons: ____KtList<ImageVector>? = null

public val Icons.AllIcons: ____KtList<ImageVector>
get() {
if (__AllIcons != null) {
return __AllIcons!!
}
__AllIcons= listOf(GithubSimpleIcons)
return __AllIcons!!
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This generated file appears to be an artifact of the test configuration added in build.gradle.kts. To keep the repository clean and the commit focused on the core fix, this file should be removed from the pull request.

Comment on lines +1 to +67
package io.github.kingsword09.example.icons.`simple-icons`.icons

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.PathFillType.Companion.NonZero
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.StrokeCap.Companion.Butt
import androidx.compose.ui.graphics.StrokeJoin.Companion.Miter
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.ImageVector.Builder
import androidx.compose.ui.graphics.vector.path
import androidx.compose.ui.unit.dp
import io.github.kingsword09.example.icons.`simple-icons`.Icons
import org.jetbrains.compose.ui.tooling.preview.Preview

public val Icons.GithubSimpleIcons: ImageVector
get() {
if (_githubSimpleIcons != null) {
return _githubSimpleIcons!!
}
_githubSimpleIcons = Builder(name = "GithubSimpleIcons", defaultWidth = 24.0.dp, defaultHeight = 24.0.dp, viewportWidth = 24.0f, viewportHeight = 24.0f).apply {
path(fill = SolidColor(Color(0xFF000000)), stroke = null, strokeLineWidth = 0.0f, strokeLineCap = Butt, strokeLineJoin = Miter, strokeLineMiter = 4.0f, pathFillType = NonZero) {
moveTo(12.0f, 0.30f)
curveToRelative(-6.63f, 0.0f, -12.0f, 5.37f, -12.0f, 12.0f)
curveToRelative(0.0f, 5.30f, 3.44f, 9.8f, 8.21f, 11.39f)
curveToRelative(0.6f, 0.11f, 0.82f, -0.26f, 0.82f, -0.58f)
curveToRelative(0.0f, -0.29f, -0.01f, -1.04f, -0.02f, -2.04f)
curveToRelative(-3.34f, 0.72f, -4.04f, -1.61f, -4.04f, -1.61f)
curveTo(4.42f, 18.07f, 3.63f, 17.7f, 3.63f, 17.7f)
curveToRelative(-1.09f, -0.74f, 0.08f, -0.73f, 0.08f, -0.73f)
curveToRelative(1.21f, 0.08f, 1.84f, 1.24f, 1.84f, 1.24f)
curveToRelative(1.07f, 1.84f, 2.81f, 1.31f, 3.50f, 1.00f)
curveToRelative(0.11f, -0.78f, 0.42f, -1.31f, 0.76f, -1.61f)
curveToRelative(-2.67f, -0.3f, -5.47f, -1.33f, -5.47f, -5.93f)
curveToRelative(0.0f, -1.31f, 0.47f, -2.38f, 1.24f, -3.22f)
curveToRelative(-0.14f, -0.30f, -0.54f, -1.52f, 0.11f, -3.18f)
curveToRelative(0.0f, 0.0f, 1.01f, -0.32f, 3.3f, 1.23f)
curveToRelative(0.96f, -0.27f, 1.98f, -0.40f, 3.0f, -0.41f)
curveToRelative(1.02f, 0.01f, 2.04f, 0.14f, 3.0f, 0.41f)
curveToRelative(2.28f, -1.55f, 3.29f, -1.23f, 3.29f, -1.23f)
curveToRelative(0.65f, 1.65f, 0.24f, 2.87f, 0.12f, 3.18f)
curveToRelative(0.77f, 0.84f, 1.23f, 1.91f, 1.23f, 3.22f)
curveToRelative(0.0f, 4.61f, -2.81f, 5.63f, -5.48f, 5.92f)
curveToRelative(0.42f, 0.36f, 0.81f, 1.10f, 0.81f, 2.22f)
curveToRelative(0.0f, 1.61f, -0.02f, 2.90f, -0.02f, 3.29f)
curveToRelative(0.0f, 0.32f, 0.21f, 0.69f, 0.83f, 0.57f)
curveTo(20.57f, 22.09f, 24.0f, 17.59f, 24.0f, 12.30f)
curveToRelative(0.0f, -6.63f, -5.37f, -12.0f, -12.0f, -12.0f)
}
}
.build()
return _githubSimpleIcons!!
}

private var _githubSimpleIcons: ImageVector? = null

@Preview
@Composable
private fun Preview() {
Box(modifier = Modifier.padding(12.dp)) {
Image(imageVector = Icons.GithubSimpleIcons, contentDescription = "")
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This generated icon file is part of the test setup for the locale fix. It should be removed from the pull request along with the other test-related artifacts to ensure the commit only contains the necessary bug fix.

@kingsword09
kingsword09 merged commit 96ea89c into main Dec 23, 2025
14 checks passed
@kingsword09
kingsword09 deleted the fix-locale-1 branch December 23, 2025 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simple icons generated icons contain syntax errors

1 participant