Form Translation (#616)
* Form Translation * Support for other languages * Support locale for datepicker * Apply translation on select input * Apply translation on select input * Improve translation --------- Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
@@ -252,6 +252,12 @@ class AnswerFormRequest extends FormRequest
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
// Set locale based on form language
|
||||
if ($this->form?->language && in_array($this->form->language, Form::LANGUAGES)) {
|
||||
app()->setLocale($this->form->language);
|
||||
}
|
||||
|
||||
|
||||
$receivedData = $this->toArray();
|
||||
$mergeData = [];
|
||||
$countryCodeMapper = json_decode(file_get_contents(resource_path('data/country_code_mapper.json')), true);
|
||||
|
||||
@@ -29,6 +29,7 @@ abstract class UserFormRequest extends \Illuminate\Foundation\Http\FormRequest
|
||||
'visibility' => ['required', Rule::in(Form::VISIBILITY)],
|
||||
|
||||
// Customization
|
||||
'language' => ['required', Rule::in(Form::LANGUAGES)],
|
||||
'font_family' => 'string|nullable',
|
||||
'theme' => ['required', Rule::in(Form::THEMES)],
|
||||
'width' => ['required', Rule::in(Form::WIDTHS)],
|
||||
|
||||
@@ -70,6 +70,7 @@ class FormResource extends JsonResource
|
||||
'dark_mode' => $this->dark_mode,
|
||||
'transparent_background' => $this->transparent_background,
|
||||
'color' => $this->color,
|
||||
'language' => $this->language,
|
||||
'theme' => $this->theme,
|
||||
'is_password_protected' => true,
|
||||
'has_password' => $this->has_password,
|
||||
|
||||
@@ -41,6 +41,8 @@ class Form extends Model implements CachableAttributes
|
||||
|
||||
public const VISIBILITY = ['public', 'draft', 'closed'];
|
||||
|
||||
public const LANGUAGES = ['en', 'fr', 'hi', 'es', 'ar', 'zh', 'ja'];
|
||||
|
||||
protected $fillable = [
|
||||
'workspace_id',
|
||||
'creator_id',
|
||||
@@ -52,6 +54,7 @@ class Form extends Model implements CachableAttributes
|
||||
'visibility',
|
||||
|
||||
// Customization
|
||||
'language',
|
||||
'font_family',
|
||||
'custom_domain',
|
||||
'size',
|
||||
|
||||
Reference in New Issue
Block a user