Closed dweipert-3138720606 closed 2 years ago
Thanks @DRogueRonin
This was similar to an approach PostTypes used in earlier version but was dropped based on the WordPress Documentation. It advises not to pass a variable names or constants for the text domain parameter in gettext functions. I believe this is because it can interfere in automatic parsing of your plugin/theme’s files for translation.
When using PostTypes it's recommended to follow the WordPress guidance and use a directly passed string literal. This is noted in the full documentation.
I am aware there are some issues to fix within the code to make translations better and looking to resolve those soon.
However, I think the example you've provided is a great to show how to extend PostTypes and implement that translation solution if it works for your project.
Many thanks!
In light of https://github.com/jjgrainger/PostTypes/issues/66 and having a similar issue, I was thinking how to add translation support to the library. So I've extended the PostType in one of my projects to add translation support with loading a textdomain.
https://developer.wordpress.org/reference/functions/load_textdomain/
PostType.php
index.php
What do you think?