Open HatemKhattab opened 4 years ago
Is key_1
and key_2
indented? Not sure if it was just a formatting error when creating this issue. If this is the case, then you'd access that variable as such: {% t 'en.key_1' %}
Hej Hani and thanks for your reply, its indented, its work like {% t 'en.key_1' %} but it not dynamic to chose the right translation file depends on the site language , I mean if the page is mysite.com/en ===> english translation or mysite.com/sv ==> swedish translation in this way it is enough to write {% t key_1 %}
Hi @HanniAbu and thanks for your reply, its idented, i want to bring the wright translation dynamically if mysite.com/en ===> english translation, if mysite.com/sv ===> swedish translation
in this way i just wirite {% t key_1 %}
I see, I haven't tried myself to see if it works, but something like this might do the trick:
Add this to the top of each page:
{% assign t = site.translations[site.lang].[site.lang] %}
Use in the page like this:
The value of Key 1 is {{ t.key_1 }} and the value of Key 2 is {{ t.key_2 }}.
it looks good @HanniAbu or maybe something like {%t site.lang.key_1%}
Hi
I used localeapp to pull my translation, it adding root key to en.yml like this
en: key_1: xx key_2: xx
is there away to make {%t key_1%} work if en.yml has a root key?