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

Multilanguage support #30

Open
spanezz opened this issue Dec 15, 2019 · 2 comments
Open

Multilanguage support #30

spanezz opened this issue Dec 15, 2019 · 2 comments

Comments

@spanezz
Copy link
Owner

spanezz commented Dec 15, 2019

Ideas for multilanguage support, based on a conversation with @DonKult.

po4a

The text type (Locale::Po4a::Text) has partial markdown support. The support isn't perfect, but was good enough so far to translate a bunch of paragraphs more or less easily.

Maybe it's enough to play with multilanguage staticsite prototypes, and see where they'd lead.

Example invocations:

update-po: Impressum.md
        po4a-updatepo -M utf-8 -f text -o markdown -o tabs=verbatim -m Impressum.md -p po/en.po

translate-files-en: po/en.po
        po4a-translate -M utf-8 -f text -k 0 -o markdown -m Impressum.md -p $^ -l Imprint.md

Serving translated versions

Currently, only explicit interlinking of pages across different languages has been tested.

This bit in an html header would look nice, but it doesn't seem like mainstream browsers currently make use of that:

        {%- if page.meta.hreflang -%}
        <link rel="alternate" hreflang="x-default" href="{{ url_for(page) }}" />
        <link rel="alternate" hreflang="{{ page.meta.content_lang }}" href="{{ url_for(page) }}" />
        {%- for reflang in page.meta.hreflang -%}
        <link rel="alternate" hreflang="{{ reflang[0] }}" href="{{ url_for(reflang[1]) }}" />
        {%- endfor -%}

It's worth looking how lektor does it, since it claim multilingual support.

For convenience, two links to doing language content negotiation with apache and nginx:

Setting current locale

Generating site pages for one language would also require a setlocale call to generate things like dates correctly. See #22

@spanezz
Copy link
Owner Author

spanezz commented Dec 15, 2019

Lektor's documentation for multilingual support is here.

From what I have seen as a quick glance:

  • site-wide one configures a list of alternatives, each with its locale information
  • the site is built multiple times, writing the output into a directory prefixed with the alternative name. For example, the it alternative website would be built in $OUTPUT/it/*
  • one alternative can be configured as primary and it won't go into a subdirectory but in the root of the output dir as usual

Content-wise, in lektor one needs to manually provide one copy of each page per language, and I haven't seen any support for potfile and the like.

I'd like, if possible, at least some content negotiation, then keep one file per page, and use potfiles to help with translations.

@spanezz
Copy link
Owner Author

spanezz commented Dec 16, 2019

Hugo has a few more multilingual features, including supporting different SITE_URL per language

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

No branches or pull requests

1 participant