localization_form
Generates a submission <form> form for switching countries and languages.
This form tag is used for two types of form submissions:
- Country selector
- Language selector
{{#localization_form /}} custom code {{/localization_form}}
Hash Params
-
return_tostring: The redirect URL after the form is submitted. The default is the current page.
Example
Country Selector
The form submission field is country_code, and its value is the corresponding country code, which can be obtained through the iso_code field in localization.available_countries object.
{{#localization_form enctype="multipart/form-data" accept-charset="UTF-8"}}
<select name="country_code" onchange="this.form.submit();">
{{#for country in localization.available_countries}}
<option value="{{country.iso_code}}" {{#if localization.country.iso_code == country.iso_code}}selected{{/if}}>
{{country.name}}({{country.currency.iso_code}}
{{country.currency.symbol}})
</option>
{{/for}}
</select>
{{/localization_form}}
Language selector
The form submission field is locale_code, and its value is the corresponding language encoding, which can be obtained through the iso_code field in localization.available_languages object .
{{#localization_form enctype="multipart/form-data" accept-charset="UTF-8"}}
<select name="locale_code" onchange="this.form.submit();">
{{#for language in localization.available_languages}}
<option value="{{language.iso_code}}" {{#if localization.language.endonym_name == language.endonym_name}}selected{{/if}}>
{{language.endonym_name}}
</option>
{{/for}}
</select>
{{/localization_form}}
Adding HTML attributes
You can add standard HTML form attributes to the form tag, such as accept , accept-charset , etc.
{{#localization_form id="localization-form" enctype="multipart/form-data" accept-charset="UTF-8"}}
custom code
{{/localization_form}}