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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Loading CLDR Data on Runtime to Reduce Build Size

Thread ID:

Created:

Updated:

Platform:

Replies:

140969 Nov 16,2018 11:18 AM UTC Nov 19,2018 12:39 PM UTC ASP.NET Core - EJ 2 1
loading
Tags: Common
Mehmood Ahmed
Asked On November 16, 2018 11:18 AM UTC

Hi,

I have observed that cldr-data package is added as a dependency by default. But, can we separate it from main.ts and load it on run-time? Because, the package increases my build size from a couple MBs to 20MB.

Thanks.

Jesus Arockia Sankaran S [Syncfusion]
Replied On November 19, 2018 12:39 PM UTC

Hi Mehmood,  

Thanks for contacting Syncfusion support.  

We suggest you to load cldr files using Ajax post to reduce the bundle size. 

Please find the below code example for your reference. 

//loading locale files 
L10n.load({ 
    'de': { 
        'calendar': { today: 'heute' } 
    }, 
    "ar": { 
        "calendar": { 
            today: 'اليوم' 
        } 
    }, 
}); 
 
//Function for loading locale files based on culture name 
function loadCultureFiles(name:any) { 
    let files: string[] = ['ca-gregorian.json', 'numbers.json', 'timeZoneNames.json']; 
    if (name === 'ar') { 
        files.push('numberingSystems.json'); 
    } 
     let loadCulture = function (prop:any) { 
        let val:string, ajax: Ajax; 
        if (name === 'ar' && prop === files.length - 1) { 
            ajax = new Ajax( './node_modules/cldr-data/supplemental/' + files[prop], 'GET', false); 
        } else { 
            ajax = new Ajax( './node_modules/cldr-data/main/' + name + '/' + files[prop], 'GET', false); 
        } 
        ajax.onSuccess = function (value:any) { 
            val = value; 
            loadCldr(JSON.parse(val)); 
        }; 
        ajax.send(); 
        
    }; 
    for (let prop = 0; prop < files.length; prop++) { 
        loadCulture(prop); 
    } 
} 
loadCultureFiles('de'); 
 
For your convenience we have created a typescript application to load cldr files using Ajax and the same can be referred from the below link. 

 

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

Regards,  
Jesus Arockia Sankaran S 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;