Localize Aspose.Cells for Java Library Exception messages

Hi. We faced with issue, when exceptions, that library throws, should be showed to end user. Our product is Russian-oriented, so, is it possible to localize library messages?

Best regards. Alexey

@makarovalv,

Please elaborate your issue/requirements in details with some sample code, sample files and screenshots. This will help us to understand you better to assist you soon. Are exception (by Aspose.Cells) thrown in us-english, please elaborate? What is the environment settings of your server (where Aspose.Cells library is processed)?

There is code example.

@Test
    void formulaException() {
        System.setProperty("user-language", "ru");
        System.setProperty("user-country", "RU");
        Locale.setDefault(Locale.forLanguageTag("ru-RU"));

        Workbook workbook = new Workbook();
        Cell a1 = workbook.getWorksheets().get(0).getCells().get("A1");

        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < 10000; i++) {
            if (builder.length() > 0) {
                builder.append("+");
            }
            builder.append(i);
        }
        a1.setFormula(builder.toString());
    }

Screenshot 2021-04-14 090720.png (82.8 KB)

We expect that exception will be like “Превышена длина формулы. Формула не может быть длиннее 8192 символов”

Best regards. Alexey

@makarovalv,

Please note, Aspose.Cells currently throws/gives all exception messages in English and are static string values. To localize error messages is not an easy or small task to do. It is complex task and we might not support it. Currently, as a workaround, you may check the exception type to re-categorize exceptions and then provide proper messages for your end users accordingly. Alternatively, you should provide end users the proper hints according to the operation (invoked APIs) in your program.

Thanks for your answer. There is several troubles to handle CellsException. It inhertited from RuntimeException, so we can’t to know what method can throw some exception. Also there is no any identifier (except text) for exception type. It would very helpful to have some enumeration of possible exceptions for handling. Anyway it is very difficult task, so i don’t expect immediately reaction. But i hope, that Aspose Team can improve this aspect.

Best regards. Alexey

@makarovalv,

There are many languages and to localize all exceptions for every language/locale is not possible. We will still check and discuss if there is some feasibility for it or we could provide some means (e.g. using some interface which user can implement) to the users for the task. If we agree on it, then we will log a ticket for it.

@makarovalv,

We discussed your issue in details. We are sorry but we cannot provide solution for your requirements currently. We think only “Formula” type cannot fit your needs. Also, to provide the details of message, even user-implemented interfaces (if we provide) cannot help much. For your requirements, I am afraid you have to use your own logic to control the workflow accordingly. For example, you may put your code i.e., Cell.setFormula(String) in the try-catch block, so when getting exception, you may show message like “the formula is invalid” in the proper language to the end user by yourselves.