The feature-packed Avada 6.1 release introduces many new features, like the dynamic-content system, gradients, filters, styling options, and more. One special feature is the new Languages-Updating API we have built for Avada. With our global community in mind, this new feature allows for more accessible translations and updates.
Why We Did It
Avada is currently being used by 585,962 beginners, professionals, marketers, and developers for a wide array of business types, across the world. Language management is a major part of tens of thousands of Avada websites. Updating your language files is an integral part of site maintenance. Since Avada language files are publicly curated by the wider community, each time a language file is updated, this update would only be available with each theme update, or, manually via our public Git repository.
We believe that everyone should be able to use WordPress and take advantage of our theme to build incredible websites. No matter where you live or what language you speak, you shouldn’t have to translate your theme and plugins manually. For years this was possible for themes and plugins hosted on the WordPress repository. Premium products, however, were always lacking in that area because there was no way for them to provide their translations efficiently. We felt we needed to change that and make this process seamless and automatic.
What It Does
When you install Avada on your site or switch to a new language, we check your site’s language locale code. If we have an updated language file available for your selection, a notification is sent to your WordPress Dashboard, indicating that a new update is available. With the click of a button, you can then automatically update translations for our products. Easy and hassle-free!
Our translations are publicly available on GitHub and are maintained by our amazing community. Anyone can contribute to these translations, something that we encourage, and as soon as there is an updated file for your language, a notification is sent to your WordPress Dashboard – just like it happens for plugins and themes hosted on wordpress.org.
How It’s Done – The Technical Part
To provide a viable solution, we started by examining the way WordPress core updates translations for plugins & themes hosted in their repository. When your site checks if there are updated translations, it queries the WordPress API and receives a JSON object as a response. This JSON contains information about languages, the last update timestamp, the WordPress version, and finally, a URL for the zip file containing the translation files. We copy the JSON, remove the package reference, version, the update timestamp, and replace it with our strings so that they correspond to what we need.
In our GitHub repository our user base contributes to the .po files. Using a grunt task, we run a compiler that converts these human-readable .po files to binary .mo file, the same as what WordPress uses internally. Likewise, the same formats used by WPML, as well as programs like Poedit.
Now that we have all our translation files, we bundle each language separately and create the zip files that we’ll later be using in our custom API. Since these compressed zip files live in our public repository, we can quickly generate the URLs for each one of them, and we also have access to the last-modified timestamp and version. We then add this new information to the WordPress-API JSON we modified earlier, and end up with our custom JSON containing all the information required. This process is repeated for all our products, including Avada, Fusion Builder, and Fusion Core.
Finally, we hook in the update_themes and update_plugins site-transients so that when WordPress searches for translations for one of our products, we modify the response and return our custom API instead of an empty response from WordPress.
We hope you enjoy this new feature! We strive to make it easier for anyone to use our products, and we feel that internationalization is an essential facet of making our products more accessible and simpler to use for everyone. As always, if you have any further questions, you are welcome to submit a support ticket, and we will be glad to help you.