BearND has uploaded a new change for review. https://gerrit.wikimedia.org/r/184406
Change subject: Add tests for two string parameters ...................................................................... Add tests for two string parameters Change-Id: I07662a650f3d0752cec00fde7c67022198e0f259 --- M wikipedia-it/src/main/java/org/wikipedia/test/TranslationTests.java 1 file changed, 23 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia refs/changes/06/184406/1 diff --git a/wikipedia-it/src/main/java/org/wikipedia/test/TranslationTests.java b/wikipedia-it/src/main/java/org/wikipedia/test/TranslationTests.java index a63c750..108541f 100644 --- a/wikipedia-it/src/main/java/org/wikipedia/test/TranslationTests.java +++ b/wikipedia-it/src/main/java/org/wikipedia/test/TranslationTests.java @@ -29,7 +29,7 @@ private static final String TAG = "TrTest"; /** Add more if needed, but then also add some tests. */ - private static final String[] POSSIBLE_PARAMS = new String[] {"%s", "%d", "%.2f"}; + private static final String[] POSSIBLE_PARAMS = new String[] {"%s", "%1$s", "%2$s", "%d", "%.2f"}; private PageActivity activity; private StringBuilder mismatches = new StringBuilder(); @@ -53,6 +53,7 @@ List<Res> tagRes = new ResourceCollector("<", "<").collectParameterResources(); List<Res> noTagRes = new ResourceCollector("<", "<").not().collectParameterResources(); List<Res> stringParamRes = new ResourceCollector("%s").collectParameterResources(); + List<Res> twoStringParamRes = new ResourceCollector("%2$s").collectParameterResources(); List<Res> decimalParamRes = new ResourceCollector("%d").collectParameterResources(); List<Res> floatParamRes = new ResourceCollector("%.2f").collectParameterResources(); @@ -89,6 +90,11 @@ continue; } checkTranslationHasParameter(res, "%s", "[stringParam]", null); + } + + // 2 string parameters + for (Res res : twoStringParamRes) { + checkTranslationHasTwoParameters(res, "%s", "[stringParam1]", "[stringParam2]"); } // decimal parameters @@ -170,12 +176,26 @@ } public void checkTranslationHasParameter(Res res, String paramName, Object val1, String alternateFormat) { -// Log.i(TAG, myLocale + ":" + res.name); +// Log.i(TAG, myLocale + ":" + res.name + ":" + paramName); String translatedString = getInstrumentation().getTargetContext().getString(res.id, val1); // Log.d(TAG, translatedString); if (!translatedString.contains(String.format(paramName, val1)) && (alternateFormat == null || !translatedString.contains(alternateFormat))) { - final String msg = myLocale + ":" + res.name + " = " + translatedString + "' doesn't contain " + val1; + final String msg = myLocale + ":" + res.name + " = " + translatedString + "' is missing " + val1; + Log.e(TAG, msg); + mismatches.append(msg).append("\n"); + } + } + + private void checkTranslationHasTwoParameters(Res res, String paramName, Object val1, Object val2) { + Log.i(TAG, myLocale + ":" + res.name + ":" + paramName); + String translatedString = getInstrumentation().getTargetContext().getString(res.id, val1, val2); + Log.d(TAG, translatedString); + if (!translatedString.contains(String.format(paramName, val1)) + || !translatedString.contains(String.format(paramName, val2))) { + final String msg = myLocale + ":" + res.name + " = " + translatedString + + "' is missing " + val1 + + "' or " + val2; Log.e(TAG, msg); mismatches.append(msg).append("\n"); } -- To view, visit https://gerrit.wikimedia.org/r/184406 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I07662a650f3d0752cec00fde7c67022198e0f259 Gerrit-PatchSet: 1 Gerrit-Project: apps/android/wikipedia Gerrit-Branch: master Gerrit-Owner: BearND <bsitzm...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits