Install&Update wordpress languages with composer


#21

I’m not sure if I understood correctly but you can ignore things in your repo using .gitignore file (Google: .gitignore)

Here’s an example from bedrock: https://github.com/roots/bedrock/blob/master/.gitignore


#22

Sorry, I have expressed myself wrong. I mean a function that extends the .gitignore automatically based on the installed composer packages.


#23

Ah, yes!
I usually ignore all and then add exceptions to files which to add. I don’t know anything which does this automatically though, this would nice feature.

Maybe you could start a hobby project which does all this :smile:


#24

That would be interesting. Maybe later this year :wink:

Now I have a problem with the composer on a remote server. It loads any language files in the specified folder. The language folders are available or in the repository. On my local VM everything works.

Does anyone have an idea?


#25

This is stunning, very helpful.

Does anybody know how to use this to make the admin in a different language? I’ve tried adding define('WPLANG', 'fr_FR'); in environments / development.php but with zero success, everything stays in english.


#26

Hey!

Did you find answer to your problem?

I usually just use WP Native Dashboard in all instances. This allows your enduser to choose which language they want to use in dashboard. Then you don’t have to worry about forcing admin to any specific language.


#27

Awesome thank you, will use that next time! (I just let it be in english for this one)


#28

Sadly this won’t work with the default trellis configuration. By default composer runs with the
--no-scripts flag which disables any composer scripts used by koodimoonni.


#29

Thanks for pointing that out. It’s pretty easy to override that default hook file but it might be worth looking into to remove that specific option.


#30

I think that --no-scripts is good for security especially for noobs. @swalkinshaw do you know if composer has option to allow specific script to run or specific package but deny all others? Like a whitelisting feature.

This might be pointless but anyone Is able to put harmless code in their composer packages and I guess that most users never look the code which is run in the implicit scripts like these language packages.


#31

Don’t think that’s possible but you can always use composer run-script to manually trigger them.


#32

This is my current workaround for a trellis-bedrock project to get the great composer language dropin up and running. If anyone has a better approach, please share :slightly_smiling:

  1. Remove --no-scripts flag from trellis/roles/deploy/hooks/build-after.yml. This enables composer to move the language files to the configured language directory. Note: imho we currently cannot use run-script, because the dropin installer doesn’t support triggering scripts (yet).
  2. Add web/app/languages/* to site/.gitignore (or wherever your bedrock project is located)
  3. The language folder has to be a shared folder on the server. Open trellis/roles/deploy/defaults/main.yml and add the following path to project_shared_children
project_shared_children:
[...]
  - path: web/app/languages
    src: languages

#33

@o1y thanks for sharing this!

Two improvements/tips which both have to do with trying to avoid modifying “core” Trellis files:

  1. You could make a copy of roles/deploy/hooks/build-after.yml and make your customizations there. Then define the new hook file as see here.
  2. Override project_shared_children in your own group_vars folder. Maybe group_vars/all/main.yml

This will make it easier to keep Trellis up to date (if that’s a concern of yours).


#34

BREAKING CHANGES
This repository is now located in: https://wp-languages.github.io

I needed to change the address because composer changed and needs all repositories as https. I redirected https://languages.koodimonni.fi to the new repository as well, but please use https://wp-languages.github.io instead than my server.


#35

This repository only contains translations for core and few selected plugins (mainly core plugins + woocommerce, bbpress). I added details in wp-languages.github.io repo if you want to manually add any translation zip into your project.

If you can run wp-cli in your deploy please consider using it’s language features:

$ wp core language install fi
Success: Language installed.

# Updates (or installs) all languages for core, plugins and themes.
# When I runned this I had jetpack installed but without any translations.

$ wp core language update
Updating 'Finnish' translation for Jetpack by WordPress.com 3.9.2...
Downloading translation from https://downloads.wordpress.org/translation/plugin/jetpack/3.9.2/fi.zip...
Translation updated successfully.
Success: Updated 1/1 translations.

It will contain every plugin translation package always. https://wp-languages.github.io can’t contain all translation data in it’s current form, but if you only need core translations it is a really handy tool.


#36

@Koodimonni, thank you for your work! :slight_smile:

If anyone wants to integrate the WP-CLI way into their deployments, I posted my workflow here:


#37

Thanks @Koodimonni for your great work. I noticed some strange behaviour though:

When switching to any other language but english (tried de and fr), the visual post editor will not show since the language files for tinymce are missing.

Am I missing something or should they be added to the packages?

Wordpress expects them to be in web/wp/wp-includes/js/tinymce/langs. However, with "koodimonni-language/core-de_de" for example, I am not getting any other languages installed there except the default wp-langs-en.js.

Here’s a screenshot on how to reproduce this:


#38

I haven’t installed anything extra besides the language packages from my composer packages.

Here’s a screenshot from finnish koodimonni-language/core-fi package in chrome:

So because it works for me I can’t really easily debug this for you.

If you really want my help please start an issue in Github instead rather than posting over here.


#39

The example behind your link doesn’t work .
The dropin-paths don’t match the ones in your post.


#40

I can’t get it to work at all. What would a working composer.json look like and where would the languages be installed?