-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom post type translatable labels not working #26
Comments
Hey thanks for reporting the issue. We'll look into whether we can apply your fix to the Lumberjack core. In the meantime, you can replace the core In You should be able to add your own service provider inside of your theme. Here are some docs on creating a service provider if that's new to you: Once you have your own service provider, replace our one with yours in /**
* List of providers to initialise during app boot
*/
'providers' => [
Rareloop\Lumberjack\Providers\RouterServiceProvider::class,
Rareloop\Lumberjack\Providers\WordPressControllersServiceProvider::class,
Rareloop\Lumberjack\Providers\TimberServiceProvider::class,
Rareloop\Lumberjack\Providers\ImageSizesServiceProvider::class,
// Rareloop\Lumberjack\Providers\CustomPostTypesServiceProvider::class,
Rareloop\Lumberjack\Providers\MenusServiceProvider::class,
Rareloop\Lumberjack\Providers\LogServiceProvider::class,
Rareloop\Lumberjack\Providers\ThemeSupportServiceProvider::class,
Rareloop\Lumberjack\Providers\QueryBuilderServiceProvider::class,
Rareloop\Lumberjack\Providers\SessionServiceProvider::class,
Rareloop\Lumberjack\Providers\EncryptionServiceProvider::class,
// Application Providers
App\Providers\AppServiceProvider::class,
App\Providers\CustomPostTypesServiceProvider,
], Hope this helps! |
@adamtomat thanks for the temp fix! Great work. I've manage to get the CPT labels translated with my own Service Provider |
Small update if you are looking for this. I think this is a beter solutions for the service provider: <?php
namespace App\Providers;
use Rareloop\Lumberjack\Config;
use Rareloop\Lumberjack\Providers\ServiceProvider;
class CustomBlocksServiceProvider extends ServiceProvider
{
public function boot(Config $config)
{
$blocks = $config->get('blocks.register');
foreach ($blocks as $block) {
add_action('init', [$block, 'register']);
}
}
} |
Thanks for creating lumberjack. This is the first time we use it and I've run into a problem with translations. We register custom post type as show in the documentation:
The custom post type is registert and we can use it in the admin and have an archive and detail view.
In the
getPostTypeConfig
we try to translate the labels off the custom post type:In poedit we can create a
.po
file in the language folder. In thefunctions.php
we load the text domain like so:If checked the loaded paths and the textdomain path is correct. But still the labels aren't translated. After some testing with displaying translated text in several places and in different actions. I've discovered that if I put the translation in a init action it get translated. The
CustomPostTypesServiceProvider
register the custom post type not in action. If I wrap the post type register in aninit
action, the labels get translation. Here is my quick and dirty fix for theCustomPostTypesServiceProvider
:Is there any possible way of register the post type in the proper action hook? So that the translation is working.
What versions of software are you using?
Operating System: MacOS 11.5
PHP Version: 7.4.1
Lumberjack Version: 5.0
The text was updated successfully, but these errors were encountered: