package com.github.aureliano.achmed;

import java.util.Locale;

import org.apache.log4j.Logger;

import com.github.aureliano.achmed.idiom.LanguageCode;
import com.github.aureliano.achmed.idiom.LanguageSingleton;

public final class AppConfiguration {

	private static final Logger logger = Logger.getLogger(AppConfiguration.class);
	
	private LanguageCode language;
	
	public AppConfiguration() {
		this.applyConfiguration();
	}
	
	public void applyConfiguration() {
		logger.info("Apply core configuration.");
		this.configureLocale();
		LanguageSingleton.instance().setDefaultLanguageCode(this.language);
	}
	
	public LanguageCode getLanguage() {
		return language;
	}
	
	private void configureLocale() {
		logger.info("Configuring default locale.");
		
		Locale locale = Locale.getDefault();
		String code = locale.getLanguage() + "_" + locale.getCountry();
		
		logger.info(String.format(
				"Using default locale to %s with language %s (%s).",
				locale.getDisplayCountry(),
				locale.getDisplayLanguage(),
				code
			)
		);
		
		this.language = LanguageCode.valueOf(code.toUpperCase());
	}
}
@@ -204,16 +204,134 @@
 ngleton;
+%0Aimport com.github.aureliano.achmed.os.IOperatingSystem;%0Aimport com.github.aureliano.achmed.os.OperatingSystemFactory;
 %0A%0Apublic
@@ -477,16 +477,59 @@
 nguage;%0A
+%09private IOperatingSystem operatingSystem;%0A
 %09%0A%09publi
@@ -665,16 +665,19 @@
 ion.%22);%0A
+%09%09%0A
 %09%09this.c
@@ -764,16 +764,52 @@
 guage);%0A
+%09%09%0A%09%09this.resolveOperatingSystem();%0A
 %09%7D%0A%09%0A%09pu
@@ -842,16 +842,16 @@
 age() %7B%0A
-
 %09%09return
@@ -866,16 +866,437 @@
 e;%0A%09%7D%0A%09%0A
+%09public IOperatingSystem getOperatingSystem() %7B%0A%09%09return operatingSystem;%0A%09%7D%0A%09%0A%09private void resolveOperatingSystem() %7B%0A%09%09logger.info(%22Resolve operating system.%22);%0A%09%09%0A%09%09this.operatingSystem = OperatingSystemFactory.currentOperatingSystem();%0A%09%09logger.info(%22Operating System: %22 + this.operatingSystem.getOperatingSystem());%0A%09%09logger.info(%22Operating System family: %22 + this.operatingSystem.getOperatingSystemFamily());%0A%09%7D%0A%09%0A
 %09private

Configure operating system resolver.