Skip to content

Commit

Permalink
Version 0.5 released.
Browse files Browse the repository at this point in the history
  • Loading branch information
kreinhard committed Oct 30, 2018
1 parent ad5e50b commit 8c2ba0b
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 20 deletions.
6 changes: 6 additions & 0 deletions merlin-core/src/main/java/de/reinhard/merlin/CoreI18n.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,10 @@ public CoreI18n() {
public CoreI18n(Locale locale) {
super(BUNDLE_NAME, locale);
}

@Override
protected I18n create(Locale locale) {
return new CoreI18n(locale);
}

}
6 changes: 5 additions & 1 deletion merlin-core/src/main/java/de/reinhard/merlin/I18n.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@
*/
public class I18n {
private ResourceBundle resourceBundle;
private Map<Locale, I18n> i18nMap = new HashMap<>();
private Map<Locale, I18n> i18nMap;

public I18n get(Locale locale) {
if (i18nMap == null) {
i18nMap = new HashMap<>();
}
I18n i18n = i18nMap.get(locale);
if (i18n == null) {
i18n = create(locale);
i18nMap.put(locale, i18n);
}
return i18n;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.reinhard.merlin.word.templating;

import de.reinhard.merlin.CoreI18n;
import de.reinhard.merlin.I18n;
import de.reinhard.merlin.excel.ExcelCell;
import de.reinhard.merlin.excel.ExcelRow;
Expand All @@ -26,16 +25,9 @@ public class AbstractExcelWriter {
protected CellStyle descriptionStyle;
protected ExcelSheet currentSheet; // Current working sheet.
protected TemplateRunContext templateRunContext;
protected I18n i18n;

public AbstractExcelWriter() {
this(CoreI18n.getDefault());
}

public AbstractExcelWriter(I18n i18n) {
this.i18n = i18n;
templateRunContext = new TemplateRunContext();
templateRunContext.setI18n(i18n);
}

public TemplateRunContext getTemplateRunContext() {
Expand Down Expand Up @@ -66,11 +58,11 @@ protected ExcelRow addDescriptionRow(String descriptionKey, int numberOfColumns,
row = currentSheet.createRow();
String msg;
if (dontModify) {
msg = i18n.getMessage(descriptionKey)
msg = getI18n().getMessage(descriptionKey)
+ "\n"
+ i18n.getMessage("merlin.word.templating.sheet_configuration_hint");
+ getI18n().getMessage("merlin.word.templating.sheet_configuration_hint");
} else {
msg = i18n.getMessage(descriptionKey);
msg = getI18n().getMessage(descriptionKey);
}
row.createCell().setCellStyle(descriptionStyle).setCellValue(msg);
if (numberOfColumns > 0) {
Expand Down Expand Up @@ -98,8 +90,8 @@ protected ExcelCell addConfigRow(String variable, Object value, String descripti
// Description
ExcelCell cell = row.createCell();
if (description != null) {
if (i18n.containsMessage(description)) {
cell.setCellValue(i18n.getMessage(description));
if (getI18n().containsMessage(description)) {
cell.setCellValue(getI18n().getMessage(description));
} else {
cell.setCellValue(description);
}
Expand Down Expand Up @@ -150,9 +142,13 @@ protected void writeValue(ExcelCell cell, Object value, VariableType type) {


protected void createConfigurationSheet() {
currentSheet = workbook.createOrGetSheet(i18n.getMessage(CONFIGURATION_SHEET_NAME));
currentSheet = workbook.createOrGetSheet(getI18n().getMessage(CONFIGURATION_SHEET_NAME));
ExcelRow row = addDescriptionRow("merlin.word.templating.sheet_configuration_description", 3);
row = currentSheet.createRow();
row.createCells(headRowStyle, "Variable", "Value", "Description");
}

protected I18n getI18n() {
return this.templateRunContext.getI18n();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public ExcelWorkbook writeToWorkbook() {
}

private void createVariablesSheet() {
currentSheet = workbook.createOrGetSheet(i18n.getMessage(SERIAL_VARIABLES_SHEET_NAME));
currentSheet = workbook.createOrGetSheet(getI18n().getMessage(SERIAL_VARIABLES_SHEET_NAME));
addDescriptionRow("merlin.word.templating.sheet_serial_variables_description", -1, false);
ExcelRow row = currentSheet.createRow();
int numberOfColumns = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,12 @@ public I18n getI18n() {
return i18n;
}

/**
* Sets i18n and locale. If you want to use your own i18n, please call {@link #setI18n(I18n)} after {@link #setLocale(Locale)}.
* @param locale
*/
public void setLocale(Locale locale) {
i18n = new CoreI18n(locale);
i18n = CoreI18n.getDefault().get(locale);
this.locale = locale;
}
}
2 changes: 1 addition & 1 deletion merlin-installer/merlin.install4j
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
</iconImageFiles>
</launcher>
</launchers>
<installerGui installerType="1" addOnAppId="" suggestPreviousLocations="true" autoUpdateDescriptorUrl="https://github.com/kreinhard/merlin/raw/master/merlin-installer/updates.xml" useAutoUpdateBaseUrl="true" autoUpdateBaseUrl="https://sourceforge.net/projects/pforge/files/Merlin/0.5/">
<installerGui installerType="1" addOnAppId="" suggestPreviousLocations="true" autoUpdateDescriptorUrl="https://github.com/kreinhard/merlin/raw/master/merlin-installer/updates.xml" useAutoUpdateBaseUrl="true" autoUpdateBaseUrl="https://sourceforge.net/projects/merlinrunner/files/0.5/">
<staticMembers script="" />
<customCode />
<autoUpdate useMinUpdatableVersion="false" minUpdatableVersion="" useMaxUpdatableVersion="false" maxUpdatableVersion="">
Expand Down
4 changes: 2 additions & 2 deletions merlin-installer/updates.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<updateDescriptor baseUrl="https://sourceforge.net/projects/pforge/files/Merlin/0.4/">
<entry targetMediaFileId="61" updatableVersionMin="" updatableVersionMax="" fileName="merlin_macos_0_4.dmg" newVersion="0.4" newMediaFileId="61" fileSize="102547591" md5Sum="ea18bb846af5e01e1b4e38eda5be648b" bundledJre="macosx-amd64-10.0.2" archive="false" singleBundle="true">
<updateDescriptor baseUrl="https://sourceforge.net/projects/merlinrunner/files/0.5/">
<entry targetMediaFileId="61" updatableVersionMin="" updatableVersionMax="" fileName="merlin_macos_0_5.dmg" newVersion="0.5" newMediaFileId="61" fileSize="102854791" md5Sum="04e3a4f2f17be4839bea5ed90476dbc9" bundledJre="macosx-amd64-10.0.2" archive="false" singleBundle="true">
<comment language="en" />
<comment language="de" />
</entry>
Expand Down

0 comments on commit 8c2ba0b

Please sign in to comment.