<% if !user_signed_in? %>

<div class="dropdown locale-dropdown">
  <a class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="#">
    <% if I18n.locale == :en %>
      <%= image_tag asset_path('flags/us.png'), class: 'locale-flag' %>
      English
      <b class="caret"></b>
    <% elsif I18n.locale == :es %>
      <%= image_tag asset_path('flags/es.png'), class: 'locale-flag' %>
      Español
      <b class="caret"></b>
    <% end %>
  </a>
  <ul class="dropdown-menu text-left" role="menu" aria-labelledby="dropdownMenu">
    <li>
      <%= link_to url_for(locale: 'en') do %>
        <%= image_tag asset_path('flags/us.png'), class: 'locale-flag' %>
        English
      <% end %>
    </li>
    <li>
      <%= link_to url_for(locale: 'es') do %>
        <%= image_tag asset_path('flags/es.png'), class: 'locale-flag' %>
        Español
      <% end %>
    </li>
  </ul>
</div>

<% end %>
<% if !user_signed_in? %>

<div class="dropdown locale-dropdown">
  <a class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="#">
    <% if I18n.locale == :en %>
      <%= image_tag asset_path('flags/us.png'), class: 'locale-flag' %>
      English <i class="fa fa-fw fa-caret-down"></i>
    <% elsif I18n.locale == :es %>
      <%= image_tag asset_path('flags/es.png'), class: 'locale-flag' %>
      Español <i class="fa fa-fw fa-caret-down"></i>
    <% end %>
  </a>
  <ul class="dropdown-menu text-left" role="menu" aria-labelledby="dropdownMenu">
    <li>
      <%= link_to url_for(locale: 'en') do %>
        <%= image_tag asset_path('flags/us.png'), class: 'locale-flag' %>
        English
      <% end %>
    </li>
    <li>
      <%= link_to url_for(locale: 'es') do %>
        <%= image_tag asset_path('flags/es.png'), class: 'locale-flag' %>
        Español
      <% end %>
    </li>
  </ul>
</div>

<% end %>
Replace caret icon from glyphicons with caret icon from fontawesome, for better consistency.
Replace caret icon from glyphicons with caret icon from fontawesome, for better consistency.
