How to set new Date / Time Format for custom language.

Posted by: alexandra_timofeeva on 14 May 2021, 1:28 am EST

  • Posted 14 May 2021, 1:28 am EST

    Hi

    I would like to translate SpreadJS Designer and Sheets into the german language. While translating I understood that I also need to set some new formats for date, time, currency etc.

    I read your topic here https://help.grapecity.com/spread/SpreadJSWeb/culturecustom.html and tried to do the same.

    I would like to ask you:
    1. I tried to implement the same in Angular but some examples didn’t work (see screenshot). How can I fix them?



    2. How can I add new a value 'German' to the dialog "formatting cells" (See screenshot)? I saved the templates of the dialogs in a file (in assets: SpreadJSTemplates.json) and change them when I change the language. However, there I can change only the titles of tabs, but not the content.



    3. When I write 03/05/2020 in a cell and after tren choose a date as a format, System understand it. Bur when I write 03.05.2020 it doesn't work. How can I fix it for the second case (03.05.2020)?

    I would be very glad if you could show me this on the file that I attached.

    Thank you in advance.
    Aleksandra
  • Replied 17 May 2021, 5:20 pm EST

    HI,

    1. We are sorry but we are unable to replicate the issue at our end. Could please let me know what exactly the issue you are facing so that we could investigate it further. You may also share a small sample that shows the issue. Further, we have tested the following demo demonstrates didn't able to replicate the issue.

    customCulture angular demo: https://www.grapecity.com/spreadjs/demos/features/culture/custom-localization/angular


    2. We are unable to achieve the required functionality using the current public hence we have escalated this issue to the concerned team for further investigation ion. we will update you once we have any information from the team. The internal ID for this issue will be SJS-8741.

    3. This is expected behavior from SJS. In Sjs changing th editing, the format is not supported. Further as a workaround, for achieving the required functionality you need first set the default date format to the show dates and then need to set the foramtter of the cell.

    Please refer to the following attached sample that demonstrates the same and let us know if you face any issues.

    sample: https://stackblitz.com/edit/angular-mrd3qb?file=src%2Fapp%2Fapp.component.ts

    Regards,
    Avinash
  • Replied 26 May 2021, 5:48 am EST

    Hi Avinash,
    Thank you for your reply. I've tried your sample and it worked. However, it would be nice to change the format of cells without explicitly defining the cell position.
    So with the CultureManager I was able to add the patterns which SpreadJS should recognize as valid (e.g. MM/dd/yyyy for english and dd.MM.yyyy in german). But now it would be nice change the displayed format of the cells depending on the selected culture without explicitly using the position of the cell. So for example let's say the user picks a cell and marks it as 'Time' and the valid pattern is "HH:mm:ss". Then he enters "08:13:34". Is it possible to add a default formatter for a custom culture which then e.g. displays the time as "08:13 Uhr". Of course since the user can pick any cell it is not possible to know which one he wants to change the format to 'Time'. So we cant use explicit cell positions. Or is there another way to achieve this?

    Also, we are unsure about the dialog customization and wanted to ask whether it also not possible to change other fields of the Dialog. E.g. is it also not possible to change/add fields to the Type list view (red marked views in screenshots).



    We are using SpreadJS with Angular.

    Thank you in advance.
    Aleksandra
  • Replied 26 May 2021, 6:50 pm EST

    Hi Alexzandar,

    If I understand correctly you want to change the time format. The SpreadJS shows the long time format inside the edit mode for achieving this you need to change the long time format of your custom culture. Please refer to the following code snippet and let us know if you face any issues.

      myCulture.DateTimeFormat.longTimePattern = 'HH:mm ur';


    Regarding the dialog box, The devs informed us that this is not currently supported, but we plan to support this in v14.2. We will update you once the feature gets added.

    Regards
    Avinash
  • Replied 26 May 2021, 9:17 pm EST

    Hey Avinash

    Thanks for your answer. Yes, you understood it correctly, I want to change the displayed time format. But in your solution you set the new format for a cell explicitly by using the position of the cell. Is it possible to get another solution?


    I want that the system sets formats depending on my culture automatically. Maybe there is something like "General" or "Default" Formatter?

    I try to describe you my logic:
    1. I write:
    cultureInfo = new GCS.Spread.Common.CultureInfo();
    this.cultureInfo.DateTimeFormat.shortTimePattern = 'HH:mm:ss';
    GCS.Spread.Common.CultureManager.addCultureInfo('de', this.myCulture);


    2. I open my designer interface and switch the language to German


    3. I choose a cell, click on it and choose Time as a format


    4. I write in a cell: 08:13:34 and got that:


    5. What I want: The system should automatically show 08:13:34 Uhr when the german culture is set (without I writing
    sheet.getCell(4, 3).formatter('HH:mm:ss Uhr')
    ). In you example it was set explicitly as shown below.


    Is it may be possible to set a default formatter for a custom culture for each category (Time/Number/Currency etc.)?

    Thanks
    Aleksandra




  • Replied 27 May 2021, 11:14 pm EST

    Hi Aleksandra,

    Thanks for the explanation but this feature currently not supported by the Designer. We have made an enhancement request on your behalf. We will update you once we have any findings related to this issue. The internal ID for this issue will be SJS-8856.

    Regards,
    Avinash
  • Marked as Answer

    Replied 3 June 2021, 2:37 pm EST

    Hi Aleksandra,

    The devs informed us that custom culture is not currently supported. please refer to the following attached workaround by which you localize the Designer according to your need.

    Regards
    Avinash

    designer.zip
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels