   ###
     Set @userFavLang from browser accept languages
   ###
-  @setUserFavLangFromBrowserAcceptLanguages: () ->
+  @setUserFavLangToStoreFromBrowserAcceptLanguages: () ->
     # Select language tag without region
     i = 0
+    l ledger.i18n.browserAcceptLanguages
     for str in ledger.i18n.browserAcceptLanguages
       if ledger.i18n.browserAcceptLanguages[i].length > 2
         i++




  # User Favorite Locale ####

  ###
    Set user locale (region)

    @param [String] tag Codified (BCP 47) language tag - Official list here : http://www.iana.org/assignments/language-subtag-registry/language-subtag-registry
  ###
  @setLocale: (tag) =>
    # If tag language is set manually
    if tag?
      if tag.length < 5
        throw new Error 'Tag language must be at least five characters. Use ledger.i18n.setUserFavLang() if you want to set the language without the region'
      if tag.substr(0, 2) isnt @userFavLang
        throw new Error 'You cannot set a locale which does not correspond to the user favorite language'
      @userFavLocale = tag
    else
      tag ?= @userFavLocale || @browserUiLang
      @userFavLocale = tag

    # set tag language to one of the store
    if ledger.storage.sync?
      ledger.storage.sync.set({i18n_userFavLocale: tag})
      @checkBoolLocale()
    else
      ledger.i18n.chromeStore.set({i18n_userFavLocale: tag})
      @checkBoolLocale()


    deferred = Q.defer()
    if ledger.storage.sync?
      ledger.storage.sync.get 'i18n_userFavLocale', (r) =>
        l 'sync store: userFavLocale', r.i18n_userFavLocale
        if r.i18n_userFavLocale isnt undefined
          @userFavLocaleSyncStoreIsSet = true
          deferred.resolve('@userFavLocale is set into synced Store')
        else
          @userFavLocaleSyncStoreIsSet = false
          deferred.reject('@userFavLocale is not set into synced Store')
    else
      @chromeStore.get 'i18n_userFavLocale', (r) =>
        #l 'chrome store: userFavLocale', r.i18n_userFavLocale
        if r.i18n_userFavLocale isnt undefined
          @userFavLocaleChromeStoreIsSet = true
          deferred.resolve('@userFavLocale ' + r.i18n_userFavLocale + ' is set into chrome Store')
        else
          @userFavLocaleChromeStoreIsSet = false
          l '@userFavLocale is not set neither into synced Store or chrome store'
          deferred.reject(false)

    return deferred.promise

