-
Notifications
You must be signed in to change notification settings - Fork 54
Add full sentence translations to the pull push dialog to support languages with declinations #1648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sejas
merged 5 commits into
trunk
from
update/stu-672-studio-add-full-sentence-translations-pull-push-dialog
Aug 7, 2025
+140
−41
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0c10bd0
Use full translation strings for better translation
sejas 54d75d6
fix tests
sejas 3e832b8
Add test case for non supported environment
sejas be8bde2
Update the descriptions for pull and push dialog to clarify remote lo…
sejas 3462069
Replace local site with remote site
sejas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,46 +1,103 @@ | ||
| import { sprintf } from '@wordpress/i18n'; | ||
| import { useI18n } from '@wordpress/react-i18n'; | ||
| import { useMemo } from 'react'; | ||
| import { getEnvironmentLabel } from 'src/modules/sync/lib/environment-utils'; | ||
| import { EnvironmentType } from 'src/modules/sync/lib/environment-utils'; | ||
|
|
||
| export const useSyncDialogTexts = ( type: 'pull' | 'push', envType: string ) => { | ||
| type TextByEnvironment = { | ||
| [ key in EnvironmentType ]: { | ||
| title: string; | ||
| description: string; | ||
| }; | ||
| }; | ||
|
|
||
| type SyncDialogTexts = { | ||
| title: string; | ||
| description: string; | ||
| fromLabel: string; | ||
| toLabel: string; | ||
| subtitleSelector: string; | ||
| envSync: string; | ||
| submit: string; | ||
| }; | ||
|
|
||
| export const useSyncDialogTexts = ( | ||
| type: 'pull' | 'push', | ||
| siteEnv: EnvironmentType | ||
| ): SyncDialogTexts => { | ||
| const { __ } = useI18n(); | ||
|
|
||
| return useMemo( () => { | ||
| const envLabel = getEnvironmentLabel( envType ); | ||
|
|
||
| if ( type === 'pull' ) { | ||
| const textByEnvironment: TextByEnvironment = { | ||
| production: { | ||
| title: __( 'Pull from Production' ), | ||
| description: __( | ||
| "Pulling will overwrite your Studio site's selected files and database with a copy from your production site. Unchecked items will not be changed." | ||
| ), | ||
| }, | ||
| staging: { | ||
| title: __( 'Pull from Staging' ), | ||
| description: __( | ||
| "Pulling will overwrite your Studio site's selected files and database with a copy from your staging site. Unchecked items will not be changed." | ||
| ), | ||
| }, | ||
| development: { | ||
| title: __( 'Pull from Development' ), | ||
| description: __( | ||
| "Pulling will overwrite your Studio site's selected files and database with a copy from your development site. Unchecked items will not be changed." | ||
| ), | ||
| }, | ||
| local: { | ||
| title: __( 'Pull from remote Local' ), | ||
| description: __( | ||
| "Pulling will overwrite your Studio site's selected files and database with a copy from your remote site with local environment. Unchecked items will not be changed." | ||
| ), | ||
| }, | ||
| }; | ||
| return { | ||
| /* translators: %s is the environment name (e.g., "Production", "Staging", "Sandbox") */ | ||
| title: sprintf( __( 'Pull from %s' ), envLabel ), | ||
| /* translators: %s is the environment type (e.g., "production", "staging", "sandbox") */ | ||
| description: sprintf( | ||
| __( | ||
| "Pulling will overwrite your Studio site's selected files and database with a copy from your %s site. Unchecked items will not be changed." | ||
| ), | ||
| envType | ||
| ), | ||
| title: textByEnvironment[ siteEnv ].title, | ||
| description: textByEnvironment[ siteEnv ].description, | ||
| fromLabel: __( 'Pull' ), | ||
| toLabel: __( 'To' ), | ||
| subtitleSelector: __( 'What would you like to pull?' ), | ||
| envSync: __( 'Read more about <a>environment pull <ArrowIcon /></a>' ), | ||
| submit: __( 'Pull' ), | ||
| }; | ||
| } else { | ||
| const textByEnvironment: TextByEnvironment = { | ||
| production: { | ||
| title: __( 'Push to Production' ), | ||
| description: __( | ||
| "Pushing will overwrite your production site's selected files and database with content from your Studio site. Unchecked items will not be changed. The production site will be backed up before any changes are applied." | ||
| ), | ||
| }, | ||
| staging: { | ||
| title: __( 'Push to Staging' ), | ||
| description: __( | ||
| "Pushing will overwrite your staging site's selected files and database with content from your Studio site. Unchecked items will not be changed. The staging site will be backed up before any changes are applied." | ||
| ), | ||
| }, | ||
| development: { | ||
| title: __( 'Push to Development' ), | ||
| description: __( | ||
| "Pushing will overwrite your development site's selected files and database with content from your Studio site. Unchecked items will not be changed. The development site will be backed up before any changes are applied." | ||
| ), | ||
| }, | ||
| local: { | ||
| title: __( 'Push to remote Local' ), | ||
| description: __( | ||
| "Pushing will overwrite your remote site's selected files and database with content from your Studio site. Unchecked items will not be changed. The remote site will be backed up before any changes are applied." | ||
| ), | ||
| }, | ||
| }; | ||
| return { | ||
| /* translators: %s is the environment name (e.g., "Production", "Staging", "Sandbox") */ | ||
| title: sprintf( __( 'Push to %s' ), envLabel ), | ||
| /* translators: first %1s is the environment type, which is used twice in the sentence (e.g., "production", "staging", "sandbox") */ | ||
| description: sprintf( | ||
| __( | ||
| "Pushing will overwrite your %s site's selected files and database with content from your local site. Unchecked items will not be changed. The %1s site will be backed up before any changes are applied." | ||
| ), | ||
| envType | ||
| ), | ||
| title: textByEnvironment[ siteEnv ].title, | ||
| description: textByEnvironment[ siteEnv ].description, | ||
| fromLabel: __( 'Push' ), | ||
| toLabel: __( 'To' ), | ||
| subtitleSelector: __( 'What would you like to push?' ), | ||
| envSync: __( 'Read more about <a>environment push <ArrowIcon /></a>' ), | ||
| submit: __( 'Push' ), | ||
| }; | ||
| } | ||
| }, [ envType, type, __ ] ); | ||
| }, [ type, __, siteEnv ] ); | ||
| }; | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,11 +1,13 @@ | ||
| import { __ } from '@wordpress/i18n'; | ||
| import { z } from 'zod'; | ||
| import { SyncSite } from 'src/hooks/use-fetch-wpcom-sites/types'; | ||
|
|
||
| export const getSiteEnvironment = ( connectedSite: SyncSite ): string => { | ||
| if ( connectedSite.isPressable ) { | ||
| return connectedSite.environmentType ?? 'production'; | ||
| } | ||
| return connectedSite.isStaging ? 'staging' : 'production'; | ||
| const EnvironmentSchema = z.enum( [ 'production', 'staging', 'development', 'local' ] ); | ||
| export type EnvironmentType = z.infer< typeof EnvironmentSchema >; | ||
|
|
||
| export const getSiteEnvironment = ( site: SyncSite ): EnvironmentType => { | ||
| const parsed = EnvironmentSchema.safeParse( site.environmentType ); | ||
| return parsed.success ? parsed.data : 'production'; | ||
| }; | ||
|
|
||
| export const getEnvironmentLabel = ( type: string ): string => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was going to mention that this also would need to be updated but I see that it is being implemented in https://github.com/Automattic/studio/pull/1645/files 👍 |
||
|
|
||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't sound very clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll remove the remote
localenvironment type from Studio in https://github.com/Automattic/studio/pull/1645/files#diff-afa3cab5af25735a5b33b66f73efe079aadcbc7ded98e89c72fbb2fcb5687edaThanks for the feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for linking those, makes sense.