From: Niki Roo Date: Sun, 26 Nov 2017 09:10:20 +0000 (+0100) Subject: Fix --help messages, fix trans step 1/2 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=99ccbdf63b539f1f40e070f5833f2d15fcf79830;p=fanfix-jexer.git Fix --help messages, fix trans step 1/2 --- diff --git a/src/be/nikiroo/fanfix/Instance.java b/src/be/nikiroo/fanfix/Instance.java index 1497782..a06c975 100644 --- a/src/be/nikiroo/fanfix/Instance.java +++ b/src/be/nikiroo/fanfix/Instance.java @@ -6,6 +6,7 @@ import java.util.Date; import be.nikiroo.fanfix.bundles.Config; import be.nikiroo.fanfix.bundles.ConfigBundle; +import be.nikiroo.fanfix.bundles.StringId; import be.nikiroo.fanfix.bundles.StringIdBundle; import be.nikiroo.fanfix.bundles.UiConfig; import be.nikiroo.fanfix.bundles.UiConfigBundle; @@ -104,11 +105,16 @@ public class Instance { } catch (IOException e) { syserr(e); } - try { - trans = new StringIdBundle(getLang()); - trans.updateFile(configDir); - } catch (IOException e) { - syserr(e); + + // No updateFile for this one! (we do not want the user to have custom + // translations that won't accept updates from newer versions) + trans = new StringIdBundle(getLang()); + + // Fix an old bug (we used to store custom translation files by + // default): + if (trans.getString(StringId.INPUT_DESC_CBZ) == null) { + // TODO: create the deleteFile method + // trans.deleteFile(configDir); } Bundles.setDirectory(configDir); diff --git a/src/be/nikiroo/fanfix/Main.java b/src/be/nikiroo/fanfix/Main.java index 9ac4884..99ac119 100644 --- a/src/be/nikiroo/fanfix/Main.java +++ b/src/be/nikiroo/fanfix/Main.java @@ -253,12 +253,30 @@ public class Main { updates.ok(); // we consider it read break; case LIST: + if (BasicReader.getReader() == null) { + Instance.syserr(new Exception( + "No reader type has been configured")); + exitCode = 10; + break; + } exitCode = list(sourceString); break; case READ: + if (BasicReader.getReader() == null) { + Instance.syserr(new Exception( + "No reader type has been configured")); + exitCode = 10; + break; + } exitCode = read(luid, chapString, true); break; case READ_URL: + if (BasicReader.getReader() == null) { + Instance.syserr(new Exception( + "No reader type has been configured")); + exitCode = 10; + break; + } exitCode = read(urlString, chapString, false); break; case HELP: @@ -277,6 +295,12 @@ public class Main { updates.ok(); // we consider it read break; case START: + if (BasicReader.getReader() == null) { + Instance.syserr(new Exception( + "No reader type has been configured")); + exitCode = 10; + break; + } BasicReader.getReader().browse(null); break; case SERVER: @@ -293,7 +317,7 @@ public class Main { } return; case REMOTE: - exitCode = 255; + exitCode = 255; // should not be reachable (REMOTE -> START) break; } } diff --git a/src/be/nikiroo/fanfix/bundles/StringId.java b/src/be/nikiroo/fanfix/bundles/StringId.java index 6ccb772..96c67e2 100644 --- a/src/be/nikiroo/fanfix/bundles/StringId.java +++ b/src/be/nikiroo/fanfix/bundles/StringId.java @@ -81,6 +81,12 @@ public enum StringId { INPUT_DESC_E621, // @Meta(description = "Description of this input type") INPUT_DESC_E_HENTAI, // + @Meta(description = "Description of this input type") + INPUT_DESC_YIFFSTAR, // + @Meta(description = "Description of this input type") + INPUT_DESC_CBZ, // + @Meta(description = "Description of this input type") + INPUT_DESC_HTML, // @Meta(info = "%s = type", description = "Default description when the type is not known by i18n") OUTPUT_DESC, // @Meta(description = "Description of this output type") diff --git a/src/be/nikiroo/fanfix/bundles/resources.properties b/src/be/nikiroo/fanfix/bundles/resources.properties index a63fbd3..bdbb754 100644 --- a/src/be/nikiroo/fanfix/bundles/resources.properties +++ b/src/be/nikiroo/fanfix/bundles/resources.properties @@ -14,9 +14,13 @@ HELP_SYNTAX = Valid options:\n\ \t--export [id] [output_type] [target]: export story to target\n\ \t--convert [URL] [output_type] [target] (+info): convert URL into target\n\ \t--read [id] ([chapter number]): read the given story from the library\n\ -\t--read-url [URL] ([chapter number]): convert on the fly and read the story, without saving it\n\ +\t--read-url [URL] ([chapter number]): convert on the fly and read the \n\ +\t\tstory, without saving it\n\ \t--list: list the stories present in the library\n\ -\t--set-reader [reader type]: set the reader type to CLI, TUI or GUI for this command\n\ +\t--set-reader [reader type]: set the reader type to CLI, TUI or GUI for \n\ +\t\tthis command\n\ +\t--remote [host] [port]: select this remote server to get \n\ +\t\t(or update or...) the stories from\n\ \t--help: this help message\n\ \t--version: return the version of the program\n\ \n\ @@ -29,7 +33,7 @@ Supported output types:\n\ ERR_SYNTAX = Syntax error (try "--help") # an input or output support type description # (FORMAT: STRING) %s = support name, %s = support desc -ERR_SYNTAX_TYPE = %s: %s +ERR_SYNTAX_TYPE = > %s: %s # Error when retrieving data # (FORMAT: STRING) %s = input string ERR_LOADING = Error when retrieving data from: %s @@ -77,30 +81,49 @@ INPUT_DESC = Unknown type: %s INPUT_DESC_EPUB = EPUB files created by this program (we do not support "all" EPUB files) # Description of this input type # (FORMAT: STRING) -INPUT_DESC_TEXT = Support class for local stories encoded in textual format, with a few rules :\n\ +INPUT_DESC_TEXT = Support class for local stories encoded in textual format, with a few \n\ +rules :\n\ \tthe title must be on the first line, \n\ -\tthe author (preceded by nothing, "by " or "©") must be on the second line, possibly with the publication date in parenthesis (i.e., "By Unknown (3rd October 1998)"), \n\ -\tchapters must be declared with "Chapter x" or "Chapter x: NAME OF THE CHAPTER", where "x" is the chapter number,\n\ +\tthe author (preceded by nothing, "by " or "©") must be on the second \n\ +\t\tline, possibly with the publication date in parenthesis\n\ +\t\t(i.e., "By Unknown (3rd October 1998)"), \n\ +\tchapters must be declared with "Chapter x" or "Chapter x: NAME OF THE \n\ +\t\tCHAPTER", where "x" is the chapter number,\n\ \ta description of the story must be given as chapter number 0,\n\ -\ta cover image may be present with the same filename but a PNG, JPEG or JPG extension. +\ta cover image may be present with the same filename but a PNG, \n\ +\t\tJPEG or JPG extension. # Description of this input type # (FORMAT: STRING) -INPUT_DESC_INFO_TEXT = Contains the same information as the TEXT format, but with a companion ".info" file to store some metadata +INPUT_DESC_INFO_TEXT = Contains the same information as the TEXT format, but with a \n\ +\tcompanion ".info" file to store some metadata # Description of this input type # (FORMAT: STRING) -INPUT_DESC_FANFICTION = Fan fictions of many, many different universes, from TV shows to novels to games. +INPUT_DESC_FANFICTION = Fan fictions of many, many different universes, from TV shows to \n\ +\tnovels to games. # Description of this input type # (FORMAT: STRING) INPUT_DESC_FIMFICTION = Fanfictions devoted to the My Little Pony show # Description of this input type # (FORMAT: STRING) -INPUT_DESC_MANGAFOX = A well filled repository of mangas, or, as their website states: Most popular manga scanlations read online for free at mangafox, as well as a close-knit community to chat and make friends. +INPUT_DESC_MANGAFOX = A well filled repository of mangas, or, as their website states: \n\ +\tMost popular manga scanlations read online for free at mangafox, \n\ +\tas well as a close-knit community to chat and make friends. # Description of this input type # (FORMAT: STRING) INPUT_DESC_E621 = Furry website supporting comics, including MLP # Description of this input type # (FORMAT: STRING) -INPUT_DESC_E_HENTAI = Website offering many comics/manga, mostly but not always NSFW (hence 'Hentai'); MLP comics can be found there, too +INPUT_DESC_E_HENTAI = Website offering many comics/manga, mostly but not always NSFW \n\n +\t(hence Hentai); MLP comics can be found there, too +# Description of this input type +# (FORMAT: STRING) +INPUT_DESC_YIFFSTAR = A Furry website, story-oriented +# Description of this input type +# (FORMAT: STRING) +INPUT_DESC_CBZ = CBZ files coming from this very program +# Description of this input type +# (FORMAT: STRING) +INPUT_DESC_HTML = HTML files coming from this very program # Default description when the type is not known by i18n # (FORMAT: STRING) %s = type OUTPUT_DESC = Unknown type: %s @@ -111,16 +134,22 @@ OUTPUT_DESC_EPUB = Standard EPUB file working on most e-book readers and viewers # (FORMAT: STRING) OUTPUT_DESC_TEXT = Local stories encoded in textual format, with a few rules :\n\ \tthe title must be on the first line, \n\ -\tthe author (preceded by nothing, "by " or "©") must be on the second line, possibly with the publication date in parenthesis (i.e., "By Unknown (3rd October 1998)"), \n\ -\tchapters must be declared with "Chapter x" or "Chapter x: NAME OF THE CHAPTER", where "x" is the chapter number,\n\ +\tthe author (preceded by nothing, "by " or "©") must be on the second \n\ +\t\tline, possibly with the publication date in parenthesis \n\ +\t\t(i.e., "By Unknown (3rd October 1998)"), \n\ +\tchapters must be declared with "Chapter x" or "Chapter x: NAME OF THE \n\ +\t\tCHAPTER", where "x" is the chapter number,\n\ \ta description of the story must be given as chapter number 0,\n\ -\ta cover image may be present with the same filename but a PNG, JPEG or JPG extension. +\ta cover image may be present with the same filename but a PNG, JPEG \n\ +\t\tor JPG extension. # Description of this output type # (FORMAT: STRING) -OUTPUT_DESC_INFO_TEXT = Contains the same information as the TEXT format, but with a companion ".info" file to store some metadata +OUTPUT_DESC_INFO_TEXT = Contains the same information as the TEXT format, but with a \n\ +\tcompanion ".info" file to store some metadata # Description of this output type # (FORMAT: STRING) -OUTPUT_DESC_CBZ = CBZ file (basically a ZIP file containing images -- we store the images in PNG format) +OUTPUT_DESC_CBZ = CBZ file (basically a ZIP file containing images -- we store the images \n\ +\tin PNG format by default) # Description of this output type # (FORMAT: STRING) OUTPUT_DESC_HTML = HTML files (a directory containing the resources and "index.html") diff --git a/src/be/nikiroo/fanfix/library/BasicLibrary.java b/src/be/nikiroo/fanfix/library/BasicLibrary.java index cf17a2b..328ef65 100644 --- a/src/be/nikiroo/fanfix/library/BasicLibrary.java +++ b/src/be/nikiroo/fanfix/library/BasicLibrary.java @@ -29,6 +29,17 @@ import be.nikiroo.utils.Progress; * @author niki */ abstract public class BasicLibrary { + /** + * Return a name for this library (the UI may display this). + *

+ * Must not be NULL. + * + * @return the name, or an empty {@link String} if none + */ + public String getLibraryName() { + return ""; + } + /** * Retrieve the main {@link File} corresponding to the given {@link Story}, * which can be passed to an external reader or instance. diff --git a/src/be/nikiroo/fanfix/library/RemoteLibrary.java b/src/be/nikiroo/fanfix/library/RemoteLibrary.java index 513849e..337e13f 100644 --- a/src/be/nikiroo/fanfix/library/RemoteLibrary.java +++ b/src/be/nikiroo/fanfix/library/RemoteLibrary.java @@ -48,6 +48,11 @@ public class RemoteLibrary extends BasicLibrary { OutputType.CBZ); } + @Override + public String getLibraryName() { + return host + ":" + port; + } + @Override protected List getMetas(Progress pg) { // TODO: progress diff --git a/src/be/nikiroo/fanfix/reader/GuiReaderFrame.java b/src/be/nikiroo/fanfix/reader/GuiReaderFrame.java index 87d7075..39db588 100644 --- a/src/be/nikiroo/fanfix/reader/GuiReaderFrame.java +++ b/src/be/nikiroo/fanfix/reader/GuiReaderFrame.java @@ -22,6 +22,7 @@ import java.util.Map.Entry; import javax.swing.BoxLayout; import javax.swing.JFileChooser; import javax.swing.JFrame; +import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; @@ -29,6 +30,7 @@ import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JPopupMenu; import javax.swing.JScrollPane; +import javax.swing.SwingConstants; import javax.swing.SwingUtilities; import javax.swing.filechooser.FileFilter; import javax.swing.filechooser.FileNameExtensionFilter; @@ -112,6 +114,12 @@ class GuiReaderFrame extends JFrame { scroll.getVerticalScrollBar().setUnitIncrement(16); add(scroll, BorderLayout.CENTER); + String message = reader.getLibrary().getLibraryName(); + if (!message.isEmpty()) { + JLabel name = new JLabel(message, SwingConstants.CENTER); + add(name, BorderLayout.NORTH); + } + pgBar = new ProgressBar(); add(pgBar, BorderLayout.SOUTH);