---
title: "localization_form"

doc_type: static
doc_category: static
doc_version: v20270301
source_url:
  html: 'https://developer.shopline.com/docs/sline/tag/localization-form'
  md: 'https://developer.shopline.com/docs/sline/tag/localization-form.md'
---

# localization_form


    Generates a form for country or region switching or language switching.

    This form is applicable to the following scenarios:
- Country or region selector
- Language selector



```sline
{{#localization_form}} custom code {{/localization_form}}
```







    
## Optional params

        
             `return_to` `string`\: The redirect URL after form submission. Defaults to the current page.
        
    



    
## Examples

        
            ### Country or region selector

            The form submission field is `country_code`, and its value is the corresponding country or region code. You can obtain it from the `iso_code` field of each country or region object by iterating through the `localization.available_countries` list.

            

            
<SlineExample path={'/products/earring-ab001'} objects={ 
    ["localization"] 
}>
```sline
{{#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}}
```
</SlineExample>
            
        
            ### Language selector

            The form submission field is `locale_code`, and its value is the corresponding language code. You can obtain it from the `iso_code` field of each language object by iterating through the `localization.available_languages` list.

            

            
<SlineExample path={'/products/earring-ab001'} objects={ 
    ["localization"] 
}>
```sline
{{#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}}
```
</SlineExample>
            
        
            ### Adding HTML attributes

            Pass in standard [HTML form attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/form#attributes), such as `name` and `accept-charset`.

            

            
<SlineExample path={'/products/earring-ab001'} objects={ 
    [""] 
}>
```sline
{{#localization_form id="localization-form" enctype="multipart/form-data" accept-charset="UTF-8"}}
custom code
{{/localization_form}}
```
</SlineExample>
            
        
    
