Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add wp language files on trellis deploy
---
- block:
- name: Install language files
command: wp core language install {{ item }}
args:
chdir: "{{ deploy_helper.new_release_path }}"
# check for existance of po-file, language install should only run once:
creates: "{{ deploy_helper.new_release_path }}/web/app/languages/{{ item }}.po"
with_items: "{{ project.languages }}"
# not sure if this is the best way to do this, but seems to work:
- name: Get installed language files
find:
paths: "{{ deploy_helper.new_release_path }}/web/app/languages"
patterns: "??.po,???.po,??_*.po"
register: language_files
# this should remove language files if languages are removed from the list:
- name: Uninstall unused language files
command: wp core language uninstall {{ item | splitext | first }}
args:
chdir: "{{ deploy_helper.new_release_path }}"
#debug: msg="{{ item | splitext | first }}"
with_items: "{{ language_files.files | map(attribute='path') | map('basename') | list }}"
when: item | splitext | first not in project.languages
# always run language update:
- name: Install/update language files for core, plugins and themes
command: wp core language update
args:
chdir: "{{ deploy_helper.new_release_path }}"
when: project.languages is defined
...
# add share-after hook:
vars:
deploy_build_before: "{{ playbook_dir }}/deploy-hooks/build-before.yml"
deploy_build_after: "{{ playbook_dir }}/roles/deploy/hooks/build-after.yml"
deploy_share_after: "{{ playbook_dir }}/deploy-hooks/share-after.yml"
deploy_finalize_before: "{{ playbook_dir }}/roles/deploy/hooks/finalize-before.yml"
deploy_finalize_after: "{{ playbook_dir }}/roles/deploy/hooks/finalize-after.yml"
...
wordpress_sites:
example.com:
site_hosts:
- canonical: staging.example.com
# redirects:
# - otherdomain.com
local_path: ../site # path targeting local Bedrock site directory (relative to Ansible root)
repo: git@github.com:example/example.com.git # replace with your Git repo URL
repo_subtree_path: site # relative path to your Bedrock/WP directory in your repo
branch: master
multisite:
enabled: false
ssl:
enabled: false
provider: letsencrypt
cache:
enabled: false
# add languages list, entries must be language codes as used by wp:
languages:
- de_DE
- fr_FR
...
# add languages folder to project_shared_children:
project_shared_children:
- path: web/app/uploads
src: uploads
- path: web/app/languages
src: languages
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment