So I am making a language switcher that pulls the name of the language directly from their respective locales/xx.yml
file. One .yml
file starts like this:
---
fr:
lang: "Française"
langshort: "FR"
Here is the piece of code responsible for displaying language switch:
- locales.each do | locale |
- if locale == I18n.locale # dont display link to current locale
- else
%a{href: "/#{locale}/"} # this part works correctly, it displays correct URL
%span.mobile-hide= t('lang') # this does not work correctly, it pulls the data from the current locale file
%span.desktop-hide= t('langshort') # this does not work correctly, it pulls the data from the current locale file
Now I want that = t('lang')
and = t('langshort')
to actually display the correct language name from other files than the active I18n. How to access them?
@komor72 @tomrutgers I think you guys will know how to do it
UPDATE: I just realised this piece of code is not working correctly because by default I mount /en
to root so there is no /en/
page and it should show directly root (/
). I need to find a way to acommodate this too.