Skip to content

Commit

Permalink
I18N-1297 - Temporarily block third-party sync for a Text Unit Variant
Browse files Browse the repository at this point in the history
Added a new status to text unit variants and avoid updating them
  • Loading branch information
DarKhaos committed Oct 22, 2024
1 parent b5454c6 commit b94cfb9
Show file tree
Hide file tree
Showing 14 changed files with 335 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ public enum Status {

MT_REVIEW,
/** A string that doesn't need any work to be performed on it. */
APPROVED;
APPROVED,

/** It was translated in Mojito, so it won't be updated during third-party sync */
TRANSLATED_IN_MOJITO;
};

@Column(name = "content", length = Integer.MAX_VALUE)
Expand Down
57 changes: 46 additions & 11 deletions webapp/src/main/java/com/box/l10n/mojito/service/tm/TMService.java
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,8 @@ public AddTMTextUnitCurrentVariantResult addTMTextUnitCurrentVariantWithResult(
TMTextUnitVariant.Status status,
boolean includedInLocalizedFile,
ZonedDateTime createdDate,
User createdBy) {
User createdBy,
boolean checkTranslatedInMojito) {

boolean noUpdate = false;

Expand Down Expand Up @@ -604,16 +605,21 @@ public AddTMTextUnitCurrentVariantResult addTMTextUnitCurrentVariantWithResult(
} else {
logger.debug("There is a current text unit variant, check if an update is needed");
TMTextUnitVariant currentTmTextUnitVariant = tmTextUnitCurrentVariant.getTmTextUnitVariant();
boolean translatedInMojito =
checkTranslatedInMojito
&& currentTmTextUnitVariant.getStatus()
== TMTextUnitVariant.Status.TRANSLATED_IN_MOJITO;
boolean updateNeeded =
isUpdateNeededForTmTextUnitVariant(
currentTmTextUnitVariant.getStatus(),
currentTmTextUnitVariant.getContentMD5(),
currentTmTextUnitVariant.isIncludedInLocalizedFile(),
currentTmTextUnitVariant.getComment(),
status,
DigestUtils.md5Hex(content),
includedInLocalizedFile,
comment);
!translatedInMojito
&& isUpdateNeededForTmTextUnitVariant(
currentTmTextUnitVariant.getStatus(),
currentTmTextUnitVariant.getContentMD5(),
currentTmTextUnitVariant.isIncludedInLocalizedFile(),
currentTmTextUnitVariant.getComment(),
status,
DigestUtils.md5Hex(content),
includedInLocalizedFile,
comment);

if (updateNeeded) {
logger.debug(
Expand All @@ -638,14 +644,43 @@ public AddTMTextUnitCurrentVariantResult addTMTextUnitCurrentVariantWithResult(
tmTextUnitCurrentVariantRepository.save(tmTextUnitCurrentVariant);
} else {
logger.debug(
"The current text unit variant has same content, comment and review status, don't add entities and return it instead");
translatedInMojito
? "The current text unit variant is kept because it has the TRANSLATED_IN_MOJITO status"
: "The current text unit variant has same content, comment and review status, don't add entities and return it instead");
noUpdate = true;
}
}

return new AddTMTextUnitCurrentVariantResult(!noUpdate, tmTextUnitCurrentVariant);
}

public AddTMTextUnitCurrentVariantResult addTMTextUnitCurrentVariantWithResult(
TMTextUnitCurrentVariant tmTextUnitCurrentVariant,
Long tmId,
Long assetId,
Long tmTextUnitId,
Long localeId,
String content,
String comment,
TMTextUnitVariant.Status status,
boolean includedInLocalizedFile,
ZonedDateTime createdDate,
User createdBy) {
return this.addTMTextUnitCurrentVariantWithResult(
tmTextUnitCurrentVariant,
tmId,
assetId,
tmTextUnitId,
localeId,
content,
comment,
status,
includedInLocalizedFile,
createdDate,
createdBy,
false);
}

/**
* Indicates if a {@link TMTextUnitVariant} should be updated by looking at new/old content,
* status, comments, etc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ void importTextUnitsOfLocaleAndAsset(
textUnitForBatchImport.getStatus(),
textUnitForBatchImport.isIncludedInLocalizedFile(),
importTime,
importedBy);
importedBy,
true);

if (addTMTextUnitCurrentVariantResult.isTmTextUnitCurrentVariantUpdated()) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,6 @@ public enum StatusFilter {
* TextUnits that are not rejected, ie {@link TMTextUnitVariant#includedInLocalizedFile} is true.
*/
NOT_REJECTED,
/** TextUnits with status ({@link TMTextUnitVariant.Status#TRANSLATED_IN_MOJITO}). */
TRANSLATED_IN_MOJITO,
}
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,11 @@ NativeCriteria getCriteriaForSearch(TextUnitSearcherParameters searchParameters)
"tuv.status", TMTextUnitVariant.Status.TRANSLATION_NEEDED.toString()),
new NativeEqExpFix("tuv.included_in_localized_file", Boolean.FALSE))));
break;
case TRANSLATED_IN_MOJITO:
conjunction.add(
new NativeEqExpFix(
"tuv.status", TMTextUnitVariant.Status.TRANSLATED_IN_MOJITO.toString()));
break;
default:
throw new RuntimeException("Filter type not implemented");
}
Expand Down
127 changes: 100 additions & 27 deletions webapp/src/main/resources/config/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ server.port=8080
server.error.include-message=always

# FLYWAY
spring.flyway.enabled=false
#spring.flyway.enabled=false

# JPA / ENVERS
spring.jpa.properties.org.hibernate.envers.audit_strategy=org.hibernate.envers.strategy.ValidityAuditStrategy
Expand All @@ -34,11 +34,11 @@ spring.jpa.properties.org.hibernate.envers.track_entities_changed_in_revision=tr
# it false break cli tests
#spring.jpa.open-in-view=false

spring.datasource.url=jdbc:hsqldb:mem:testdb;DB_CLOSE_DELAY=-1
#spring.datasource.url=jdbc:hsqldb:mem:testdb;DB_CLOSE_DELAY=-1
# adding defer-datasource-initialization=true means we must set it to false in the production profile, else it is
# conflicting with Flyway. I'd expect that parameter to not do anything for non-embedded database but it does conflict
# with Flyway regardless. So this is not great but don't have a better solution at the moment.
spring.jpa.defer-datasource-initialization=true
#spring.jpa.defer-datasource-initialization=true
spring.sql.init.schema-locations=classpath:/db/hsql/schema.sql
spring.sql.init.data-locations=classpath:/db/hsql/data.sql
spring.datasource.hikari.maximum-pool-size=30
Expand Down Expand Up @@ -185,15 +185,7 @@ spring.session.jdbc.table-name=SPRING_SESSION_V2


# Slack client
#l10n.slackClients.slack-bot-name-here.token=xxx-yyy-zzz

# Integrity Check Notifier Warnings
#l10n.integrity-check-notifier.enabled=true
# Default Slack client to use for sending warnings
#l10n.integrity-check-notifier.slackClientId=slack-bot-name-here
#l10n.integrity-check-notifier.slackChannel=#name-of-channel-for-warnings
#l10n.integrity-check-notifier.warnings.html-tag.title=Tag Mismatch In Translated String
#l10n.integrity-check-notifier.warnings.html-tag.text=The source and target string have a mismatch in their tags.
#l10n.slack.token=xxx-yyy-zzz

# Phabricator client
#l10n.phabricator.token=api-xyz
Expand All @@ -206,9 +198,6 @@ spring.session.jdbc.table-name=SPRING_SESSION_V2
# Notification for branch activity
#l10n.branchNotification.slack.enabled=true
#l10n.branchNotification.slack.userEmailPattern={0}@test.com
# Blocked usernames to not send Slack messages to (Regex works here and usernames can be seperated by commas)
#l10n.branchNotification.slack.blockedUsernames=bot-number-001,jenkins-bot,.*\\\[bot\\\]$

#l10n.branchNotification.phabricator.enabled=true
#l10n.branchNotification.phabricator.reviewer=PHID-PROJ-xyz
#l10n.branchNotification.phabricator.blockingReview=true
Expand All @@ -217,7 +206,7 @@ spring.session.jdbc.table-name=SPRING_SESSION_V2
#l10n.link.{repository}.location.url=https://opengrok.someplace.com/xref/${openGrokRepository}
#l10n.link.{repository}.location.extractedPrefix=/some/extractor/prefix/
#l10n.link.{repository}.location.label=${openGrokRepository}
#l10n.link.{repository}.location.useUsage=True
#l10n.link.{repository}.location.useUsage=true
#l10n.link.{repository}.pullRequest.url=https://secure.phabricator.com/${branchName}


Expand All @@ -233,7 +222,7 @@ spring.session.jdbc.table-name=SPRING_SESSION_V2

#l10n.link.{repository2}.location.url=https://someotherplace.com/xref/${textUnitName}
#l10n.link.{repository2}.location.label=${textUnitName}
#l10n.link.{repository2}.location.useUsage=False
#l10n.link.{repository2}.location.useUsage=false

# Google Analytics
#l10n.googleAnalytics.enabled=true
Expand All @@ -256,13 +245,97 @@ spring.session.jdbc.table-name=SPRING_SESSION_V2
#l10n.blob-storage.s3.bucket=mojito
#l10n.blob-storage.s3.prefix=mojito

# PagerDuty - Value is an integration key for 'Events API v2' integration
#l10n.pagerduty.integrations.default=xxxyyyzzz

# Adjust the number of retries and delay between retries for the PagerDuty client
# l10n.pagerduty.retry.maxRetries=5
# Minimum back off delay in milliseconds
# l10n.pagerduty.retry.minBackOffDelay=500
# Maximum back off delay in milliseconds
# l10n.pagerduty.retry.maxBackOffDelay=5000

### SQL DEBUGGING
#spring.jpa.properties.hibernate.generate_statistics=true
#spring.jpa.properties.hibernate.show_sql=true
#spring.jpa.properties.hibernate.format_sql=true
#logging.level.org.hibernate.SQL=DEBUG

# # PARAMS:
#logging.level.org.hibernate.type=TRACE
#logging.level.org.hibernate.engine.query.spi.HQLQueryPlan=TRACE

spring.flyway.enabled=true
spring.jpa.defer-datasource-initialization=false
l10n.flyway.clean=false
spring.datasource.url=jdbc:mysql://localhost:3306/mojitodb?characterEncoding=UTF-8&useUnicode=true
spring.datasource.username=mojito
spring.datasource.password=password1
spring.datasource.driverClassName=com.mysql.jdbc.Driver

l10n.org.quartz.jobStore.useProperties=true
l10n.org.quartz.scheduler.instanceId=AUTO
l10n.org.quartz.jobStore.isClustered=true
l10n.org.quartz.threadPool.threadCount=10
l10n.org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX
l10n.org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate
l10n.org.quartz.jobStore.dataSource=myDS
l10n.org.quartz.dataSource.myDS.provider=hikaricp
l10n.org.quartz.dataSource.myDS.driver=com.mysql.jdbc.Driver
l10n.org.quartz.dataSource.myDS.URL=jdbc:mysql://localhost:3306/mojitodb?characterEncoding=UTF-8&useUnicode=true
l10n.org.quartz.dataSource.myDS.user=mojito
l10n.org.quartz.dataSource.myDS.password=password1
l10n.org.quartz.dataSource.myDS.maxConnections=12
l10n.org.quartz.dataSource.myDS.validationQuery=select 1

spring.flyway.driver-class-name=com.mysql.jdbc.Driver
spring.flyway.url=jdbc:mysql://localhost:3306/mojitodb?characterEncoding=UTF-8&useUnicode=true
spring.flyway.user=mojito
spring.flyway.password=password1

l10n.smartling.clientID=tinbznavwfwvadmltylpjrhwqpofpl
l10n.smartling.clientSecret=s3u7m1opom00qvmcqhh2u4fq7oDR_jkc6ha73r308nelbpmd751vqdf
l10n.ThirdPartyTMS.impl=ThirdPartyTMSSmartling
l10n.smartling.accountId=128217e07

l10n.link.android.location.url=https://github.com/search?q=repo:"pinternal/android"+path:"${assetPath}"+"${textUnitName}"&type=code
l10n.link.android.location.label=${assetPath}/${textUnitNameInSource}
l10n.link.android.location.useUsage=false
l10n.link.android.commit.url=https://github.com/pinternal/android/commit/${commit}
l10n.link.android.commit.label=${commit}
l10n.link.android.thirdParty.url=https://dashboard.smartling.com/app/projects/45cb8ac6c/strings/?hashcodes=${thirdPartyTextUnitId}
l10n.link.android.thirdParty.label=Search in Smartling
l10n.link.android.pullRequest.url=https://github.com/${branchName}
l10n.link.android.textUnitNameToTextUnitNameInSource.singular=(.*)
l10n.link.android.textUnitNameToTextUnitNameInSource.plural=(.*)_(zero|one|two|few|many|other)$

l10n.link.webapp.location.url=https://github.com/pinternal/pinboard/blob/master/${filePath}#L${lineNumber}
l10n.link.webapp.location.extractorPrefixRegex=/mnt/pinboard/
l10n.link.webapp.location.label=${usage}
l10n.link.webapp.location.useUsage=true
l10n.link.webapp.commit.url=https://github.com/pinternal/pinboard/commit/${commit}
l10n.link.webapp.commit.label=${commit}
l10n.link.webapp.thirdParty.url=https://dashboard.smartling.com/app/projects/89bed53e6/strings/?hashcodes=${thirdPartyTextUnitId}
l10n.link.webapp.thirdParty.label=Search in Smartling
l10n.link.webapp.pullRequest.url=https://github.com/${branchName}

l10n.link.pinboard.location.url=https://github.com/pinternal/pinboard/blob/master/${filePath}#L${lineNumber}
l10n.link.pinboard.location.label=${usage}
l10n.link.pinboard.location.useUsage=true
l10n.link.pinboard.commit.url=https://github.com/pinternal/pinboard/commit/${commit}
l10n.link.pinboard.commit.label=${commit}
l10n.link.pinboard.thirdParty.url=https://dashboard.smartling.com/app/projects/f98185df6/strings/?hashcodes=${thirdPartyTextUnitId}
l10n.link.pinboard.thirdParty.label=Search in Smartling
l10n.link.pinboard.pullRequest.url=https://github.com/${branchName}

#l10n.blob-storage.s3.bucket=pinterest-maryville
#l10n.blob-storage.s3.prefix=mojito-dev
#l10n.asset-content-service.storage.type=s3Fallback
#l10n.blob-storage.type=s3
#l10n.aws.s3.enabled=true
#l10n.aws.s3.access-key-id=
#l10n.aws.s3.access-key-secret=
#l10n.aws.s3.region=us-east-1

#l10n.branchNotification.notifiers.github.github-pinternal.owner=pinternal
#l10n.branchNotification.notifiers.github.github-pinternal.messages.newNotificationMsgFormat={message}{link}\n\n{strings}\n\n\
# _Need more information? Check [how to provide screenshots](http://pinch.pinadmin.com/glow-screenshot) and read about [translation times](http://pinch.pinadmin.com/glow-translation-times) in the [Glow! documentation](http://pinch.pinadmin.com/glow)._
#l10n.branchNotification.notifiers.github.github-pinternal.messages.newStrings=:globe_with_meridians: We received your strings! Please **add screenshots** :camera_flash: before the cutoff time at **3pm PST** and **wait for translations** before releasing.
#l10n.branchNotification.notifiers.github.github-pinternal.messages.updatedNotificationMsgFormat={message}{link}\n\n{strings}\n\n\
# _Need more information? Check [how to provide screenshots](http://pinch.pinadmin.com/glow-screenshot) and read about [translation times](http://pinch.pinadmin.com/glow-translation-times) in the [Glow! documentation](http://pinch.pinadmin.com/glow)._
#l10n.branchNotification.notifiers.github.github-pinternal.messages.updatedStrings=:new: Your branch was updated with new strings! Please **add screenshots** :camera_flash: before the cutoff time at **3pm PST** and **wait for translations** before releasing.
#l10n.branchNotification.notifiers.github.github-pinternal.messages.screenshotsMissing=Please provide screenshots to help the localization team before the **3pm PST** cutoff time.\n\n\
# _Need more information? Check [how to provide screenshots](http://pinch.pinadmin.com/glow-screenshot) and read about [translation times](http://pinch.pinadmin.com/glow-translation-times) in the [Glow! documentation](http://pinch.pinadmin.com/glow)._
#l10n.branchNotification.notifiers.github.github-pinternal.messages.translationsReady=Translations are ready in [Mojito](https://mojito.pinadmin.com/branches?searchText={branchName}&deleted=true&onlyMyBranches=false) and you will \
# have them in GitHub soon! :tada:\n\nThey will be pushed [automatically](https://github.com/search?q=repo%3Apinternal%2F{githubRepository}+%5Bauto-l10n%5D&type=commits&s=committer-date&o=desc) to the **master** branch a few hours after your PR is merged. \
# You can then rebase your branch off the latest **master** branch in order to see the translations working locally.\n\n_Need more information? Check [the documentation](http://pinch.pinadmin.com/glow)_.
6 changes: 6 additions & 0 deletions webapp/src/main/resources/properties/en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ search.statusDropdown.needsReview=Needs Review
# Status filter option to search for text units that need to be translated
search.statusDropdown.forTranslation=Needs Translation

# Status filter option to search for text units that are translated in Mojito
search.statusDropdown.translatedInMojito=Translated in Mojito

# Status filter option to search for text units that are rejected (won't be added in localized file)
search.statusDropdown.rejected=Rejected

Expand Down Expand Up @@ -325,6 +328,9 @@ textUnit.reviewModal.rejected=Rejected
# Button label used for primary action "removeReview" on modal dialog
textUnit.reviewModal.accepted=Accepted

# Label for Translated in Mojito button on modal dialog
textUnit.reviewModal.translatedInMojito=Translated in Mojito

# Button label used for the Needs Review button on the textunit review modal
textUnit.reviewModal.needsReview=Needs Review

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ let StatusDropdown = createReactClass({
},

setStateAndCallSearchParamChanged(searchFilterParam, searchFilterParamValue) {

let state = {};

state[searchFilterParam] = searchFilterParamValue;

this.setState(state, function () {
Expand Down Expand Up @@ -170,6 +170,8 @@ let StatusDropdown = createReactClass({
return this.props.intl.formatMessage({ id: "search.statusDropdown.needsReview" });
case SearchParamsStore.STATUS.REJECTED:
return this.props.intl.formatMessage({ id: "search.statusDropdown.rejected" });
case SearchParamsStore.STATUS.TRANSLATED_IN_MOJITO:
return this.props.intl.formatMessage({ id: "search.statusDropdown.translatedInMojito" });
}
},

Expand Down Expand Up @@ -263,6 +265,7 @@ let StatusDropdown = createReactClass({
{this.renderStatusMenuItem(SearchParamsStore.STATUS.FOR_TRANSLATION)}
{this.renderStatusMenuItem(SearchParamsStore.STATUS.REVIEW_NEEDED)}
{this.renderStatusMenuItem(SearchParamsStore.STATUS.REJECTED)}
{this.renderStatusMenuItem(SearchParamsStore.STATUS.TRANSLATED_IN_MOJITO)}

<MenuItem divider />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,10 @@ let TextUnit = createReactClass({
textUnit.setIncludedInLocalizedFile(true);
textUnit.setStatus(TextUnitSDK.STATUS.TRANSLATION_NEEDED);
break;
case "translated_in_mojito":
textUnit.setIncludedInLocalizedFile(true);
textUnit.setStatus(TextUnitSDK.STATUS.TRANSLATED_IN_MOJITO);
break;
}

WorkbenchActions.saveTextUnit(textUnit);
Expand Down
Loading

0 comments on commit b94cfb9

Please sign in to comment.