Skip to content

Commit

Permalink
feat: add shared translation report row cells
Browse files Browse the repository at this point in the history
This commit just adds the `<td>` cells with shared stats. We still need
to wire things up to handle shared stats.

For #347.

Came out of phetsims/qa#869.
  • Loading branch information
liammulh committed Feb 8, 2023
1 parent 1a49679 commit ea38012
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/client/jsx/getTranslationReportRows.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const getTranslationReportRows = (
<td><Link to={`/translate/${locale}/${simName}`}>{simNamesAndTitles[ simName ]}</Link></td>
<td>Loading...</td>
<td>Loading...</td>
<td>Loading...</td>
</tr>
);
}
Expand All @@ -77,12 +78,20 @@ const getTranslationReportRows = (

// Create the row JSX.
const simSpecificPercent = Math.floor( ( reportObject.numSimSpecificTranslatedStrings / reportObject.numSimSpecificStrings ) * 100 );
let sharedPercent = 0;
const hasSharedStrings = reportObject.numSharedStrings && reportObject.numSharedTranslatedStrings;
let sharedJsx = <td>N/A</td>;
const commonPercent = Math.floor( ( reportObject.numCommonTranslatedStrings / reportObject.numCommonStrings ) * 100 );
if ( hasSharedStrings ) {
sharedPercent = Math.floor( ( reportObject.numSharedTranslatedStrings / reportObject.numSharedStrings ) * 100 );
sharedJsx = <td>{sharedPercent}% ({reportObject.numSharedTranslatedStrings} of {reportObject.numSharedStrings})</td>;
}
if ( Object.keys( translationReportJsx ).includes( reportObject.simName ) ) {
translationReportJsx[ reportObject.simName ] = (
<tr key={reportObject.simName}>
<td><Link to={`/translate/${locale}/${reportObject.simName}`}>{reportObject.simTitle}</Link>{pendingUpdate}</td>
<td>{simSpecificPercent}% ({reportObject.numSimSpecificTranslatedStrings} of {reportObject.numSimSpecificStrings})</td>
{sharedJsx}
<td>{commonPercent}% ({reportObject.numCommonTranslatedStrings} of {reportObject.numCommonStrings})</td>
</tr>
);
Expand Down

0 comments on commit ea38012

Please sign in to comment.