hirasso / acf-multilingual
An experimental plugin for building multilingual websites using WordPress and Advanced Custom Fields 🌀
Fund package maintenance!
hirasso
Installs: 5
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 1
Type:wordpress-plugin
pkg:composer/hirasso/acf-multilingual
Requires (Dev)
- laravel/pint: ^1.25
- pestphp/pest: ^1.23
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.1
- roots/wordpress: ^6.8
- symfony/var-dumper: ^7.3
- wp-phpunit/wp-phpunit: ^6.8
- wpackagist-plugin/advanced-custom-fields: ^6.6
- wpackagist-plugin/classic-editor: ^1.6
- wpackagist-theme/twentytwentyfive: ^1.3
- yoast/wp-test-utils: ^1.2
README
An experimental plugin for building multilingual websites using WordPress and Advanced Custom Fields 🌀
Limitations
Does NOT integrate with plugins that add additional fields to the WordPress Admin, like e.g. Yoast SEO. Works best with fully customized pure WordPress/ACF setups.
Why did I make this public?
I made this public in the hopes to make it more sustainable and fail-proof. You will probably not want to use this plugin in big corporate projects, just yet (or ever). Use it for a personal website or the likes and report bugs and problems.
Usage
Installation
Via Composer (recommended):
- Install the plugin:
composer require hirasso/acf-multilingual
- Activate the plugin manually or using WP CLI:
wp plugin activate acf-multilingual
Manually:
- Download and extract the plugin from the latest release
- Copy the
acf-multilingualfolder into yourwp-content/pluginsfolder - Activate the plugin via the plugins admin page – Done!
- Handle updates via afragen/git-updater
Setup
Add as many languages as you like. The languages will be injected into the URL, like this:
https://yoursite.tld/your-post/ < default language
https://yoursite.tld/de/dein-eintrag/ < german translation
https://yoursite.tld/es/tu-entrada/ < spanish translation
Put a file acfml.config.json in your theme root, for example with these contents:
{
"languages": {
"en": {
"locale": "en_US",
"name": "English"
},
"de": {
"locale": "de_DE",
"name": "Deutsch"
}
},
"post_types": {
"page": true,
"project": {
"de": {
"rewrite_slug": "projekt",
"archive_slug": "projekte"
}
}
},
"taxonomies": {
"filter": true
}
}
This config will make:
- English the default language
- Deutsch the second language
- The post type "page" translatable
- The post type "project" translatable, with custom rewrite slugs for german
- The custom taxonomy "filter" translatable
API
To get an idea about what the plugin can do, it's probably quickest to have a look at the API.
Make ACF fields multilingual
Set ACF fields to be multilingual, so that they can be translated for every language. like e.g. Text, Textarea, WYSIWYG, ... (for the full list see $multilingual_field_types in the class FieldsController):
Now the field can be translated!
If you use vinkla/extended-acf, you can make fields multilingual like so:
\Extended\ACF\Fields\Text::make('Text') ->withSettings(['acfml_multilingual' => true]);
If a field is not marked multilingual, it will display the same value in both languages.