Localization and RTL

19 Dec 20223 minutes to read

Localization

The Localization library allows to localize default text content of the ColorPicker. The ColorPicker component has static text for control buttons (apply / cancel) and mode switcher that can be changed to other cultures (Arabic, Deutsch, French, etc.) by defining the locale value and translation object.

The following list of properties and its values are used in the ColorPicker.

Locale key words Text
Apply Apply
Cancel Cancel
ModeSwitcher Switch Mode

Loading translations

To load translation object in an application use load function of L10n class.

The following example demonstrates the ColorPicker in Deutsch culture.

<div class='wrap'>
    <h4>Choose Color</h4>
    @Html.EJS().ColorPicker("element").Locale("de-DE").Render()
</div>

<script>
    ej.base.L10n.load({
        'de-DE': {
            'colorpicker': {
                'Apply': 'Anwenden',
                'Cancel': 'Abbrechen',
                'ModeSwitcher': 'Modus wechseln'
            }
        }
    });
</script>

<style>
    .wrap {
        margin: 0 auto;
        width: 300px;
        text-align: center;
    }
</style>
public ActionResult Localization()
    {
            return View();
    }

Right to Left - RTL

ColorPicker component has RTL support. It helps to render the ColorPicker from right-to-left direction. It improves the user experiences and accessibility for users who use right-to-left languages (Arabic, Farsi, Urdu, etc). This can be achieved by setting the enableRtl property to true.

<div class='wrap'>
    <h4>Choose Color</h4>
    @Html.EJS().ColorPicker("element").EnableRtl(true).Locale("ar-AE").Render()
</div>

<script>
    ej.base.L10n.load({
        'ar-AE': {
            'colorpicker': {
                'Apply': 'تطبيق',
                'Cancel': 'إلغاء',
                'ModeSwitcher': 'مفتاح كهربائي الوضع'
            }
        }
    });
</script>

<style>
    .wrap {
        margin: 0 auto;
        width: 300px;
        text-align: center;
    }
</style>
public ActionResult Rtl()
    {
            return View();
    }

NOTE

View Sample in GitHub.

See also