Skip to content
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

Translatable content and fixtures #5

Open
HansCz opened this issue Jun 29, 2020 · 1 comment
Open

Translatable content and fixtures #5

HansCz opened this issue Jun 29, 2020 · 1 comment

Comments

@HansCz
Copy link

HansCz commented Jun 29, 2020

Have you given any thought to how you might handle translations of fixtures?
For example how to handle fixtures on sites using WPML?

Given the following:

#
# TERMS
#
Hellonico\Fixtures\Entity\Term:
  focus_areas{1..4}: # custom taxonomy
    name (unique): <words(3, true)> # '(unique)' is required
    description: <sentences(1, true)>
    taxonomy: focus_area

#
# POSTS
#
Hellonico\Fixtures\Entity\Post:
  default (template):
    post_title: <words(2, true)>
    post_date: <dateTimeThisDecade()>
    post_content: <paragraphs(5, true)>
    post_excerpt: <paragraphs(1, true)>

  projects_with_focus_area_1_{1..5}:
      __construct: [<postId(post_type=projects&post_status=publish)>]
      tax_input:
        focus_area: '@focus_areas1->term_id'

I can relate the generated terms just fine to the existing posts, but the <postID()> function does not stick to fetching posts in the default language. It randomly fetches posts regardless of their language. Would you be interested in a fix for this?

I imagine checking if WPML is running, and if so, limit the post query to only fetch posts in the default language.

@HansCz
Copy link
Author

HansCz commented Jun 29, 2020

An update for anybody who might run into this issue:
The specific problem mentioned above can be alleviated by adding suppress_filters=0 to the postId() arguments.

In the context of the above example, I changed:

 __construct: [<postId(post_type=projects&post_status=publish)>]

to

 __construct: [<postId(post_type=projects&post_status=publish&suppress_filters=0)>]

I'm still convinced there is work to be done re. translatable content and fixtures, though.
Is it something you would welcome?

I'll let you know when I have formulated some more specific ideas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant