i18n-array-groq-query-migration

द्वारा sanity-io

उन पुराने GROQ पैटर्न का पता लगाएं और अपडेट करें जहां sanity-plugin-internationalized-array के लिए _key से भाषा पढ़ी जाती है, जब उपयोगकर्ता v4 से v5 माइग्रेशन का उल्लेख करते हैं, या…

npx skills add https://github.com/sanity-io/plugins --skill i18n-array-groq-query-migration

Internationalized Array GROQ Migration

Goal

Help users find GROQ queries that still read locale from _key and rewrite them safely for v5.

When To Use

Use this skill when a user asks to:

  • migrate sanity-plugin-internationalized-array from v4 to v5
  • migrate @sanity/document-internationalization from v5 to v6 alongside sanity-plugin-internationalized-array language field changes
  • find queries that still use _key for language lookup
  • update GROQ filters like _key == "en" or _key == $language

Detection Workflow

Detection commands below use grep. If your environment differs, use your editor's global search with equivalent patterns.

  1. Search for direct language comparisons on _key:
grep -REn --exclude-dir=node_modules "_key[[:space:]]*==[[:space:]]*(\"[^\"]+\"|'[^']+'|\\$[A-Za-z_][A-Za-z0-9_]*)" .
  1. Search for any localized-array filters that mention _key:
grep -REn --exclude-dir=node_modules "\[[^]]*_key[^]]*\]" .
  1. Prioritize matches that look like localized-value reads, for example:
  • field[_key == ...][0].value
  • select(...) branches that compare _key to a language value
  1. Check for uses of groq and verify if they use _key as the language, if it is using it, update them.

  2. Explicitly check for template-interpolated language expressions and keep the same operand, for example:

    • _key == "${language}"
    • _key == "${locale}"
  3. Review each match to avoid false positives where _key is used for unrelated array item identity.

Rewrite Rules

Use the same language operand from the original query. The language operand can be a string literal (for example "en"), a variable (for example $language), or a template-interpolated expression (for example "${language}").

  • Before data migration is executed (backwards compatible):
    • _key == <languageExpr> -> language == <languageExpr> || _key == <languageExpr>
  • After migration is complete:
    • language == <languageExpr> || _key == <languageExpr> -> language == <languageExpr>

Examples

Legacy:

*[_type == "person"]{
  "greeting": greeting[_key == $language][0].value
}

Backwards compatible:

*[_type == "person"]{
  "greeting": greeting[language == $language || _key == $language][0].value
}

Post-migration final form:

*[_type == "person"]{
  "greeting": greeting[language == $language][0].value
}

Response Template

When reporting findings to a user:

  1. List each query location that still uses _key as language source.
  2. Show the exact replacement using the same language expression.
  3. Label each replacement as:
    • backwards-compatible (pre-migration), or
    • final (post-migration complete).
  4. Label each match category as runtime, docs/example, or ambiguous.
  5. Call out any ambiguous _key usage that needs manual review.

sanity-io की और Skills

tdd
sanity-io
लाल-हरा-रीफैक्टर लूप के साथ परीक्षण-संचालित विकास। उपयोग तब करें जब उपयोगकर्ता TDD का उपयोग करके सुविधाएँ बनाना या बग ठीक करना चाहता है, "लाल-हरा-रीफैक्टर" का उल्लेख करता है, चाहता है…
performance-optimization
sanity-io
एप्लिकेशन के प्रदर्शन को अनुकूलित करता है। इसका उपयोग तब करें जब प्रदर्शन आवश्यकताएं हों, जब आपको प्रदर्शन में गिरावट का संदेह हो, या जब कोर वेब वाइटल्स या लोड समय...
content-experimentation-best-practices
sanity-io
सामग्री प्रयोगों को डिज़ाइन करने, निष्पादित करने और विश्लेषण करने के लिए संरचित मार्गदर्शन, जो रूपांतरण और जुड़ाव को बेहतर बनाने में सहायक हो। इसमें परिकल्पना ढाँचे, मीट्रिक चयन, नमूना आकार गणना, और A/B तथा बहुभिन्नरूपी प्रयोगों में सांख्यिकीय महत्व परीक्षण शामिल है। p-मान, विश्वास अंतराल, शक्ति विश्लेषण, और परिणामों की व्याख्या के लिए बायेसियन विधियों पर विस्तृत संसाधन प्रदान करता है। फ़ील्ड स्तर पर वे
content-modeling-best-practices
sanity-io
संरचित सामग्री मॉडलिंग मार्गदर्शन: स्कीमा डिज़ाइन, पुन: प्रयोज्यता और बहु-चैनल वितरण के लिए। मुख्य सिद्धांतों को शामिल करता है: सामग्री को पृष्ठों के बजाय डेटा के रूप में मानना, एकल स्रोत सत्य बनाए रखना, भविष्य के चैनलों के लिए डिज़ाइन करना और संपादक वर्कफ़्लो को अनुकूलित करना। संदर्भ बनाम एम्बेडेड ऑब्जेक्ट, चिंताओं का पृथक्करण और सामग्री पुन: उपयोग पैटर्न के लिए निर्ण
portable-text-conversion
sanity-io
HTML और Markdown सामग्री को Sanity के लिए Portable Text ब्लॉक में बदलें। लीगेसी CMS से सामग्री माइग्रेट करते समय, Sanity में HTML या Markdown आयात करते समय उपयोग करें,…
portable-text-serialization
sanity-io
पोर्टेबल टेक्स्ट को React, Svelte, Vue, Astro, HTML, Markdown और सादे टेक्स्ट में रेंडर और सीरियलाइज़ करें। किसी भी फ्रंटएंड में पोर्टेबल टेक्स्ट रेंडरिंग लागू करते समय उपयोग करें…
sanity-best-practices
sanity-io
Sanity CMS विकास के लिए विभिन्न फ्रेमवर्क और विषयों पर व्यापक सर्वोत्तम अभ्यास और एकीकरण गाइड। Next.js, Nuxt, Astro, Remix, SvelteKit और Angular सहित 10+ फ्रेमवर्क एकीकरण को कवर करता है, जिसमें फ्रेमवर्क-विशिष्ट पैटर्न और सेटअप मार्गदर्शन शामिल है। स्कीमा डिज़ाइन, GROQ क्वेरी ऑप्टिमाइज़ेशन, विज़ुअल एडिटिंग, पोर्टेबल टेक्स्ट, इमेज, TypeGen, लोकलाइज़ेशन और कंटेंट माइग्रेशन के लिए विषय ग
sanity-migration
sanity-io
अन्य CMS और सामग्री प्रणालियों से Sanity में माइग्रेशन की योजना बनाता है, उन्हें कार्यान्वित करता है और उनकी समीक्षा करता है। AEM, Adobe Experience Manager, Contentful, Strapi, Webflow, WordPress, Payload, Drupal, Markdown/MDX/frontmatter फ़ाइलों, WXR/XML निर्यात, CMS API, डेटाबेस डंप, स्थिर HTML से Sanity में माइग्रेट या रीप्लेटफ़ॉर्म करते समय, या निष्कर्षण, रूपांतरण, Portable Text रूपांतरण, एसेट माइग्रेशन, रीडायरेक्ट, सत्यापन और कटओवर वर्कफ़्लो डिज़
data-analysisdatabasedevelopment