-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
Translating post type label and slug #46
Comments
I have the same problem. In sage 10.3.1 (october 22) it worked flawlessly, but since 10.5.1 localization stopped working for me, maybe new acorn is the issue? |
This is very unlikely to be a regression/issue in Acorn, but this isn't something I've ever tested in Poet. In theory, it should work, though. Does it work if calling |
Yes, it does work. It's definitely related to the boot process in Acorn, as it is getting all the poet config values before the localization is available. I used a workaround in the same file by using a switch with get_option('WPLANG') and writing all the translations directly in the file (or ternary if there aren't many). Fortunately it's not a big deal to do it this way while a better solution is found. |
https://github.com/Log1x/poet/blob/master/src/Poet.php#L63 can you try messing with the |
yes, there is where I found more or less where the problem was located. I did move the config inside the init but didn't work. I think (and it is a guess as I don't understand acorn) the config is loaded by acorn as soon as acorn boots and thus the init hook doesn't apply. |
I'll look into this more when I get a chance. |
@Log1x I am facing the same. Can't translate the labels for CPTs and Taxonomies. Thanks! |
Not 100% sure what this would be. The best guess would be to play with the hook. I'm not sure why the translations wouldn't be loaded by time Could also be them not getting resolved from configs (try hardcoding the labels as a test maybe?) – I don't have a good test environment to dig deeper myself at the moment. :( |
@Log1x thanks a lot for getting back to me so fast. Line 63 in 3bc3a1d
Tried to move the config getter into the Hardcoding the labels here works! But at this point the Wondering if |
@Log1x just wonderung if you agree, that the translations should get processed by acorn via |
It's not a bad idea as it currently doesn't work, but I don't know how annoying it's going to be to handle it within Acorn. In an ideal world, we wouldn't have to extend/mess with illuminate/config directly, but I'm not seeing much hope in the config bootstrapping without extending Repository. |
I think this will be very annoying as the config is also cached. So if it worked as expected, the config value of the current language would be cached as a string anyway.
This would also support simple strings. So it is backwards compatible. |
If you think that would work I am all for it. As far as I know, you have to hardcode anything related to I don't have much first-hand experience with multi-lang on WordPress. |
OMG, wasn't aware of that. However I will test it and get back to you. Thanks |
@Log1x it works as expected as long as the strings are registered:
However you are right that gettext needs to find the strings somewhere using
While this is not ideal, at least it allows us to translate the strings. Still I will open an issue for Acorn but wonder if you would be interested in a PR for this workaround. Edit: Something like this could do it, too:
|
@ouun Ill reply here instead of the acorn issue queue. I haven’t checked if that part of the acorn bootstrap has changed in v3 but it did fix it in v2. What my gist did was re-evaluate the config files on each request, without it they’re only evaluated once and precompiled. Edit: skimming the code it look’s like it has changed and you now need to swap out the kernel. |
Tried another approach today: Regular usage of
Is someone aware of a possibility to get the value from the config that still contains whatever is set there? E.g.:
How would I get |
Anyone figure this out yet? Ran into this issue after upgrading couple of sites from Acorn 2 to 3. Edit: actually not entirely sure anymore if this was the same issue. In my case it was enough to make sure that theme textdomain was called before Poet config, so adding a _i18n.php config file (so that it gets loaded early) and moving load_theme_textdomain() there seems to have done the trick. |
This was my solution, but after updating Wordpress to 6.7, it triggers the Notice: |
///**
// * Register the theme text domain.
// */
//add_action('after_setup_theme', function () {
// load_theme_textdomain('sage', get_template_directory() . '/resources/lang');
//});
Edit: This seem to be a wide issue with WordPress 6.7. I found the following snippet https://forum.bricksbuilder.io/t/solved-wrong-language-after-wordpress-6-7/27861/3 which I adjusted for sage and it works. Create as a plugin with <?php
/**
* Register the theme text domain.
*/
add_action(
'init',
function() {
global $l10n, $wp_textdomain_registry;
$domain = 'sage';
$lang_dir = get_template_directory() . '/resources/lang';
$locale = get_locale();
$wp_textdomain_registry->set($domain, $locale, $lang_dir);
if (isset($l10n[$domain])) {
unset($l10n[$domain]);
}
load_theme_textdomain($domain, $lang_dir);
},
); |
For me it does the same as adding
The Notice disappears, but everything created with poet doesn't get translations |
@SergiArias did you run WordPress 6.7.1 has fixes to translations maybe it helps |
Hi,
I have this code in my poet.php file:
'calendar' => [ 'enter_title_here' => 'Enter calendar month or year', 'menu_icon' => 'dashicons-calendar-alt', 'supports' => ['title', 'revisions', 'page-attributes'], 'show_in_rest' => true, 'hierarchical' => true, 'has_archive' => false, 'labels' => [ 'singular' => __('Calendar', 'sage'), 'plural' => __('Calendars', 'sage'), ], ],
I've generated a pot file, and translated it, but it doesn't seem to work: slug and labels remain in english even on my french website
The text was updated successfully, but these errors were encountered: