Language Switch for Designer Component

Posted by: trankhanhngan00 on 5 March 2023, 9:31 pm EST

    • Post Options:
    • Link

    Posted 5 March 2023, 9:31 pm EST

    Hi Grapecity team,

    I am researching for switching language for spreadsheet, but I have problem with translate the ribbon (Designer Component)

    Currently I import resource file like this:

    <script src="/js/gc.spread.sheets.designer.resource.en.x.x.x.min.js" type="text/javascript"></script>
    <script src="/js/gc.spread.sheets.designer.resource.ja.x.x.x.min.js" type="text/javascript"></script>
    <script src="/js/gc.spread.sheets.designer.resource.cn.x.x.x.min.js" type="text/javascript"></script>
    <script src="/js/gc.spread.sheets.designer.resource.ko.x.x.x.min.js" type="text/javascript"></script>
    <script src="/js/gc.spread.sheets.designer.all.x.x.x.min.js" type="text/javascript"></script>

    It keeps run into the last file (Korean), and I cannot find any SpreadJS function to switch between them (such as

    GC.Spread.Common.CultureManager.culture('en-us')
    )

    May I ask is there any way to switch language for Designer?

    Thank you for your help!

  • Posted 7 March 2023, 5:09 am EST

    Dear Ngan,

    I would like to kindly suggest that you begin by preparing the necessary resources for the specific languages, such as en and ko, and save them in individual files. To accomplish this, I recommend using the getResources method.

    After that, you can use the setResources method to switch between cultures and modify the language used in the designer by altering the resources of the designer. You can load the resources for various languages from the files and assign them to the designer using the GC.Spread.Sheets.Designer.setResources(resources) method.

    For further clarity, I have attached a sample which you can refer to. Here’s the link: https://jscodemine.grapecity.com/share/Q9Oyl9IdTEub6kIZHzaXzw/?defaultOpen={“OpenedFileName”:[“/index.html”,“/src/app.js”],“ActiveFile”:“/src/app.js”}

    Additionally, please take a look at the following code snippet to save the resources of a language (culture) in a JavaScript file:

    
    var res_json_str = JSON.stringify(GC.Spread.Sheets.Designer.getResources());
    
    //For EN Resources
    var result = 'var en_res_str = ' + "" + res_json_str + ";";
    result = result.replaceAll('\','\\');
    saveAs(new Blob([result], { type: "text/javascript;charset=utf-8" }), 'en_res.js');
    

    If you experience any issues, please do not hesitate to let us know.

    For more information, please refer to the following documentation:

    GC.Spread.Sheets.Designer.setResources(): https://www.grapecity.com/spreadjs/api/designer/modules/GC.Spread.Sheets.Designer#setresources

    designer.setConfig(): https://www.grapecity.com/spreadjs/api/designer/classes/GC.Spread.Sheets.Designer.Designer#setconfig

    Thank you for your time and consideration.

    Best regards,

    Ankit

  • Posted 7 March 2023, 8:41 pm EST - Updated 7 March 2023, 9:28 pm EST

    Many thanks for your answer and sample, it works fine for me!

  • Posted 9 March 2023, 5:11 am EST

    Dear Ngan,

    We sincerely apologize for any inconvenience caused. We regret to inform you that the Designer resources file in German is not provided by our team. However, we do offer Designer resources files in English, Japanese, Chinese, and Korean.

    If you require a resource file in a specific language, you may create your own based on the format of the aforementioned resources. We understand that this may require extra effort on your part, but we are willing to assist you in any way we can.

    Furthermore, we would like to inform you that you can modify the resources at runtime by using the designer.getResources() method to retrieve the resources of the current language and the designer.setResources() method to set the modified resources.

    Please refer to the following documentation links for more information on these methods:

    designer.getResources(): https://www.grapecity.com/spreadjs/api/designer/modules/GC.Spread.Sheets.Designer#getresources

    designer.setResources(): https://www.grapecity.com/spreadjs/api/designer/modules/GC.Spread.Sheets.Designer#setresources

    We hope this information proves helpful. If you encounter any issues or require further assistance, please do not hesitate to contact us.

    Regards,

    Ankit

Need extra support?

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

Learn More

Forum Channels