I’m in the process of migrating a pretty complex site to Trellis (finally). The last thing I need to tackle is localizing automated reminder ticket mails to users who ordered a trip via the site.
I use Polylang for localization. On the shared host I was on I had a cron running which set’s the users language by fetching it from the database and by running:
On the Trellis provisioned server (dev / staging) this doesn’t work. The automated mail will use the correct language strings, but will render dates in the default language.
They only way I’ve been able to fix this was by installing the language packs on the server via SSH. But it feels to me this isn’t the correct method to get this working. If it is, is there a way to automate this while provisioning?
Hope someone can point me in the right direction. Kind regards!
Thanks @ben! Thank you so much for your reply. I really appreciate it. I tried to search for an answer before posting but it never came to mind that the answer might lay in installing WP language packs via the CLI.
My site is already configured and deployed in Dutch and the WP language files are in my repo. This makes me wonder if installing languages via the CLI is redundant or does it do more than just downloading the *.mo files? From your reply I assume it also installs the locales as well? Is that correct?
That’s nice to hear. I didn’t get much feedback on my suggestion otherwise.
IMO this definitely belongs into the core (as a configurable option, as I laid out).
There are some problems on first deploy (when wordpress is not installed yet) but I think @strarsis provided some fixes for that. @ben: Are you interested in a core PR or would you rather see that as an extension?
Yes, but it should work on the second one.
I’ll get back to this next week and try to come up with a fixed version.
I also saw that wp-cli has changed, you have to update languages for themes and plugins separately now.
So you get an error when you deploy the first time?
I had the same issue when the WordPress site hadn’t been set up yet.
The WordPress site has to be set up first, this can also be done using wp,
then the language install commands are happy.
Currently I am using the project_copy_folders option:
# There are certain folders you'll want to copy from release to release to speed up deploys.
# Examples: Composer's `vendor` folder, npm's `node_modules`.
# These should not be part of project_shared_children since dependencies need to be atomic and tied to a deploy.
But when there is a better approach I would like to know.