pull/146/head
ruibaby 2019-04-06 20:59:52 +08:00
parent 5c1b521b11
commit eeb06ca9bb
5 changed files with 26 additions and 1 deletions

View File

@ -91,7 +91,7 @@ public class LocalFileHandler implements FileHandler {
Assert.notNull(file, "Multipart file must not be null");
// Get current time
Calendar current = Calendar.getInstance(Locale.CHINESE);
Calendar current = Calendar.getInstance(optionService.getLocale());
// Get month and day of month
int year = current.get(Calendar.YEAR);
int month = current.get(Calendar.MONTH) + 1;

View File

@ -6,6 +6,11 @@ package run.halo.app.model.properties;
*/
public enum BlogProperties implements PropertyEnum {
/**
* Blog locale.
*/
BLOG_LOCALE("blog_locale", String.class),
/**
* Blog title.
*/

View File

@ -268,4 +268,12 @@ public interface OptionService extends CrudService<Option, Integer> {
*/
@NonNull
Zone getQnYunZone();
/**
* Gets locale.
*
* @return locale user set or default locale
*/
@NonNull
Locale getLocale();
}

View File

@ -269,4 +269,15 @@ public class OptionServiceImpl extends AbstractCrudService<Option, Integer> impl
}).orElseGet(Zone::autoZone);
}
@Override
public Locale getLocale() {
return getByProperty(BlogProperties.BLOG_LOCALE).map(localeStr -> {
try {
return Locale.forLanguageTag(localeStr);
} catch (Exception e) {
return Locale.getDefault();
}
}).orElseGet(Locale::getDefault);
}
}

View File

@ -164,6 +164,7 @@ public class InstallController {
// Init default properties
Map<PropertyEnum, String> properties = new HashMap<>(11);
properties.put(PrimaryProperties.IS_INSTALLED, Boolean.TRUE.toString());
properties.put(BlogProperties.BLOG_LOCALE, installParam.getLocale());
properties.put(BlogProperties.BLOG_TITLE, installParam.getTitle());
properties.put(BlogProperties.BLOG_URL, installParam.getUrl());
properties.put(PrimaryProperties.THEME, DEFAULT_THEME_NAME);