primocms / builder

MIT License
11 stars 31 forks source link

Add an option to change primary language for a deployment #13

Open tnzk opened 11 months ago

tnzk commented 11 months ago

Currently, Primo uses English as the primary language (#120). When you have different locales, the root ('/') serves the texts and images for English, and other locales, say German, are served via /de. This can be annoying when you build a site for primarily non-English speakers where you need to use the root for an other language, which forces using another locale to host English version. Visitors for the site will see English in /de or the like.

This PR adds a select box in the "Deploy modal" to choose which language to use as the primary language in the deployment.

スクリーンショット 2023-10-11 15 21 07

It builds the site bundle in which the files in root have the content in the primary language chosen with sub directories any other languages.

$ tree .
.
├── _symbols
│   ├── 2807ecaa-82f5-45dc-ba3f-c9c6d5abfa83.js
│   └── abcbb3c8-27e8-4ee7-9d6f-cdb3f0134289.js
├── edit
│   └── index.html
├── en
│   └── index.html
├── index.html
├── primo.json
└── robots.txt

For simplicity, it just asks the primary language every time you are to deploy. It could be useful if you can choose and persist the primary language as part of metadata, as suggested in #120. It will also enable to follow the setting in the language selector in the editing screen. This will involve a DB migration (adding non-nullable default_locale which defaults to 'en' to sites table), let me know if you find this a good idea to include in this PR.

matthewmateo commented 11 months ago

Thank you for this! Definitely would love to implement this functionality ASAP for international users.

One thing I noticed though is that it looks like English and Japanese are static values in the Deployment modal? Is this still a work in progress?

Will review more tomorrow, thanks again!

tnzk commented 11 months ago

Thank you for reviewing! I forgot they were yet to be fixed, now I updated it to show languages used in the site as the options.

I also added primary_language as a store, so that users don't have to choose the language every time he/she deploys.

micahmills commented 2 months ago

Other than the merge conflicts what else needs to be done to get this merged in? I would like this feature and I have some time to help with it.