locomotivecms / wagon

Wagon is a command line tool that let's you develop for Locomotive right on your local machine.
https://www.locomotivecms.com
MIT License
188 stars 117 forks source link

Better translation support #386

Open sebastienbeau opened 4 years ago

sebastienbeau commented 4 years ago

Context:

For the Shopinvader projet we want to share a community theme with a lot of translation. We want to translate the slug and the page name ...

current template is here : https://github.com/shopinvader/shopinvader-template/tree/master/app/views/pages

Current behavior:

For every language we need to add one page for each existing page. Ex: index.liquid => index.fr.liquid So basically if you want to have 4 langs you will have 4 pages

Also if you clone the official template and only want to use FR language you need to drop merge all .fr.liquid page in .liquid page and drop the useless *.fr.liquid page

Proposal behavior:

Instead of create a page per lang, the idea is to add a directory "page_translation" in the data directory and inside this directory one file per lang.

- app
  + assets/*
  + content_types/*
  + views
    + pages/*
    + sections/*
    + snippets/*
- config
  + deploy.yml
  + site.yml
  + translation.yml
  + metafields_schema.yml
- data
  + customers.yml
  + posts_groups.yml
  + posts.yml
  + page_translation
     + fr.yml
     + en.yml
     + de.yml
- public

The file will look like this :

index:
   title: Home page
   slug: home
account:
   title: Account
   published: false
   slug: my-account
...

And an header of an page will look like this

sections_dropzone_content:
   -...

So basically the value will be

Note : For sure if you want you localize your sections_dropzone_content, but this make your translation file huge with not big added value (because the customer will modify it). So we recommand to keep the sections_dropszone_content is the page.liquid and use Lorem Ipsum.

Regarding slug, handle :

Currently user mix handle, slug and their have difficulty to understand what is what.

So I propose the following behavior:

Handle of directory : When creating a directory (without any page with the same name) wagon will create a page on locomotive but the page do not have any handle. So if you create a page after with the same name it will create a new page and you will have 2 pages.

The idea is now to set as handle the name of the repository. So if you create a directory, deploy and latter create a page with the same name as the directory, the next deploy will update the page instead of creating a new one.

@thibaultrey I need your feedback, I already talk about it with @did