ordercloud-api / headstart

A complete and opinionated eCommerce solution using OrderCloud as the backbone - built with .NET Core and Angular
MIT License
31 stars 74 forks source link

sort all translation definition keys by alphabetical order #445

Closed crhistianramirez closed 2 years ago

crhistianramirez commented 2 years ago

I used the following script on each file to produce a json string where the keys were sorted

function sortDefinitions(obj) {
    const keys = Object.keys(obj).sort();
    const keyValStrings = keys.map(key => {
        const val = obj[key];
        if(typeof val === 'string') {
           return `"${key}": "${val}"`
        }
        return `"${key}": ${sortDefinitions(val)}`;
    }).join(',');
    return '{' + keyValStrings + '}'
}