Add: Language Config on Build

This commit is contained in:
Siroco 2022-12-19 14:10:02 +01:00
parent 69aa02fcdc
commit 365821fda0
No known key found for this signature in database
GPG Key ID: 1324098302A514B0
2 changed files with 46 additions and 7 deletions

View File

@ -28,22 +28,51 @@ ADD wp-config.php /app/
ADD themes /app/ ADD themes /app/
RUN cd wp-content/themes && \ RUN cd wp-content/themes && \
for theme in `cat /app/themes`; do \ for theme in `cat /app/themes`; do \
DOWNLOAD_URL=`curl "https://api.wordpress.org/themes/info/1.1/?action=theme_information&request\[slug\]=$theme" |jq -r '.download_link'` && \ DOWNLOAD_URL=`curl -s "https://api.wordpress.org/themes/info/1.1/?action=theme_information&request\[slug\]=$theme" |jq -r '.download_link'` && \
wget -O theme.zip $DOWNLOAD_URL && \ wget -q -O theme.zip $DOWNLOAD_URL && \
unzip theme.zip && \ unzip -q theme.zip && \
rm theme.zip; \ rm theme.zip; \
done done
# install plugins # install plugins
ADD plugins /app/ ADD plugins /app/
RUN cd wp-content/plugins && \ RUN cd wp-content/plugins && \
for plugin in `cat /app/plugins`; do \ for plugin in `cat /app/plugins`; do \
DOWNLOAD_URL=`curl "https://api.wordpress.org/plugins/info/1.0/$plugin.json" |jq -r '.download_link'` && \ DOWNLOAD_URL=`curl -s "https://api.wordpress.org/plugins/info/1.0/$plugin.json" |jq -r '.download_link'` && \
wget -O plugin.zip $DOWNLOAD_URL && \ wget -q -O plugin.zip $DOWNLOAD_URL && \
unzip plugin.zip && \ unzip -q plugin.zip && \
rm plugin.zip; \ rm plugin.zip; \
done done
# install languages (core, plugins, themes)
ADD languages /app/
RUN mkdir -p wp-content/languages wp-content/languages/plugins wp-content/languages/themes && \
WP_VERSION=$(wp --allow-root core version) && \
for language in `cat /app/languages`; do \
cd /app/wp-content/languages && \
echo "Install Language Files $language" && \
DOWNLOAD_URL=`curl -s "https://api.wordpress.org/translations/core/1.0/?version=$WP_VERSION" | jq -r '.translations[] | select(.language=="'$language'").package '` && \
[ -z $DOWNLOAD_URL ] && echo "Download language file for $language not exist" && \
[ -z $DOWNLOAD_URL ] || wget -q -O language.zip $DOWNLOAD_URL && \
[ -f language.zip ] && unzip -q language.zip && \
[ -f language.zip ] && rm language.zip && \
cd plugins && \
for plugin in `cat /app/plugins`; do \
DOWNLOAD_URL=`curl -s "https://api.wordpress.org/translations/plugins/1.0/?slug=$plugin" | jq -r '.translations[] | select(.language=="'$language'").package '` && \
[ -z $DOWNLOAD_URL ] && echo "Download language file for $plugin : $language not exist" && \
[ -z $DOWNLOAD_URL ] || wget -q -O language.zip $DOWNLOAD_URL && \
[ -z $DOWNLOAD_URL ] || unzip -q language.zip && \
[ -z $DOWNLOAD_URL ] || rm language.zip; \
done && \
cd ../themes && \
for theme in `cat /app/themes`; do \
DOWNLOAD_URL=`curl -s "https://api.wordpress.org/translations/themes/1.0/?slug=$theme" | jq -r '.translations[] | select(.language=="'$language'").package '` && \
[ -z $DOWNLOAD_URL ] && echo "Download language file for $theme : $language not exist" && \
[ -z $DOWNLOAD_URL ] || wget -q -O language.zip $DOWNLOAD_URL && \
[ -z $DOWNLOAD_URL ] || unzip -q language.zip && \
[ -z $DOWNLOAD_URL ] || rm language.zip; \
done; \
done
VOLUME /app/wp-content/uploads VOLUME /app/wp-content/uploads

10
languages Normal file
View File

@ -0,0 +1,10 @@
es_ES
ca
de_DE
en_GB
en_US
es_MX
eu
fr_FR
gl_ES
zh_CN