@sanity/language-filter 2.24.1 → 2.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +30 -6
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,12 +1,36 @@
1
- ### @sanity/language-filter
1
+ # Field-level translation filter Plugin for Sanity.io
2
2
 
3
3
  A Sanity plugin that supports filtering localized fields by language
4
4
 
5
- ## Usage
5
+ ![Language Filter UI](https://user-images.githubusercontent.com/9684022/150549913-68f1b7c7-3305-48b4-b72b-41b95e82450c.gif)
6
6
 
7
- ### Install plugin
7
+ ## What this plugin solves
8
8
 
9
- > sanity install @sanity/language-filter
9
+ There are two popular methods of internationalization in Sanity Studio:
10
+
11
+ - **Field-level translation**
12
+ - A single document with many languages of content
13
+ - Achieved by mapping over languages on each field, to create an object
14
+ - Best for documents that have a mix of language-specific and common fields
15
+ - Not recommended for Portable Text
16
+ - **Document-level translation**
17
+ - A unique document version for every language
18
+ - Joined together by references and/or a predictable `_id`
19
+ - Best for documents that have unique, language-specific fields and no common content across languages
20
+ - Best for translating content using Portable Text
21
+
22
+ This plugin adds features to the Studio to improve handling **field-level translations**.
23
+
24
+ - A "Filter Languages" button to show/hide fields in an object of language-specific fields
25
+ - Configuration to set "default" languages which are always visible
26
+
27
+ For **document-level translations** you should use the [@sanity/document-internationalization plugin](https://www.npmjs.com/package/@sanity/document-internationalization).
28
+
29
+ ## Installation
30
+
31
+ ```
32
+ sanity install @sanity/language-filter
33
+ ```
10
34
 
11
35
  Installing with `sanity install` updates your `sanity.json` to include this plugin. If installing with npm or yarn, ensure your `plugins` array includes `@sanity/language-filter`.
12
36
 
@@ -33,7 +57,7 @@ export default {
33
57
  {id: 'en', title: 'English'},
34
58
  {id: 'es', title: 'Spanish'},
35
59
  {id: 'arb', title: 'Arabic'},
36
- {id: 'pt', title: 'Portuguese'}
60
+ {id: 'pt', title: 'Portuguese'},
37
61
  //...
38
62
  ],
39
63
  // Select Norwegian (Bokmål) by default
@@ -41,7 +65,7 @@ export default {
41
65
  // Only show language filter for document type `page` (schemaType.name)
42
66
  documentTypes: ['page'],
43
67
  filterField: (enclosingType, field, selectedLanguageIds) =>
44
- !enclosingType.name.startsWith('locale') || selectedLanguageIds.includes(field.name)
68
+ !enclosingType.name.startsWith('locale') || selectedLanguageIds.includes(field.name),
45
69
  }
46
70
  ```
47
71
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/language-filter",
3
- "version": "2.24.1",
3
+ "version": "2.25.1",
4
4
  "description": "A Sanity plugin that supports filtering localized fields by language",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -39,5 +39,5 @@
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
- "gitHead": "3cacc40d47916bfe60c8491362c9abd36d45dae0"
42
+ "gitHead": "1d592c30e846288e282d4d1490fc349780f62131"
43
43
  }