Skip to content

Conversation

@KonerDev
Copy link
Member

This PR changes the placeholder syntax one more time, because before, Weblate didn't recognize the placeholders correctly. They have to be in this format: e.g. %s or %1$s.

Additionally, this PR applies this change to all existing translations.

@github-actions
Copy link

github-actions bot commented Oct 25, 2025

PR Summary

Updated the placeholder syntax in string resources from named placeholders (e.g., %(key)s) to standard positional placeholders (e.g., %s, %d). This change improves compatibility and highlighting within Weblate, ensuring correct recognition of translatable strings. The Res.kt utility functions getFilledString and fillPlaceholders were refactored to accept vararg Any? arguments and utilize String.format for string formatting, simplifying their usage across the application. All existing translations were updated to reflect this new syntax.

Changes

File Summary
core/main/src/main/java/com/rk/tabs/EditorTab.kt Updated the call to strings.ask_lsp_install.getFilledString to pass the server.languageName directly as an argument, aligning with the new placeholder syntax and getFilledString function signature.
core/main/src/main/java/com/rk/xededitor/ui/components/FileActionDialog.kt Modified calls to fillPlaceholders for close_current_project and ask_del strings. The mapOf argument for named placeholders was replaced with direct arguments, reflecting the updated string formatting utility.
core/main/src/main/java/com/rk/xededitor/ui/components/FindingsDialog.kt Adjusted the description.fillPlaceholders call to pass codeItems.size directly, removing the mapOf wrapper, in line with the new string formatting approach.
core/main/src/main/java/com/rk/xededitor/ui/screens/settings/SettingsScreen.kt Updated the debug_options_desc.getFilledString call to pass strings.app_name.getString() directly, removing the mapOf argument, to conform to the new placeholder handling.
core/resources/src/main/java/com/rk/resources/Res.kt Refactored getFilledString and fillPlaceholders functions to accept vararg Any? instead of Map<String, Any>. The implementation now uses String.format for placeholder replacement, standardizing string formatting and improving Weblate compatibility.
core/resources/src/main/res/values-ar/strings.xml Updated string resources to replace named placeholders like %(file_name) and %(project_name) with standard positional placeholders %s for improved Weblate compatibility.
core/resources/src/main/res/values-cs/strings.xml Modified string resources to use positional placeholders (%s, %d) instead of named placeholders (%(key)s) for better Weblate recognition. Also removed the line_spacing_multiplier string.
core/resources/src/main/res/values-de/strings.xml Converted named placeholders (e.g., %(project_name)s, %(count)d) in German string resources to standard positional placeholders (%s, %d) to enhance Weblate compatibility. Also removed the line_spacing_multiplier string.
core/resources/src/main/res/values-fr/strings.xml Replaced named placeholders (e.g., %(file_name), %(count)) with positional placeholders (%s, %d) in French string resources for better Weblate integration.
core/resources/src/main/res/values-in/strings.xml Converted named placeholders (e.g., %(file_name), %(project_name)) in Indonesian string resources to standard positional placeholders (%s) for improved Weblate compatibility.
core/resources/src/main/res/values-it/strings.xml Modified Italian string resources to use positional placeholders (%s) instead of named placeholders (%(name)) for enhanced Weblate compatibility.
core/resources/src/main/res/values-ja/strings.xml Updated Japanese string resources to replace named placeholders (e.g., %(file_name), %(project_name)) with positional placeholders (%s) for better Weblate recognition. Also removed the line_spacing_multiplier string.
core/resources/src/main/res/values-pl/strings.xml Converted named placeholders (e.g., %(file_name), %(count)) in Polish string resources to standard positional placeholders (%s, %d) to improve Weblate compatibility. Also removed the line_spacing_multiplier string.
core/resources/src/main/res/values-pt-rBR/strings.xml Updated the debug_options_desc string in Brazilian Portuguese resources to use a positional placeholder %s instead of %(app_name). Also removed the line_spacing_multiplier string.
core/resources/src/main/res/values-pt/strings.xml Modified the ask_del string in Portuguese resources to use a positional placeholder %s instead of %(file_name).
core/resources/src/main/res/values-ru/strings.xml Replaced named placeholders (e.g., %(file_name)s, %(project_name)s) with positional placeholders (%s) in Russian string resources for improved Weblate compatibility. Also removed the line_spacing_multiplier string.
core/resources/src/main/res/values-tr/strings.xml Converted named placeholders (e.g., %(file_name), %(count)) in Turkish string resources to standard positional placeholders (%s, %d) for better Weblate integration. Also removed the line_spacing_multiplier string.
core/resources/src/main/res/values-zh-rTW/strings.xml Updated Traditional Chinese string resources to replace named placeholders (e.g., %(file_name)s, %(count)d) with positional placeholders (%s, %d) for improved Weblate compatibility. Also removed the line_spacing_multiplier string.
core/resources/src/main/res/values-zh/strings.xml Modified Simplified Chinese string resources to use positional placeholders (%s, %d) instead of named placeholders (e.g., %(file_name)s, %(count)d) for better Weblate recognition. Also removed the line_spacing_multiplier string.
core/resources/src/main/res/values/strings.xml Updated default English string resources to replace named placeholders (e.g., %(file_name)s, %(count)d) with standard positional placeholders (%s, %d) for improved Weblate compatibility.

autogenerated by presubmit.ai

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

🚨 Pull request needs attention.

Review Summary

Commits Considered (1)
  • 4852475: fix(resources): change placeholder syntax for better Weblate highlighting
Files Processed (20)
  • core/main/src/main/java/com/rk/tabs/EditorTab.kt (1 hunk)
  • core/main/src/main/java/com/rk/xededitor/ui/components/FileActionDialog.kt (2 hunks)
  • core/main/src/main/java/com/rk/xededitor/ui/components/FindingsDialog.kt (1 hunk)
  • core/main/src/main/java/com/rk/xededitor/ui/screens/settings/SettingsScreen.kt (1 hunk)
  • core/resources/src/main/java/com/rk/resources/Res.kt (1 hunk)
  • core/resources/src/main/res/values-ar/strings.xml (3 hunks)
  • core/resources/src/main/res/values-cs/strings.xml (5 hunks)
  • core/resources/src/main/res/values-de/strings.xml (7 hunks)
  • core/resources/src/main/res/values-fr/strings.xml (6 hunks)
  • core/resources/src/main/res/values-in/strings.xml (5 hunks)
  • core/resources/src/main/res/values-it/strings.xml (4 hunks)
  • core/resources/src/main/res/values-ja/strings.xml (5 hunks)
  • core/resources/src/main/res/values-pl/strings.xml (7 hunks)
  • core/resources/src/main/res/values-pt-rBR/strings.xml (2 hunks)
  • core/resources/src/main/res/values-pt/strings.xml (1 hunk)
  • core/resources/src/main/res/values-ru/strings.xml (6 hunks)
  • core/resources/src/main/res/values-tr/strings.xml (7 hunks)
  • core/resources/src/main/res/values-zh-rTW/strings.xml (7 hunks)
  • core/resources/src/main/res/values-zh/strings.xml (7 hunks)
  • core/resources/src/main/res/values/strings.xml (6 hunks)
Actionable Comments (1)
  • core/resources/src/main/java/com/rk/resources/Res.kt [31-32]

    possible bug: "Potential runtime errors with String.format arguments."

Skipped Comments (1)
  • core/resources/src/main/java/com/rk/resources/Res.kt [31-32]

    best practice: "Consider explicit locale for String.format."

Comment on lines +31 to +32
fun String.fillPlaceholders(vararg args: Any?): String {
return String.format(this, *args)

Choose a reason for hiding this comment

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

The new fillPlaceholders function uses String.format(this, *args). This method is powerful but can throw an IllegalFormatException at runtime if the provided arguments do not strictly match the format specifiers in the string resource (e.g., passing a string to a %d specifier). The previous map-based approach was more resilient to such type mismatches. Ensure all call sites pass arguments that conform to the expected format specifiers to prevent runtime crashes.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

LGTM!

Review Summary

Commits Considered (1)
  • c3f47ed: Merge branch 'main' into fix/placeholders
Files Processed (2)
  • core/resources/src/main/res/values-ru/strings.xml (6 hunks)
  • core/resources/src/main/res/values-zh/strings.xml (7 hunks)
Actionable Comments (0)
Skipped Comments (0)

@RohitKushvaha01 RohitKushvaha01 merged commit 1c1895c into Xed-Editor:main Oct 25, 2025
1 check passed
@KonerDev KonerDev deleted the fix/placeholders branch November 1, 2025 13:13
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.

2 participants