Localization fixes

This commit is contained in:
Georgy Litvinov 2021-04-09 14:51:37 +02:00
parent 7db145b987
commit 085735e509
2 changed files with 168 additions and 133 deletions

View file

@ -590,59 +590,88 @@ public class ConfigurationWindow extends JFrame {
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addGap(32)
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(cb_Pagination, GroupLayout.PREFERRED_SIZE, 303, GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addGap(1)
.addComponent(lb_Scale, GroupLayout.PREFERRED_SIZE, 168, GroupLayout.PREFERRED_SIZE)
.addGap(33)
.addComponent(tf_Scale, GroupLayout.PREFERRED_SIZE, 175, GroupLayout.PREFERRED_SIZE))
.addComponent(lb_SplitByLevel, GroupLayout.PREFERRED_SIZE, 454, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(tf_SplitByLevel, GroupLayout.PREFERRED_SIZE, 48, GroupLayout.PREFERRED_SIZE)
.addGap(541))
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(lb_MaxWidth, GroupLayout.PREFERRED_SIZE, 175, GroupLayout.PREFERRED_SIZE)
.addGap(28)
.addComponent(tf_MaxWidth, GroupLayout.PREFERRED_SIZE, 175, GroupLayout.PREFERRED_SIZE))
.addComponent(cb_Greenstone, GroupLayout.PREFERRED_SIZE, 482, GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(cb_IgnoreEmptyParagraphs, GroupLayout.PREFERRED_SIZE, 441, GroupLayout.PREFERRED_SIZE)
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(cb_IgnoreHardLineBreaks, GroupLayout.PREFERRED_SIZE, 341, GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(cb_convertToPx, GroupLayout.PREFERRED_SIZE, 592, GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(cb_EmbedRaster)
.addContainerGap())
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(cb_EmbedVectorImages, GroupLayout.PREFERRED_SIZE, 276, GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(cb_InlineStyles, GroupLayout.PREFERRED_SIZE, 322, GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(lb_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, 350, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(tf_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, 58, GroupLayout.PREFERRED_SIZE))
.addComponent(cb_convertToPx, GroupLayout.PREFERRED_SIZE, 592, GroupLayout.PREFERRED_SIZE)
.addComponent(cb_Greenstone, GroupLayout.PREFERRED_SIZE, 482, GroupLayout.PREFERRED_SIZE)
.addComponent(cb_EmbedRaster)
.addComponent(tf_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, 58, GroupLayout.PREFERRED_SIZE)
.addGap(635))
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(lb_MaxWidth, GroupLayout.PREFERRED_SIZE, 175, GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(lb_Scale, GroupLayout.PREFERRED_SIZE, 168, GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(lb_TargetFormat_description, GroupLayout.PREFERRED_SIZE, 178, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(lb_TargetFormat, GroupLayout.PREFERRED_SIZE, 111, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(lb_SplitByLevel, GroupLayout.PREFERRED_SIZE, 454, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(tf_SplitByLevel, GroupLayout.PREFERRED_SIZE, 175, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING, false)
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(lb_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, 191, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(tf_pageBreakInlineStyle))
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(lb_FilePath, GroupLayout.PREFERRED_SIZE, 193, GroupLayout.PREFERRED_SIZE)
.addComponent(lb_OutFilePath, GroupLayout.PREFERRED_SIZE, 191, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING, false)
.addComponent(tf_OutputFile, Alignment.TRAILING)
.addComponent(tf_inputFile, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 576, Short.MAX_VALUE))))
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(tf_OutputFile, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 579, Short.MAX_VALUE)
.addComponent(tf_inputFile, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 579, Short.MAX_VALUE))
.addGap(13)
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(btn_ChooseInputFile, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE)
.addComponent(btn_ChooseOutputFile, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE)))
.addComponent(cb_UseMathJax, GroupLayout.PREFERRED_SIZE, 352, GroupLayout.PREFERRED_SIZE)
.addComponent(cb_SplitWholePagesOnly, GroupLayout.PREFERRED_SIZE, 323, GroupLayout.PREFERRED_SIZE)
.addComponent(cb_InlineStyles, GroupLayout.PREFERRED_SIZE, 322, GroupLayout.PREFERRED_SIZE)
.addComponent(cb_EmbedVectorImages, GroupLayout.PREFERRED_SIZE, 276, GroupLayout.PREFERRED_SIZE)
.addComponent(cb_IgnoreHardLineBreaks, GroupLayout.PREFERRED_SIZE, 341, GroupLayout.PREFERRED_SIZE)
.addComponent(cb_IgnoreEmptyParagraphs, GroupLayout.PREFERRED_SIZE, 441, GroupLayout.PREFERRED_SIZE))
.addGap(127))
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(lb_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, 191, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(tf_Scale, GroupLayout.PREFERRED_SIZE, 175, GroupLayout.PREFERRED_SIZE)
.addComponent(tf_pageBreakInlineStyle, GroupLayout.DEFAULT_SIZE, 707, Short.MAX_VALUE)
.addComponent(tf_MaxWidth, GroupLayout.PREFERRED_SIZE, 175, GroupLayout.PREFERRED_SIZE))))
.addGap(145)))))))))))))))
);
gl_panel_configHTML.setVerticalGroup(
gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addContainerGap()
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE)
@ -662,62 +691,50 @@ public class ConfigurationWindow extends JFrame {
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE)
.addComponent(lb_pageBreakInlineStyle)
.addComponent(tf_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.RELATED, 10, Short.MAX_VALUE)
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.TRAILING)
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(tf_Scale, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(5))
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addGap(18)
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE)
.addComponent(lb_Scale)
.addGap(8)))
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addGap(2)
.addComponent(lb_MaxWidth))
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(tf_Scale, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE)
.addComponent(lb_MaxWidth)
.addComponent(tf_MaxWidth, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(tf_MaxWidth, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addGap(8)
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE)
.addComponent(lb_FilterLetterSpacing)
.addGap(4)
.addComponent(tf_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(cb_InlineStyles)
.addGap(7)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(cb_EmbedVectorImages)
.addGap(7)
.addComponent(cb_EmbedRaster))
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addGap(6)
.addComponent(tf_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
.addGap(7)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(cb_EmbedRaster)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(cb_convertToPx)
.addPreferredGap(ComponentPlacement.RELATED)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(cb_IgnoreHardLineBreaks)
.addGap(7)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(cb_IgnoreEmptyParagraphs)
.addGap(4)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(cb_Greenstone)
.addGap(8)
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(tf_SplitByLevel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addGap(2)
.addComponent(lb_SplitByLevel, GroupLayout.PREFERRED_SIZE, 16, GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE)
.addComponent(lb_SplitByLevel, GroupLayout.PREFERRED_SIZE, 16, GroupLayout.PREFERRED_SIZE)
.addComponent(tf_SplitByLevel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(cb_SplitWholePagesOnly)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(cb_UseMathJax)
.addPreferredGap(ComponentPlacement.RELATED)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(cb_Pagination)
.addContainerGap(248, Short.MAX_VALUE))
.addPreferredGap(ComponentPlacement.RELATED, 128, Short.MAX_VALUE))
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addGap(34)
.addComponent(btn_ChooseInputFile)
.addGap(10)
.addComponent(btn_ChooseOutputFile)
.addContainerGap(649, Short.MAX_VALUE))
.addPreferredGap(ComponentPlacement.RELATED, 414, Short.MAX_VALUE)))
.addGap(118))
);
panel_configHTML.setLayout(gl_panel_configHTML);
return panel_configHTML;
@ -945,9 +962,9 @@ public class ConfigurationWindow extends JFrame {
.addComponent(cb_InlineStyles)
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.TRAILING)
.addComponent(lb_TargetFormat_description, Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 311, GroupLayout.PREFERRED_SIZE)
.addGroup(Alignment.LEADING, gl_panel_configHTML.createSequentialGroup()
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(lb_TargetFormat_description, GroupLayout.PREFERRED_SIZE, 311, GroupLayout.PREFERRED_SIZE)
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(lb_FilePath, GroupLayout.PREFERRED_SIZE, 176, GroupLayout.PREFERRED_SIZE)
.addComponent(lb_metadataFilePath, GroupLayout.PREFERRED_SIZE, 177, GroupLayout.PREFERRED_SIZE)
@ -955,12 +972,12 @@ public class ConfigurationWindow extends JFrame {
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(lb_TargetFormat, GroupLayout.PREFERRED_SIZE, 68, GroupLayout.PREFERRED_SIZE)
.addComponent(tf_OutputFile, GroupLayout.DEFAULT_SIZE, 592, Short.MAX_VALUE)
.addComponent(tf_OutputFile, GroupLayout.DEFAULT_SIZE, 572, Short.MAX_VALUE)
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(tf_metadataPath, GroupLayout.DEFAULT_SIZE, 591, Short.MAX_VALUE)
.addComponent(tf_metadataPath, GroupLayout.DEFAULT_SIZE, 571, Short.MAX_VALUE)
.addGap(1))
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(tf_inputFile, GroupLayout.DEFAULT_SIZE, 589, Short.MAX_VALUE)
.addComponent(tf_inputFile, GroupLayout.DEFAULT_SIZE, 569, Short.MAX_VALUE)
.addGap(3)))))
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_configHTML.createSequentialGroup()
@ -974,10 +991,10 @@ public class ConfigurationWindow extends JFrame {
.addComponent(btn_ChooseOutputFile, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE)))
.addGap(149))
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(lb_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, 210, GroupLayout.PREFERRED_SIZE)
.addComponent(lb_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, 196, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(tf_pageBreakInlineStyle, GroupLayout.DEFAULT_SIZE, 660, Short.MAX_VALUE)
.addGap(149))
.addComponent(tf_pageBreakInlineStyle, GroupLayout.DEFAULT_SIZE, 692, Short.MAX_VALUE)
.addGap(145))
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(lb_type, GroupLayout.PREFERRED_SIZE, 148, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
@ -1032,7 +1049,7 @@ public class ConfigurationWindow extends JFrame {
.addGap(20)
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE)
.addComponent(lb_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE)
.addComponent(tf_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
.addComponent(tf_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(18)
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE)
.addComponent(lb_type)
@ -1061,7 +1078,7 @@ public class ConfigurationWindow extends JFrame {
.addComponent(cb_UseMathJax)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(cb_Pagination)
.addContainerGap(238, Short.MAX_VALUE))
.addContainerGap(113, Short.MAX_VALUE))
);
panel_configHTML.setLayout(gl_panel_configHTML);
return panel_configHTML;
@ -1112,9 +1129,9 @@ public class ConfigurationWindow extends JFrame {
.addGap(83)
.addComponent(btn_Exit, GroupLayout.PREFERRED_SIZE, 100, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(btn_SaveAs, GroupLayout.PREFERRED_SIZE, 100, GroupLayout.PREFERRED_SIZE)
.addComponent(btn_SaveAs, GroupLayout.PREFERRED_SIZE, 140, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(btn_Save, GroupLayout.PREFERRED_SIZE, 100, GroupLayout.PREFERRED_SIZE)
.addComponent(btn_Save, GroupLayout.PREFERRED_SIZE, 120, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(btn_startConversion, GroupLayout.PREFERRED_SIZE, 100, GroupLayout.PREFERRED_SIZE)
.addContainerGap(427, Short.MAX_VALUE))

View file

@ -12,21 +12,39 @@ public class Localizer {
private Locale currentLocale;
private String resourceBundle = "pro.litvinovg.w2phtml.gui.localizations.w2phtml";
private ResourceBundle translations;
private boolean isOld = false;
public Localizer() {
currentLocale = Locale.forLanguageTag("RU");//Locale.getDefault();
translations = ResourceBundle.getBundle(resourceBundle, currentLocale);
this.isOld = isOldJava();
}
public String getTranslation(String name) {
if (translations != null && translations.containsKey(name)) {
String translation = translations.getString(name);
if (isOld) {
try {
return new String(translation.getBytes("ISO-8859-1"), "UTF-8");
} catch(UnsupportedEncodingException e) {
e.printStackTrace();
}
} else {
return translation;
}
}
return TRANSLATION_NOT_FOUND;
}
private boolean isOldJava() {
try {
String versionString = System.getProperty("java.class.version");
Float version = Float.parseFloat(versionString);
if (version < 53) {
return true;
}
} catch (Exception e) {
System.out.println(e.getLocalizedMessage());
}
return false;
}
}