From 2bfad60b41d15d82093a7d728983eff1e9447c4d Mon Sep 17 00:00:00 2001 From: Thomas Cashman Date: Wed, 4 Aug 2021 13:51:26 +0100 Subject: [PATCH] Fix Xlsx2Po outputting incorrect filenames Also Fix exception in Xlsx2Po when cell is in numeric format --- CHANGES | 4 ++++ .../main/java/org/mini2Dx/gettext/xlsx/Xlsx2Po.java | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 35bff2f..847fb4e 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +[1.9.2] +- Fix Xlsx2Po outputting incorrect filenames +- Fix exception in Xlsx2Po when cell is in numeric format + [1.9.1] - Fix PoFile not reading UTF8 characters correctly depending on constructor used - TranslationEntry no longer outputs empty comments diff --git a/gettext-xlsx/src/main/java/org/mini2Dx/gettext/xlsx/Xlsx2Po.java b/gettext-xlsx/src/main/java/org/mini2Dx/gettext/xlsx/Xlsx2Po.java index 81998f4..6cfa40f 100644 --- a/gettext-xlsx/src/main/java/org/mini2Dx/gettext/xlsx/Xlsx2Po.java +++ b/gettext-xlsx/src/main/java/org/mini2Dx/gettext/xlsx/Xlsx2Po.java @@ -65,7 +65,7 @@ public static void convertFile(final File xlsxFile, final File poDirectory) thro if(!directory.exists()) { directory.mkdirs(); } - outputFiles.put(locale, new File(directory, sheet.getSheetName().replace(".pot", ".po"))); + outputFiles.put(locale, new File(directory, xlsxFile.getName().replace(".pot", ".po").replace(".xlsx", ".po"))); poFiles.put(locale, new PoFile(locale)); localeIndices.put(columnIndex, locale); } @@ -115,6 +115,13 @@ private static String getCell(final Row row, final int columnIndex) { if(row.getCell(columnIndex) == null) { return ""; } - return row.getCell(columnIndex).getStringCellValue().trim(); + try { + return row.getCell(columnIndex).getStringCellValue().trim(); + } catch (IllegalStateException e) { + if(e.getMessage().contains("Cannot get a STRING value from a NUMERIC cell")) { + return String.valueOf(row.getCell(columnIndex).getNumericCellValue()); + } + throw e; + } } }