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

moment.js ui-grid not correct localization #1844


User avatar
0
andmattia created

I have a strange situation.

I a page with ui-grid I see that the column header will be localized in correct way but date inside page not. I make an example: page are setted in italian 1 load page show my header in intlian but row show me date in English (I check that abp language var are in italian) 2 load i do with f5 row are localized in italian

I see a similar issue on a pop up when I inject agular-datetime-picker via oclazyload and i solve put on 1st row

moment.locale(abp.localization.currentLanguage.name);

I think depend off some angular problem but I'm not sure any idea or similar issue? mat


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

    Hi,

    Can you try the check value of "moment.locale()" when grid is not showing correct datea for italian language ? And can you send me the grid column definition for that date column ?

    I want to reproduce the problem.

    Thanks.

  • User Avatar
    0
    andmattia created

    Hi

    to solve this issue I use this code

    if (abp.localization.currentLanguage.name !== moment.locale()) {
                    moment.locale(abp.localization.currentLanguage.name);
                    console.log(moment.locale());
                }
    

    in a ui-grid I don't have anything of strange { name: abp.localization.tmk('HolidayStart'), field: 'holiday.from', cellFilter: 'momentFormat:'llll'', width: '*' },

    and is in english format

    in a modal I do the same fix with code on second row of js

    moment.locale(abp.localization.currentLanguage.name);
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Normally momentjs's localization is set in layout.cshtml (since you are using SPA version) by this line.

    moment.locale('@Thread.CurrentThread.CurrentUICulture.Name'); //Localizing moment.js
    

    can you put a breakpoint and see the value of Thread.CurrentThread.CurrentUICulture.Name ?