Accessing currentLocale in Studio/Document when dropdown lang is changed

8 replies
Last updated: Apr 11, 2023
Hi everyone, I have a case where I need to access the
from document-internationalization plugin inside the `Studio`/`Document`, is there away to get the local when the
lang is change in document?
Apr 9, 2023, 11:54 AM
I do use
custom component
for my link (react-select) for the link field. Here is my query where I want to get the

  React.useEffect(() => {
    const referenceTypes = (referenceField?.type as ReferenceSchemaType)?.to?.map((t) =>

    // query for all pages that are not drafts
    const query = `*[_type in $referenceTypes && uri != null && !(_id in path("drafts.**")) ] | order(uri.current asc)`

      .fetch(query, { referenceTypes, baseLocale: 'en-us' }) // here its static from , I want it more dynamic.
      .then((results: PageQueryResult[]) => {
        const ids = => ({
          label: Array.isArray(result.title) ? : result.title,
          value: result._id,
          subLabel: result?._type,
  }, [referenceField?.type])
Apr 9, 2023, 11:56 AM
You can get the document values using the useFormValue hook :)
Apr 9, 2023, 2:51 PM
Seems this is only available in v3, I want it in v2 🙂
user A
Apr 10, 2023, 11:28 AM
Well avoiding upgrading to v3 only causes you more pain in the future imo. Anyways you can use the
Apr 10, 2023, 11:35 AM
v2 has end of life in december btw
Apr 10, 2023, 11:36 AM
Thanks a lot for the advice 🙂 I did refactor and moved to v3 ❤️
Apr 11, 2023, 7:45 AM
but got two questions:• I want inside studio when I do a query, I want to get the translated value of a field (using Language FIlter plugin), I found this but how can I get access to the
langs url-param state
?• last question, I have a
document with
enabled, I want to access
inside the preview, before I upgrade it was working in v2 but now seems
seems undefined_
Apr 11, 2023, 7:49 AM

Sanity– build remarkable experiences at scale

The Sanity Composable Content Cloud is the headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?