CDRH / orchid

Rails Engine for site integration with CDRH API
MIT License
3 stars 0 forks source link

Tell google not to translate language toggle #206

Closed karindalziel closed 3 years ago

karindalziel commented 3 years ago

On the family letters website, google was trying to translate the "ES/EN" toggle as "IT IS/IN"

I overwrite the template there with the following, but we should change in orchid (then we can remove that template in family letters)

I'm just adding the "notranslate" class to the buttons.

(this may also be indicative of lang attributes being set incorrectly/not being set somewhere, so experiment to see if we can fix in other ways)

another wayt to fix this may just be to spell out the whole language

<% if APP_OPTS["languages"].present? && APP_OPTS["languages"][/\|/] %>
  <div class="language_link btn-group" role="group" aria-label="language choice">
    <% APP_OPTS["languages"].split("|").each do |lang_code| %>
      <%# create link to switch languages that keeps current parameters %>
      <%# TODO a11y / ARIA markup for full language names? %>
      <% if lang_code == I18n.locale.to_s %>
        <%= link_to lang_code.upcase, "#", class: "btn btn-primary disabled notranslate",
          hreflang: lang_code, rel: "alternate", tabindex: -1 %>
      <% else %>
        <%# a11y / ARIA markup for full language name? %>
        <%= link_to lang_code.upcase, locale_link(lang_code),
          class: "btn btn-default notranslate", hreflang: lang_code, rel: "alternate" %>
      <% end %>
    <% end %>
  </div>
<% end %>
jduss4 commented 3 years ago

A couple solutions for this:

One would be to show the language in its own language: Español / English / 日本語, for example Another would be to write the language in the current language: Spanish / English / Japanese, for example

I'm tempted to say we should go for the first one, since after some looking around that appears to be the most common scenario. We could use the yaml files and so if anybody needed to alter them for a specific site, it would not be difficult to change the display.