Skip to content

feat: Add string extraction and generation tools for i18n#306

Open
codenameakshay wants to merge 1 commit into
akshay/3.0.0from
claude/strings-repository-localization-pU85m
Open

feat: Add string extraction and generation tools for i18n#306
codenameakshay wants to merge 1 commit into
akshay/3.0.0from
claude/strings-repository-localization-pU85m

Conversation

@codenameakshay
Copy link
Copy Markdown
Member

Summary

Introduces automated tooling for managing UI strings across Android and iOS platforms. This enables a centralized strings management workflow where strings are extracted from Dart code, stored in Android's strings.xml, and then generated into platform-specific formats.

Key Changes

  • tool/extract_strings.dart: New tool that scans Dart source files for hardcoded UI strings (Text widgets, labels, hints, tooltips, etc.) using regex patterns. Extracts unique strings and merges them into android/app/src/main/res/values/strings.xml while avoiding duplicates and filtering out non-translatable content (URLs, file paths, regex patterns, analytics keys, etc.).

  • tool/generate_strings.dart: New tool that reads the centralized strings.xml and generates:

    • lib/core/l10n/app_strings.g.dart: Dart class with static string constants (snake_case keys converted to camelCase)
    • ios/Runner/Base.lproj/Localizable.strings: iOS-format strings file for localization
  • lib/core/l10n/app_strings.g.dart: Generated Dart constants file containing 8 UI strings (marked as generated code, not to be manually edited)

  • ios/Runner/Base.lproj/Localizable.strings: Generated iOS localization file with the same strings in iOS format

  • Makefile: Added new targets:

    • strings-extract: Run extraction tool
    • strings-gen: Run generation tool and format output
    • strings: Run both extraction and generation
    • strings-check: Verify generated files are up-to-date (for CI)
    • Updated ci target to include strings-check

Implementation Details

  • Uses LinkedHashMap to preserve insertion order in XML files
  • Extraction patterns support both single and double-quoted strings across multiple UI parameter types
  • Intelligent key generation converts values to snake_case with collision handling
  • Exclusion filters prevent extraction of non-user-facing strings (URLs, asset paths, programmatic keys, regex patterns)
  • Proper XML escaping/unescaping for special characters
  • Generated files include headers indicating they are auto-generated

https://claude.ai/code/session_011ytNUzWd4ENWrRHkPeWKFc

Adds a strings.xml-based localization pipeline:
- tool/extract_strings.dart: scans lib/ for UI strings (Text widgets,
  label/title/hintText/etc params) and merges into strings.xml
- tool/generate_strings.dart: reads strings.xml and generates
  lib/core/l10n/app_strings.g.dart (Dart static constants) and
  ios/Runner/Base.lproj/Localizable.strings (iOS format)
- Initial generated files seeded from existing strings.xml entries
- Makefile targets: strings-extract, strings-gen, strings, strings-check
- strings-check added to the ci target as a diff guard

https://claude.ai/code/session_011ytNUzWd4ENWrRHkPeWKFc
@codenameakshay codenameakshay self-assigned this Mar 16, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 16, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f4640f83-20ac-4340-ab8c-394eb46544e6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch claude/strings-repository-localization-pU85m
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

Android App Size Report

Status: PASS

Metric Base Head Delta
app-profile.apk 85,063,025 B (81.12 MiB) 85,006,997 B (81.07 MiB) -56,028 B (-0.05 MiB) (-0.07%)

Thresholds: max delta 1,572,864 B (1.50 MiB) OR 5.00%.

Top artifact bucket deltas (uncompressed bytes):

  • bundle_metadata: +0 B (0.00 MiB)
  • dex: +0 B (0.00 MiB)
  • meta_inf: +0 B (0.00 MiB)
  • native_libs: +0 B (0.00 MiB)
  • other: +0 B (0.00 MiB)

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