-
Notifications
You must be signed in to change notification settings - Fork 435
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(i18n): allow locale plugins to translate "All fields" field group (…
…#7117) * fix(i18n): allow translating field group titles * chore(test-studio): add field group translation debug * chore(e2e): simplify e2e studio config * test(i18n): add test for field group translations
- Loading branch information
Showing
14 changed files
with
143 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {defineLocaleResourceBundle} from 'sanity' | ||
import {testStudioLocaleNamespace} from 'sanity-test-studio/locales' | ||
|
||
export const e2eI18nBundles = [ | ||
defineLocaleResourceBundle({ | ||
locale: 'en-US', | ||
namespace: testStudioLocaleNamespace, | ||
resources: { | ||
'field-groups.group-1': '🇺🇸 Group 1', | ||
}, | ||
}), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import {defineType} from 'sanity' | ||
|
||
import {testStudioLocaleNamespace} from '../../locales' | ||
|
||
export default defineType({ | ||
name: 'fieldGroupsWithI18n', | ||
title: 'With i18n', | ||
type: 'document', | ||
groups: [ | ||
{ | ||
name: 'i18n-group1', | ||
title: 'I18N-MISSING (1)', | ||
i18n: {title: {key: 'field-groups.group-1', ns: testStudioLocaleNamespace}}, | ||
}, | ||
{ | ||
name: 'i18n-group2', | ||
title: 'I18N-MISSING (2)', | ||
i18n: {title: {key: 'intentionally-missing-key', ns: testStudioLocaleNamespace}}, | ||
}, | ||
{ | ||
name: 'non-i18n-group3', | ||
title: '🌐 Non-i18n group', | ||
}, | ||
], | ||
fields: [ | ||
{name: 'field1', type: 'string', group: 'i18n-group1'}, | ||
{name: 'field2', type: 'string', group: 'i18n-group2'}, | ||
{name: 'field3', type: 'string', group: 'i18n-group1'}, | ||
{name: 'field4', type: 'string', group: ['i18n-group1', 'i18n-group2']}, | ||
{name: 'field5', type: 'string', group: 'non-i18n-group3'}, | ||
], | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import {expect} from '@playwright/test' | ||
import {test} from '@sanity/test' | ||
|
||
test('fields groups can use/not use i18n titles', async ({page, createDraftDocument}) => { | ||
await createDraftDocument('/test/content/input-debug;field-groups;fieldGroupsWithI18n') | ||
|
||
await expect(await page.getByTestId(`group-tab-i18n-group1`)).toBeVisible() | ||
|
||
// Should be translated (see e2e studio `i18n/bundles`) | ||
await expect(page.getByTestId('group-tab-i18n-group1')).toHaveText('🇺🇸 Group 1') | ||
// Should intentionally not be translated, eg show the missing key | ||
await expect(page.getByTestId('group-tab-i18n-group2')).toHaveText('intentionally-missing-key') | ||
// Should show defined title if no `i18n` key is defined | ||
await expect(page.getByTestId('group-tab-non-i18n-group3')).toHaveText('🌐 Non-i18n group') | ||
}) |