~/ ← projects/ flavor-cf7

flavor-cf7

Contact Form 7 integration for Flavor — translates labels, placeholders, options, validation messages, and mail templates.

2026 · by serhii · beta · wordpresscf7i18nphp

## case study

— problem & approach #case-study

the problem

Contact Form 7 stores form markup in post_content — labels, placeholders, select options, and mail templates live outside the gettext/.mo pipeline. WPML and Polylang solve it by duplicating the entire form post per language. Sites using Flavor for content translation have no bridge to CF7 without falling back to one of those heavy plugins.

the approach

A lightweight addon that hooks Flavor’s public filters to extend translation coverage to CF7:

  • Form labels / placeholders / select options — translated via Flv_Translator::translate_string() and stored in Flavor’s String Translations table
  • Validation messages — translated by intercepting CF7’s wpcf7_messages array
  • Mail templates (subject, body, recipient overrides) — translated post-meta lookup against Flavor’s storage
  • Request language — Flavor learns the form-submission language via the _wpcf7_locale field through the flv/detect_request_language filter
  • Form post type — Flavor sees wpcf7_contact_form posts as post_title-only (CF7 stores shortcodes in post_content, never to be translated)

Uses only Flavor’s public API. CF7 strings are auto-registered on save and become translatable from Flavor’s String Translations admin.

stack

  • WordPress 6.0+, PHP 8.0+
  • Flavor (active) — public filter API
  • Contact Form 7 (active)
// (c) 2026 symonov · independent dev studio vimgittmuxdocker EOF — end of file —