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

Expose all translations strings #14

Open
esamattis opened this issue Jan 28, 2020 · 0 comments
Open

Expose all translations strings #14

esamattis opened this issue Jan 28, 2020 · 0 comments

Comments

@esamattis
Copy link
Member

This could work

function get_polylang_strings($slug = 'en') {
	$values 		= [];
    $term           = get_term_by( 'slug' , $slug , 'language' ); 
    $posts          = get_posts(array( 'name' => 'polylang_mo_'.$term->term_id , 'post_type' => 'polylang_mo' , 'post_status' => 'private' , 'posts_per_page' =>1 ));
    $post_id        = $posts[0]->ID;
    $translations   = get_post_meta( $post_id , '_pll_strings_translations' , true );
    if(!$translations) {
    	return;
    }
    foreach($translations as $translation) {
    	$values[$translation[0]] = $translation[1];
    }
    return $values;
}

See

https://wp-graphql.slack.com/archives/CH3E1FZHB/p1580230496018300

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