Skip to content

Conversation

@bamsejon
Copy link

Summary

  • Fix JavaScript crash on /events/new page when LANGUAGES env var contains locales not imported from air-datepicker
  • Add support for 12 additional locales: Swedish (sv), Danish (da), Norwegian Bokmål (nb), Finnish (fi), Polish (pl), Portuguese (pt), Russian (ru), Ukrainian (uk), Czech (cs), Japanese (ja), Chinese (zh), Korean (ko)
  • Fix fallback logic to check actual locale availability

Problem

When the LANGUAGES environment variable includes locales that weren't imported from air-datepicker (like Swedish "sv"), the datepicker initialization crashes with "undefined" is not valid JSON. This prevents the Create button from being enabled on the event creation page.

Fixes #205

Changes

  1. Added locale imports (assets/js/app.js):

    • Imported 12 additional air-datepicker locales
    • Imported corresponding moment.js locales
  2. Fixed fallback logic:

    • Changed from checking airdatePickrSupportedLocales (which came from config)
    • Now checks if locale actually exists in airdatePickrLocales keys
    • Moved airdatePickrLocales definition before the fallback check

Test plan

  • Set LANGUAGES=en,sv and verify /events/new page works
  • Verify datepicker displays in Swedish when browser locale is Swedish
  • Verify English fallback works for unsupported locales
  • Test "Quick event" still works
  • Test event editing works

🤖 Generated with Claude Code

The issue occurs when:
1. LANGUAGES env var includes locales not imported in app.js (e.g., "sv")
2. window.claperConfig.supportedLocales contains these locales
3. The fallback check only verified against supportedLocales, not actual imports
4. This caused airdatePickrLocales[locale] to return undefined
5. AirDatepicker's _handleLocale crashed trying to parse undefined

Fix:
- Added more locale imports from air-datepicker (sv, da, nb, fi, pl, pt, ru, uk, cs, ja, zh, ko)
- Added corresponding moment locale imports
- Changed fallback check to verify locale exists in airdatePickrLocales keys

Fixes the "Create" button being disabled on the /events/new page.
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.

Create button disabled on /events/new page when LANGUAGES contains unsupported datepicker locales

1 participant