Skip to content

Localize Spark starter copy defaults#25

Merged
next-devin merged 2 commits into
mainfrom
codex/spark-localization-compliance
Jun 21, 2026
Merged

Localize Spark starter copy defaults#25
next-devin merged 2 commits into
mainfrom
codex/spark-localization-compliance

Conversation

@next-devin

Copy link
Copy Markdown
Contributor

Summary

  • remove English starter copy from settings_data.json and schema defaults so templates can fall back to localized {% t %} strings
  • add localized defaults for featured section headings and side-cart suggested-products title
  • add locale parity and template translation-key contract tests

Validation

  • python3 -m unittest discover -s tests
  • python3 -m json.tool for schema, settings data, and locale files
  • git diff --check

@next-devin next-devin marked this pull request as ready for review June 21, 2026 06:42

ROOT = Path(__file__).resolve().parents[1]

LOCALIZED_DEFAULT_OVERRIDE_SETTINGS = {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: LOCALIZED_DEFAULT_OVERRIDE_SETTINGS is a hand-maintained set duplicated from the schema/partials. If a future contributor adds a new starter-copy setting (schema field with a localized {% t %} fallback in a template) but forgets to update this list, the test won't catch it — the contract is opt-in rather than derived. Consider generating this set from {% t %} usage combined with template-introspection (e.g., look for patterns like settings.X|default:default_X in templates), or at minimum add a comment in the schema/partials pointing back to this constant so the linkage is discoverable.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@@ -561,7 +556,6 @@
"name": "promo_banner_heading",
"label": "Heading",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: Removing the default for promo_banner_heading is inconsistent with the rest of this PR. Every other removed default is paired with a {% t %} fallback in the corresponding template (section_hero.html, section_featured_products.html, section_featured_categories.html, section_on_sale.html, block_cart_upsell.html, etc.). Here, partials/section_promo_banner.html still uses the heading as a section-render gate and has no localized fallback — so dropping the default means the banner disappears for new installs.

Either drop promo_banner_heading from STARTER_COPY_SETTINGS (i.e., restore the default) or update the template to render a localized fallback heading.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

Comment thread partials/block_cart_upsell.html Outdated
{% if settings.enable_upsells %}
<div class="spark-upsells" data-upsell-section>
{% if settings.upsell_section_title %}
{% t "side_cart.default.upsell_section_title" as default_upsell_section_title %}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: The previous {% if settings.upsell_section_title %} guard was removed, and the new default_upsell_section_title is unconditionally populated from the locale file. Net effect: whenever settings.enable_upsells is true, the <h3>...</h3> heading renders even if no upsell products are configured and the merchant never set a title. That always-on heading is a behavior change from the prior implementation, which suppressed the heading when no title was set.

Consider keeping the heading suppressed when there are no upsell products (e.g., gate on the upsell product settings) or restore the original guard if the always-on heading is unintentional.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

Comment thread tests/test_localization_contracts.py Outdated
class LocalizationContractTests(unittest.TestCase):
def test_template_translation_keys_exist_in_every_locale(self):
template_dirs = ["layouts", "partials", "templates"]
key_pattern = re.compile(r"{%\s*t\s+[\"']([^\"']+)[\"']")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: The translation-key regex {%\s*t\s+["\']([^"\']+)["\'] will silently miss {% t %} invocations written with Django whitespace control ({%- t "key" %} or {% t "key" -%}). All current callers use the plain form, so tests pass today, but a future contributor using {%- t %} would have their key silently dropped from the contract check, allowing missing-key drift to slip back in.

Consider tightening the regex to accept an optional - after {% and before %}: {%-?\s*t\s+["\']([^"\']+)["\'].


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@kilo-code-bot

kilo-code-bot Bot commented Jun 21, 2026

Copy link
Copy Markdown

Code Review Summary

Status: 1 New Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1

Resolution of previous review (commit 9fd5102)

All 7 issues from the previous review are resolved in commit 0509bec:

Previous File Resolution
partials/section_promo_banner.html (CRITICAL) {% if settings.promo_banner_heading %} guard removed; section now always renders with localized default. ✓
partials/block_cart_upsell.html (WARNING) Entire <div class="spark-upsells"> wrapped in {% if settings.upsell_product_1 or settings.upsell_product_2 or settings.upsell_product_3 %} — heading no longer renders with zero products. ✓
partials/recommended_products.html (WARNING) Locale recommended_products_header updated to "Recommended products" across all 12 locales; semantic copy regression fixed. ✓
configs/settings_schema.json (WARNING) promo_banner_heading now backed by {% t "homepage.heading.promo_banner" as default_promo_banner_heading %} fallback. ✓
partials/section_featured_product.html (WARNING) featured_product_header now uses default:default_featured_product_heading from {% t "homepage.heading.featured_product" %}. ✓
tests/test_localization_contracts.py regex (SUGGESTION) TRANSLATION_TAG_PATTERN now {%-?\s*t\s+… — handles {%- t "key" %} whitespace-control variants. ✓
tests/test_localization_contracts.py hand-maintained list (SUGGESTION) New test_localized_default_override_settings_match_template_usage derives the set from templates and asserts equality with the hand-maintained set. ✓

New issues from incremental review (commit 0509bec)

SUGGESTION

File Line Issue
tests/test_localization_contracts.py 77 localized_default_settings_from_templates scopes assignment and default-pattern matching to the same file's text. If a future contributor puts {% t "..." as default_X %} in a shared parent partial and `settings.Y

Notes on review coverage

  • Dead locale key (not in diff, surfaced via summary): homepage.placeholder.promo_banner is no longer referenced by any template — the placeholder skeleton in partials/section_promo_banner.html was removed in this PR. The key still exists in all 12 locale files (e.g., locales/en.default.json:294). This is dead code introduced by this PR (the template using it was deleted). The test test_template_translation_keys_exist_in_every_locale does not detect unused keys; only missing ones. Recommend pruning homepage.placeholder.promo_banner from all 12 locale files in a follow-up.
  • layouts/base.html, partials/announcement_bar.html, partials/side_cart.html, partials/block_cart_progress_bar.html, partials/recommended_products.html, partials/section_featured_product.html, partials/section_promo_banner.html, and the 12 locale files were all reviewed; no other issues found.

Fix these issues in Kilo Cloud

Previous Review Summary (commit 9fd5102)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 9fd5102)

Status: 7 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 1
WARNING 4
SUGGESTION 2
Issue Details (click to expand)

CRITICAL

File Line Issue
partials/section_promo_banner.html 3 Schema promo_banner_heading default removed + settings_data.json starter value removed, but this template still gates the entire section on {% if settings.promo_banner_heading %}. New installs will never render the promo banner. (Inline-comment blocked — file not in PR diff; surfaced via summary.)

WARNING

File Line Issue
partials/block_cart_upsell.html 10 Removed {% if settings.upsell_section_title %} guard; default_upsell_section_title is always populated from locale, so the heading now always renders when enable_upsells is true, even with zero upsell products configured.
partials/recommended_products.html 11 Removing the Recommended Products schema default shifts the fallback to store.catalogue.recommended_products_header ("Customers who viewed this item also bought") — a meaningful semantic copy change for upgrading merchants. (Inline-comment blocked — file not in PR diff.)
configs/settings_schema.json 557 promo_banner_heading default removal is inconsistent: every other removed default pairs with a {% t %} fallback in its template; this one doesn't.
partials/section_featured_product.html 6 featured_product_header still has no localized fallback even though its sibling featured_product_cta_text (line 38) does — inconsistent with the PR's intent. (Inline-comment blocked — file not in PR diff.)

SUGGESTION

File Line Issue
tests/test_localization_contracts.py 66 Translation-key regex won't match {%- t "key" %} (whitespace-control variants) — future contributors could silently bypass the missing-key check.
tests/test_localization_contracts.py 9 LOCALIZED_DEFAULT_OVERRIDE_SETTINGS is hand-maintained rather than derived; future starter-copy settings can drift out of the contract silently.
Files Reviewed (17 files)
  • configs/settings_data.json - 1 issue (summary)
  • configs/settings_schema.json - 1 issue (inline)
  • locales/de.json - clean
  • locales/en.default.json - clean
  • locales/es.json - clean
  • locales/fi.json - clean
  • locales/fr.json - clean
  • locales/it.json - clean
  • locales/nl.json - clean
  • locales/no.json - clean
  • locales/pt.json - clean
  • locales/sv.json - clean
  • locales/th.json - clean
  • partials/block_cart_upsell.html - 1 issue (inline)
  • partials/section_featured_categories.html - clean
  • partials/section_featured_products.html - clean
  • tests/test_localization_contracts.py - 2 issues (inline)

Notes on review coverage

  • partials/section_promo_banner.html, partials/recommended_products.html, and partials/section_featured_product.html were not modified by this PR but are affected by the schema/setting changes; their issues are reported in the summary because they fall outside the diff hunks and cannot receive inline comments.

Fix these issues in Kilo Cloud


Reviewed by minimax-m3 · Input: 125.9K · Output: 17.5K · Cached: 3M

yield from (ROOT / dirname).rglob("*.html")


def localized_default_settings_from_templates():

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: localized_default_settings_from_templates scopes LOCALIZED_DEFAULT_ASSIGNMENT_PATTERN and SETTING_DEFAULT_PATTERN to the same file's text. If a future contributor puts the {% t "..." as default_X %} assignment in a shared parent partial and the settings.Y|default:default_X reference in a child include, the test will not detect Y (false negative) and the exact-equality assertion will fail (false positive). Consider collecting assignments and references across all template files and joining them once, so the test mirrors the runtime scoping of the variables rather than the file-scoping of re.findall.

Suggested change
def localized_default_settings_from_templates():
def localized_default_settings_from_templates():
settings = set()
localized_default_vars = set()
for path in template_paths():
text = path.read_text()
localized_default_vars.update(LOCALIZED_DEFAULT_ASSIGNMENT_PATTERN.findall(text))
for path in template_paths():
text = path.read_text()
for setting_name, default_var in SETTING_DEFAULT_PATTERN.findall(text):
if default_var in localized_default_vars:
settings.add(setting_name)
return settings

Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@next-devin next-devin merged commit 1a364dd into main Jun 21, 2026
2 checks passed
@next-devin next-devin deleted the codex/spark-localization-compliance branch June 21, 2026 07:09
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.

1 participant