Query by language

When querying the API, you can now query by language. Simply add the query option “lang” set to the language code you are querying (example, “en-us” for American English).

If you don't specify a "lang" you will query the documents in your master language.

Here’s an example of how to query for all the documents of the type “blog-post” in French.

Copy
      api.query(
    Prismic.Predicates.at('document.type', 'blog-post'),
    { lang : 'fr-fr' }
).then(function(blogPosts) {
    // blogPosts is the response object, blogPosts.results holds the documents
});
    
Copy
      $blogPosts = $api->query(
    Predicates::at('document.type', 'blog-post'),
    [ 'lang' => 'fr-fr' ]
);
// $blogPosts contains the response object, $blogPosts->getResults() holds the documents
    
Copy
      blog_posts = api.query(
    Prismic::Predicates.at("document.type", "blog-post"),
    { "lang" => "fr-fr" }
)
# blog_posts contains the response object, blog_posts.results holds the documents
    

If you want to query all the document of the same type in all languages you can just add a * as your lang option.

Copy
      api.query(
    Prismic.Predicates.at('document.type', 'blog-post'),
    { lang : '*' }
).then(function(blogPosts) {
    // blogPosts is the response object, blogPosts.results holds the documents
});
    
Copy
      $blogPosts = $api->query(
    Predicates::at('document.type', 'blog-post'),
    [ 'lang' => '*' ]
);
// $blogPosts contains the response object, $blogPosts->getResults() holds the documents
    
Copy
      blog_posts = api.query(
    Prismic::Predicates.at("document.type", "blog-post"),
    { "lang" => "*" }
)
# blog_posts contains the response object, blog_posts.results holds the documents