Query by Language

If you are taking advantage of the multi-language feature in your Prismic content repository, then you'll need to be able to query documents by a specific language. This page will show you how retrieve documents by language.

Before reading

This page assumes that you're using the Vue.js starter project or that you have setup your project as explained on the Integrating with existing project page.

Query documents of a certain language

To specify a particular language you want in a query, simply add the lang option set to the language code you are querying (example: "en-us" for American English).

If you don't specify a "lang" the system will by default 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 Traditional French ("fr-fr").

Copy
this.$prismic.client.query(
  this.$prismic.Predicates.at('document.type', 'blog_post'),
  { lang : 'fr-fr' }
).then((response) => {
  // response is the response object, response.results holds the documents
});

Query documents in all languages

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

Here is an example that queries all the documents of the type "blog_post" in all the available languages.

Copy
this.$prismic.client.query(
  this.$prismic.Predicates.at('document.type', 'blog_post'),
  { lang : '*' }
).then((response) => {
  // response is the response object, response.results holds the documents
});

Vue Router: Reacting to params changes

If your component is retrieving content from the Prismic API based on one of the route params, make sure to take a look at our Reacting to params changes page.