diff --git a/src/client/components/TranslationReportTable.jsx b/src/client/components/TranslationReportTable.jsx
index 18247655..c80d7227 100644
--- a/src/client/components/TranslationReportTable.jsx
+++ b/src/client/components/TranslationReportTable.jsx
@@ -83,24 +83,10 @@ const TranslationReportTable = ( { locale, localeName, wantsUntranslated } ) =>
: <>>
}
-
diff --git a/src/client/js/SortKeyEnum.js b/src/client/js/SortKeyEnum.js
index c769931f..8363cbca 100644
--- a/src/client/js/SortKeyEnum.js
+++ b/src/client/js/SortKeyEnum.js
@@ -10,9 +10,10 @@
const SortKeyEnum = {
SIM_TITLE: [ 'simTitle' ],
- SIM_SPECIFIC_PERCENT: [ 'simSpecificPercent', 'numSimSpecificStrings' ],
- COMMON_PERCENT: [ 'commonPercent', 'numCommonStrings' ],
- SHARED_PERCENT: [ 'sharedPercent', 'numSharedStrings' ]
+ TOTAL_STRINGS: [ 'percentTotal, totalTranslatedStrings' ],
+ SIM_SPECIFIC_PERCENT: [ 'percentSimSpecific', 'numSimSpecificStrings' ],
+ COMMON_PERCENT: [ 'percentCommon', 'numCommonStrings' ],
+ SHARED_PERCENT: [ 'percentShared', 'numSharedStrings' ]
};
Object.freeze( SortKeyEnum );
diff --git a/src/client/jsx/getTranslationReportRows.jsx b/src/client/jsx/getTranslationReportRows.jsx
index 864e2002..84236d55 100644
--- a/src/client/jsx/getTranslationReportRows.jsx
+++ b/src/client/jsx/getTranslationReportRows.jsx
@@ -11,6 +11,7 @@ import { Link } from 'react-router-dom';
import getMinutesElapsed from '../../common/getMinutesElapsed.js';
import publicConfig from '../../common/publicConfig.js';
import getSortedTranslationReportRows from './getSortedTranslationReportRows.jsx';
+import infoCircle from '../img/info-circle.svg';
/**
* Return an array of translation report table rows, i.e. return an array of JSX. These rows are put into the
@@ -75,34 +76,41 @@ const getTranslationReportRows = (
}
// Create the row JSX.
- const simSpecificPercent = Math.floor( ( reportObject.numSimSpecificTranslatedStrings / reportObject.numSimSpecificStrings ) * 100 );
- let sharedPercent = 0;
const hasSharedStrings = reportObject.numSharedStrings !== null;
let sharedStatsString = 'N/A';
- const commonPercent = Math.floor( ( reportObject.numCommonTranslatedStrings / reportObject.numCommonStrings ) * 100 );
if ( hasSharedStrings ) {
- sharedPercent = Math.floor( ( reportObject.numSharedTranslatedStrings / reportObject.numSharedStrings ) * 100 );
- sharedStatsString = `${sharedPercent}% (${reportObject.numSharedTranslatedStrings} of ${reportObject.numSharedStrings})`;
+ sharedStatsString = `${reportObject.percentShared}% (${reportObject.numSharedTranslatedStrings} of ${reportObject.numSharedStrings})`;
}
- let totalStrings = reportObject.numSimSpecificStrings +
- reportObject.numCommonStrings;
- let totalTranslatedStrings = reportObject.numSimSpecificTranslatedStrings +
- reportObject.numCommonTranslatedStrings;
- if ( hasSharedStrings ) {
- totalStrings += reportObject.numSharedStrings;
- totalTranslatedStrings += reportObject.numSharedTranslatedStrings;
- }
- const simSpecificStatsString = `${simSpecificPercent}% (${reportObject.numSimSpecificTranslatedStrings} of ${reportObject.numSimSpecificStrings})`;
- const commonStatsString = `${commonPercent}% (${reportObject.numCommonTranslatedStrings} of ${reportObject.numCommonStrings})`;
- console.log( sharedStatsString );
- console.log( simSpecificStatsString );
- console.log( commonStatsString );
- const totalPercent = Math.floor( ( totalTranslatedStrings / totalStrings ) * 100 );
+ const simSpecificStatsString = `${reportObject.percentSimSpecific}% (${reportObject.numSimSpecificTranslatedStrings} of ${reportObject.numSimSpecificStrings})`;
+ const commonStatsString = `${reportObject.percentCommon}% (${reportObject.numCommonTranslatedStrings} of ${reportObject.numCommonStrings})`;
+ const statsString = `Statistics for ${reportObject.simTitle}:
+ Sim-Specific Strings: ${simSpecificStatsString}
+ Shared Strings: ${sharedStatsString}
+ Common Strings: ${commonStatsString}`;
+ const buttonStyle = {
+ marginRight: '6px',
+ padding: '0'
+ };
+ const statsInfoJsx = (
+
+ );
if ( Object.keys( translationReportJsx ).includes( reportObject.simName ) ) {
translationReportJsx[ reportObject.simName ] = (
{reportObject.simTitle}{pendingUpdate} |
- {totalPercent}% ({totalTranslatedStrings} of {totalStrings}) |
+
+ {statsInfoJsx}
+ {reportObject.percentTotal}% ({reportObject.totalTranslatedStrings} of {reportObject.totalStrings})
+ |
);
}
diff --git a/src/server/translationApi/translationReport/getTranslationReportObject.js b/src/server/translationApi/translationReport/getTranslationReportObject.js
index 51c60377..97ccc49b 100644
--- a/src/server/translationApi/translationReport/getTranslationReportObject.js
+++ b/src/server/translationApi/translationReport/getTranslationReportObject.js
@@ -14,6 +14,27 @@ import getCommonTranslatedStringKeysAndValues from './getCommonTranslatedStringK
import getSimSpecificEnglishStringKeysAndValues from './getSimSpecificEnglishStringKeysAndValues.js';
import getSimSpecificTranslatedStringKeysAndValues from './getSimSpecificTranslatedStringKeysAndValues.js';
+const getPercent = ( numerator, denominator ) => {
+ let percent = null;
+ if ( numerator !== null && denominator !== null ) {
+ percent = Math.floor( ( numerator / denominator ) * 100 );
+ }
+ return percent;
+};
+
+const getTotalStrings = values => {
+ let total = 0;
+ for ( const value of values ) {
+ if ( value === null ) {
+ total += 0;
+ }
+ else {
+ total += value;
+ }
+ }
+ return total;
+};
+
const getTranslationReportObject = async (
simName,
locale,
@@ -26,10 +47,16 @@ const getTranslationReportObject = async (
simTitle: simTitle,
numCommonStrings: null,
numCommonTranslatedStrings: null,
+ percentCommon: null,
numSimSpecificStrings: null,
numSimSpecificTranslatedStrings: wantsUntranslated === 'true' ? 0 : null,
+ percentSimSpecific: null,
numSharedStrings: null,
- numSharedTranslatedStrings: null
+ numSharedTranslatedStrings: wantsUntranslated === 'true' ? 0 : null,
+ percentShared: null,
+ totalStrings: null,
+ totalTranslatedStrings: null,
+ percentTotal: null
};
// If the user is in development environment, and they set the short report
@@ -46,10 +73,37 @@ const getTranslationReportObject = async (
const DENOMINATOR_MAX = 100;
translationReportObject.numCommonStrings = getRandomInt( DENOMINATOR_MIN, DENOMINATOR_MAX );
translationReportObject.numCommonTranslatedStrings = getRandomInt( NUMERATOR_MIN, NUMERATOR_MAX );
+ translationReportObject.percentCommon = getPercent(
+ translationReportObject.numCommonTranslatedStrings,
+ translationReportObject.numCommonStrings
+ );
translationReportObject.numSimSpecificStrings = getRandomInt( DENOMINATOR_MIN, DENOMINATOR_MAX );
translationReportObject.numSimSpecificTranslatedStrings = wantsUntranslated === 'true' ? 0 : getRandomInt( DENOMINATOR_MIN, DENOMINATOR_MAX );
+ translationReportObject.percentSimSpecific = getPercent(
+ translationReportObject.numSimSpecificTranslatedStrings,
+ translationReportObject.numSimSpecificStrings
+ );
translationReportObject.numSharedStrings = getRandomInt( DENOMINATOR_MIN, DENOMINATOR_MAX );
translationReportObject.numSharedTranslatedStrings = getRandomInt( NUMERATOR_MIN, NUMERATOR_MAX );
+ translationReportObject.percentShared = getPercent(
+ translationReportObject.numSharedTranslatedStrings,
+ translationReportObject.numSharedStrings
+ );
+ translationReportObject.totalStrings = getTotalStrings( [
+ translationReportObject.numCommonStrings,
+ translationReportObject.numSimSpecificStrings,
+ translationReportObject.numSharedStrings
+ ] );
+ translationReportObject.totalTranslatedStrings = getTotalStrings( [
+ translationReportObject.numCommonTranslatedStrings,
+ translationReportObject.numSimSpecificTranslatedStrings,
+ translationReportObject.numSharedTranslatedStrings
+ ] );
+ translationReportObject.percentTotal = getPercent(
+ translationReportObject.totalTranslatedStrings,
+ translationReportObject.totalStrings
+ );
+
return translationReportObject;
}
@@ -82,6 +136,11 @@ const getTranslationReportObject = async (
.filter( key => commonTranslatedStringKeysAndValues[ key ] !== ''
&& commonEnglishStringKeysAndValues[ key ] !== noLongerUsedFlag ).length;
+ translationReportObject.percentCommon = getPercent(
+ translationReportObject.numCommonTranslatedStrings,
+ translationReportObject.numCommonStrings
+ );
+
const latestSimSha = await getLatestSimSha( simName );
const simSpecificEnglishStringKeysAndValues = await getSimSpecificEnglishStringKeysAndValues(
simName,
@@ -107,6 +166,11 @@ const getTranslationReportObject = async (
} ).length;
}
+ translationReportObject.percentSimSpecific = getPercent(
+ translationReportObject.numSimSpecificTranslatedStrings,
+ translationReportObject.numSimSpecificStrings
+ );
+
// If there are shared strings for this sim, we need to get the stats for those.
if ( categorizedStringKeys.shared.length > 0 ) {
@@ -156,15 +220,30 @@ const getTranslationReportObject = async (
&& sharedEnglishStringKeysAndValues[ key ] !== noLongerUsedFlag;
} ).length;
}
- else {
-
- // If we don't have a translation, this is zero.
- translationReportObject.numSharedTranslatedStrings = 0;
- }
}
}
+
+ translationReportObject.percentShared = getPercent(
+ translationReportObject.numSharedTranslatedStrings,
+ translationReportObject.numSharedStrings
+ );
}
+ translationReportObject.totalStrings = getTotalStrings( [
+ translationReportObject.numCommonStrings,
+ translationReportObject.numSimSpecificStrings,
+ translationReportObject.numSharedStrings
+ ] );
+ translationReportObject.totalTranslatedStrings = getTotalStrings( [
+ translationReportObject.numCommonTranslatedStrings,
+ translationReportObject.numSimSpecificTranslatedStrings,
+ translationReportObject.numSharedTranslatedStrings
+ ] );
+ translationReportObject.percentTotal = getPercent(
+ translationReportObject.totalTranslatedStrings,
+ translationReportObject.totalStrings
+ );
+
return translationReportObject;
};