statamic / ideas

💡Discussions on ideas and feature requests for Statamic
https://statamic.dev
30 stars 1 forks source link

Request for Localized Error Messages in Statamic's Form API for Headless CMS Integration #1115

Closed thomas4Bitcraft closed 5 months ago

thomas4Bitcraft commented 5 months ago

I am reaching out to discuss an enhancement opportunity for Statamic when used as a Headless CMS, particularly in our Nuxt application. We've encountered a challenge with the localization of error messages generated through the Form API ("/!/forms/.."). Currently, these messages default to the primary language of the website, rather than adapting to the user's preferred locale.

In an attempt to address this, we implemented a middleware solution:

if ($request->hasHeader('x-locale')) {
    $locale = $request->header('x-locale');
    App::setLocale($locale);
}

Unfortunately, this approach hasn't influenced the language of the error messages. Could you consider implementing a feature that allows for the localization of error messages in the Form API? This would be a significant improvement for developers using Statamic as a Headless CMS in multilingual environments.

jasonvarga commented 5 months ago

Done in https://github.com/statamic/cms/pull/9383. Will be in 3.46.0