       if not @state.dirty
         callback newLangCode
       else
-        @confirm tr('~CONFIRM.CHANGE_LANGUAGE'), -> callback newLangCode
+        postSave = (err) =>
+          if err
+            @alert(err)
+            @confirm tr('~CONFIRM.CHANGE_LANGUAGE'), -> callback newLangCode
+          else
+            callback newLangCode
+        if @state.metadata?.provider or @autoProvider 'save'
+          @save (err) -> postSave()
+        else
+          @saveTempFile postSave
 
   showBlockingModal: (modalProps) ->
     @_ui.showBlockingModal modalProps

      window.localStorage.removeItem key
    catch e
      callback "Unable to load copied file"

  _sharedMetadata: ->
    @state.currentContent?.getSharedMetadata() or {}

    else if hashParams.newInFolderParams
      [providerName, folder] = hashParams.newInFolderParams.split ':'
      @createNewInFolder providerName, folder
    else if @haveTempFile()
      @openAndClearTempFile()
    else
      # give providers a chance to process url params
      for provider in @state.availableProviders
