Did you know that The Events Calendar allows you to create custom language files for the plugin in addition to the ones that come packaged with the plugin? Well, it does as of Version 4.2, and we want to show you how that works.
Why Use Custom Language Files?
It’s a fair question. The plugin already includes language files, so why not simply edit those and be on your merry way?
The reason is that we release regular updates to our plugins, and with each update, existing files on your server get updated with the new files.
This means that each update essentially erases the hard work you may have put into editing the language files! We’re not trying to make your life difficult—at this time, this is just the only way we can offer plugin updates to you.
This is where custom language files come to the rescue! They allow you to duplicate any of the plugin’s language files, store them in a safe place on your WordPress installation, and prevent them—and any edits you’ve made to them—from being overridden when we release updates.
That’s the main idea of custom language files: WordPress will first check for your custom language files before looking for the ones we package with our releases, giving you control of the language translations while avoiding losing those customizations.
Let’s dive into the steps for creating your own custom language files.
Step 1: Make a Copy of the Language File You Need
The first step is to locate the language file you wish to customize and make a copy of it. For your reference, all of our products include a directory for languages:
- The Events Calendar: /wp-content/plugins/the-events-calendar/lang/
- Events Calendar PRO: /wp-content/plugins/events-calendar-pro/lang/
- Event Tickets: /wp-content/plugins/events-tickets/lang/
- Event Tickets Plus: /wp-content/plugins/events-tickets-plus/lang/
- Community Events: /wp-content/plugins/the-events-calendar-community-events/lang/
- Community Tickets: /wp-content/plugins/the-events-calendar-community-events-tickets/lang/
- Filter Bar: /wp-content/plugins/the-events-calendar-filterbar/lang/
- iCal Importer: /wp-content/plugins/the-events-calendar-importer-ical/lang/
- Facebook Events: /wp-content/plugins/the-events-calendar-facebook-importer/lang/
- Eventbrite Tickets: /wp-content/plugins/the-events-calendar-eventbrite-tickets/lang/
So, for example, if you want to customize the Spanish translation file for The Events Calendar, you would copy the two following files:
Step 2: Find the WordPress Languages Folder
The second step is to located the languages file for your WordPress installation. Many WordPress installations include this by default at this location: /wp-content/languages
Inside of that folder is another folder called /plugins. That is where we’re going to hang out.
If, for some reason, your WordPress installation does not include /wp-content/languages/plugins, please create these folders.
Step 3: Place the Copied Language Files in the Languages Folder
Once you’ve located (or created) the wp-content/languages folder and /plugins subfolder inside it, take the language files you duplicated in Step 1 and place them in the wp-content/languages/plugins folder.
Step 4: Edit Away!
Now that the language files are in your WordPress installation, you can modify them to suit your needs. In this case, edit the strings in the language files and save your work.
Are you new to editing language files? Many of us on the Modern Tribe team use POEdit, a free software application that allows you to edit .po files and convert them into the .mo language file that is read by WordPress.