Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

General

Current lang is empty

Started by Alexander Kim 8 years ago · 3 replies · 575 views
8 years ago

I've added Kazakh language in system.yaml kk (it doesn't existing in Grav) and now my html lang is empty:

TWIG
<html lang="{{ grav.language.getActive ?: theme_config.default_lang }}">

What's wrong?

TXT
<html lang="">
8 years ago

hmm, looks like that should be fine, so have you set up

YAML
languages:
  translations: true

as described in Single language different than English?

Just a guess, but getActive probably needs translations enabled.

I just checked a site I have, where the single language is en-NZ and I don't have translations enabled. The template has:

TWIG
<html lang="{{ grav.language.getLanguage ?: theme_config.default_lang }}">

instead of getActive. I think I remember changing that after it didn't work (like yours). I suspect getLanguage will work anyway if there is only one supported language. Try that if you don't need translations.

👍 1
8 years ago

@hughbris:
hmm, looks like that should be fine, so have you set up

languages:
translations: true

as described in Single language different than English?

Translations are enabled, but "include default language" is disabled, because i won't use language code, if i have just one language on the site.

@hughbris:
instead of getActive. I think I remember changing that after it didn’t work (like yours). I suspect getLanguage will work anyway if there is only one supported language. Try that if you don’t need translations.

That worked, thanks. But this won't work if we have more than 1 language, right?

8 years ago

@heihachi88:
But this won’t work if we have more than 1 language, right?

Haha, I'm the wrong guy to ask as I pretty much work only in the English language world. My custom en-NZ is about all I've done with languages.

Experiment with different combinations or wait for another answer from someone here
who has multi-language experience.

Suggested topics

Topic Participants Replies Views Activity
General · by Jerry Hunt, 4 days ago
2 82 12 hours ago
General · by pamtbaau, 17 hours ago
1 55 16 hours ago
General · by Andy Miller, 1 day ago
0 45 1 day ago
General · by Marcel, 12 months ago
6 348 5 days ago
General · by Duc , 5 days ago
3 43 5 days ago