We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Change global culture and currency

Hi

I’m trying to change global culture and currency in my project following this article:


I don’t understand how to reference the installed cldr-data packages? Do you have a complete working sample of this? I’m primary working with grid and numericTextBox.

/S

1 Reply

CI Christopher Issac Sunder K Syncfusion Team December 18, 2018 09:45 AM UTC

Hi Stefan, 

Thank you for contacting Syncfusion support.  
 
You can follow the below code block to refer the installed cldr-data packages json files in your application.  

[Layout.cshtml] 

<script src="https://cdn.syncfusion.com/ej2/dist/ej2.min.js"></script> 
<script> 
    var L10n = ej.base.L10n; 
    L10n.load({ 
        'sv': { 
            'numerictextbox': { 
                incrementTitle: 'inkrementstitel', decrementTitle: 'minskningstitel' 
            } 
        } 
    }); 
    function loadCultureFiles(name) { 
        var files = ['currencies.json', 'numbers.json']; 
        var loader = ej.base.loadCldr; 
        var loadCulture = function (prop) { 
            var val, ajax; 
            ajax = new ej.base.Ajax('/node_modules/cldr-data/main/sv/' + files[prop], 'GET', false); 
            ajax.onSuccess = function (value) { 
                val = value; 
            }; 
            ajax.send(); 
            loader(JSON.parse(val)); 
        }; 
        for (var prop = 0; prop < files.length; prop++) { 
            loadCulture(prop); 
        } 
    } 
    //Load the needed culture files and set the culture for global 
    loadCultureFiles("sv"); 
    ej.base.setCulture('sv'); 
</script> 

If you follow this method, you don’t need to specify the culture at component level as like below. 

<ejs-numerictextbox id="numeric" value="12" decimals="2"></ejs-numerictextbox> 


Please get back to us if you require any further assistance. 

Thanks, 
Christo

Loader.
Live Chat Icon For mobile
Up arrow icon