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.

Support

How to translate a modular page

Solved by Natalia Bazilenco View solution

Started by Natalia Bazilenco 3 years ago · 2 replies · 344 views
3 years ago

How can I translate the modular page to other languages. I read the documentation again about modular page, but did not find anything about translating modular pages. By analogy with my other site, I set up multilang.

YAML
languages:
  supported:
    - ua
    - ru
    - ro
    - en
  default_lang: ua
  include_default_lang: false
  include_default_lang_file_extension: true
  translations: true
  translations_fallback: true
  session_store_active: false
  http_accept_language: false
  override_locale: false
  content_fallback:
    ua: ua
    ru: ru
    en: en
    ro: ro
  pages_fallback_only: true
home:
  alias: /home

I created a page for English

02.home-eng winth modular.en.md

YAML
title: 'Home Eng'
content:
    items: '@self.modular'
    order:
        by: default
        dir: asc
        custom:
            - _showcase
            - _highlights
            - _callout
            - _features

For English page url is /en/home-eng but page on frontend is blank

last edited 03/07/23 by Natalia Bazilenco
3 years ago
it seems to work, I copied the files to a folder from 1.home into 2.home_ro and rename all md files to modular.ro.md, hero.ro and etc
+---01.home
modular.md
+---01._hero
header.jpg
hero.md
+---02._highlights
features.md
+---03._callout
jeep.jpg
text.md
---04._features
features.md
---02.home_ro modular.ro.md
TXT
+---01._hero
|       header.jpg
|       hero.ro.md
|       
+---02._highlights
|       features.ro.md
|       
+---03._callout
|       jeep.jpg
|       text.ro.md
|       
\---04._features
        features.ro.md
3 years ago Solution

Not correct. For translate One-Page site with modular content need:
1) in \user\pages\01.home need create modular file with language prefix (modular.ro.md, modular.ua.md, modular.en.md etc.)
2) in same modular folders need create .md file with language prefix (hero.ro.md, hero.en.md etc) Example "\user\pages\01.home\01._hero\hero.ro.md"

Then, when choosing a language, the site will display content for its language version

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
3 92 3 hours ago
Support · by Anna, 3 days ago
2 94 23 hours ago
Support · by Justin Young, 1 day ago
1 62 1 day ago
Support · by Duc , 1 week ago
2 98 6 days ago
Support · by Colin Hume, 1 week ago
2 91 6 days ago