Need Help Implementing Real-Time Progress Output in Translation Loop Using JConsole

  Kiến thức lập trình

I’m struggling to print ‘translating text x / y’ one at a time. Currently, all the translation progress is outputted at once once the loop completes. JConsole, which I’m using, is a basic JFrame-based console with a TextArea added to it.

My code

                System.out.println("Translating " + scrapedTextCollection.size() + " results...");
                // Perform translation...

                int count = 0;
                for (Map<String, String> mappedText : scrapedTextCollection) {
                    count++;
                    MainClient.getClientExtension().getJConsole().writeInformation("Translating text" + count + " /  " + scrapedTextCollection.size());
                    String translatedResult = Translator.translate(Language.valueOf(textData.translateX()), Language.valueOf(textData.translateY()), mappedText.get("Title") + " - " + mappedText.get("Chunk Text"));
                    mappedText.put("Translated Text", translatedResult);
                }

I have tried all sorts of things but its not working. Any help would be great.

LEAVE A COMMENT