$ = jQuery
context = window
logger = context.JK.logger

@LanguageStore = Reflux.createStore(
  {
    listenables: @LanguageActions
    languages: []
    languageLookup: {}

    init: ->
      # Register with the app store to get @app
      this.listenTo(context.AppStore, this.onAppInit)

    onAppInit: (@app) ->
      rest.getLanguages().done (languages) =>
        @languages = languages
        for language in @languages
          @languageLookup[language.id] = language.description
        @trigger(@languages)

    display: (id)  ->
      @languageLookup[id]
  }
)
