Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting default_language takes no effect #1615

Closed
longfangsong opened this issue Sep 9, 2021 · 5 comments
Closed

Setting default_language takes no effect #1615

longfangsong opened this issue Sep 9, 2021 · 5 comments

Comments

@longfangsong
Copy link

longfangsong commented Sep 9, 2021

Bug Report

Environment

Zola version:
v0.14.1 (also apply to current next branch)

Expected Behavior

(In fact I'm a little confused about what's the expected behaviour for zola here. I read the doc and some similiar issues like #1512 but still cannot figure it out.)

I suppose setting default_language in config.toml will make __tera_context.config.title to be [languages.<default_language>.title].

Current Behavior

It seems zola always prefer translations under en.

Step to reproduce

In my templates/index.html:

<h1>{{ config.title }}</h1>

In config.toml:

# ...
title = "title"
default_language = "fr"
[translations]
title = "translations.title"

[languages.fr]
title = "languages.fr.title"
[languages.fr.translations]
home = "languages.fr.translations.home"

[languages.en]
title = "languages.en.title"
[languages.en.translations]
home = "languages.fr.translations.home"

All other files are untouched after zola init.

Serve with zola serve, the result is languages.en.title.

Some behaviour in other situations:

  • When all translation and languages stuff removed, ie.
    # ...
    # add or remove `default_language` makes no difference
    # default_language = "fr"
    title = "title"
    Then the result is nothing (__tera_context.config.title is null), is it a regression bug Incorrect values in __tera_context #1512 ?
  • When we have [languages.en], ie.
    # ...
    # add or remove `default_language` still makes no difference
    # default_language = "fr"
    [languages.en]
    title = "languages.en.title"
    [languages.en.translations]
    home = "languages.fr.translations.home"
    Then the result is always languages.en.title, no matter what value default_language is or other languages configuations added.
@Keats
Copy link
Collaborator

Keats commented Sep 9, 2021

The rendering should be language aware. Eg if you're rendering a en page, it will give you the en title. If you are rendering a fr page, it will give the fr title.

@longfangsong
Copy link
Author

The rendering should be language aware. Eg if you're rendering a en page, it will give you the en title. If you are rendering a fr page, it will give the fr title.

I got this, but what about default_language?

I suppose if I render with default_language='fr', I should get.

./public
├── en
│   └── index.html # content should be languages.en.title
├── index.html # content should be languages.fr.title
...
└── sitemap.xml

But in fact I got:

./public
├── fr
│   └── index.html # content is languages.fr.title
├── index.html # content is languages.en.title
...
└── sitemap.xml

@Keats
Copy link
Collaborator

Keats commented Sep 9, 2021

Can you push a very basic repo so I can have a look?

@longfangsong
Copy link
Author

Can you push a very basic repo so I can have a look?

https://github.com/longfangsong/zola-lab.git

@longfangsong
Copy link
Author

Same problem as #1634

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants