 API = require 'api'
 appSelectors = require './app-selectors.coffee'
 
-formatSelector = (state) ->
-	lang = state.lang
+langSelector = (state) ->
+	state.localeState.get 'lang'
+
+formatSelector = (state, lang) ->
 	moment.locale lang
 	utils.mapObjectRecursively(
 		state

containerSelector = Reselect.createSelector(
	[
		(state) ->
			state.articleState.set('lang', state.localeState.get 'lang').toJS()
	],
	formatSelector
)

articleSelector = (state) ->
	lang = state.localeState.get 'lang'
	state = state.articleState.toJS()
	if state.articles.length
		article = state.articles[0]

		article = API.getArticleDefaults()
	return {
		article: article
	}

itemSelector = Reselect.createSelector(
	[
		Reselect.createSelector(
			[ articleSelector, langSelector ]
			formatSelector
		)
		appSelectors.titleSelector
	]
	(state, titleState) ->
