Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Order of languages #4836


User avatar
0
vladsd created

How do I change the order of languages in abp.localization.languages

I would like English to be a first choice, no offence to anyone language:)

Thanks.


5 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    @vladsd, I think easiest way is to do it on the client side if you only want to change order for abp.localization.languages. You can do it after the ajax request is finished.

  • User Avatar
    0
    vladsd created

    @ismcagdas - i cannot find where those languages are loaded, or you suggest to do it at the app startup?

    thanks.

  • User Avatar
    0
    ismcagdas created
    Support Team

    If you are using angular version, then you can do it here <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/blob/94e8ec44a49a22ecb8a09d65954c1d193ad532c6/angular/src/AppPreBootstrap.ts#L139">https://github.com/aspnetzero/aspnet-ze ... ap.ts#L139</a>.

    Request to "AbpUserConfiguration/GetAll" returns related scripts.

  • User Avatar
    0
    vladsd created

    Here you go, solution, not pretty but works:)

    // reorg languages with english first
                var langs = abp.localization.languages;
                var languages = [];
                for (var i = 0; i < langs.length; i++) {
                    var info = langs[i];
                    if (info.name == 'en') languages.push(info);
                }
                for (var i = 0; i < langs.length; i++) {
                    var info = langs[i];
                    if (info.name != 'en') languages.push(info);
                }
                abp.localization.languages = languages;
    
  • User Avatar
    0
    aaron created
    Support Team

    How about:

    abp.localization.languages.sort(function (info1, info2) {
        return info1.name == 'en' ? -1 : info2.name == 'en' ? 1 : 0;
    });