mirror of https://github.com/tasks/tasks
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
2.1 KiB
Java
71 lines
2.1 KiB
Java
/**
|
|
* Copyright (c) 2012 Todoroo Inc
|
|
*
|
|
* See the file "LICENSE" for the full license governing this code.
|
|
*/
|
|
package com.todoroo.astrid.test;
|
|
|
|
import android.content.res.Resources;
|
|
|
|
import com.todoroo.andlib.test.TranslationTests;
|
|
|
|
import org.tasks.R;
|
|
|
|
import java.util.Locale;
|
|
|
|
public class AstridTranslationTest extends TranslationTests {
|
|
|
|
@Override
|
|
public Class<?> getArrayResources() {
|
|
return R.array.class;
|
|
}
|
|
|
|
@Override
|
|
public Class<?> getStringResources() {
|
|
return R.string.class;
|
|
}
|
|
|
|
@Override
|
|
public int[] getDateFormatStrings() {
|
|
return new int[] {
|
|
//
|
|
};
|
|
}
|
|
|
|
/**
|
|
* check if string contains contains substrings
|
|
*/
|
|
public void contains(Resources r, int resource, StringBuilder failures, String... contains) {
|
|
String string = r.getString(resource);
|
|
for(String contain : contains)
|
|
if(!string.contains(contain)) {
|
|
Locale locale = r.getConfiguration().locale;
|
|
String name = r.getResourceName(resource);
|
|
failures.append(String.format("%s: %s did not contain: %s\n",
|
|
locale.toString(), name, contain));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Test dollar sign resources
|
|
*/
|
|
public void testSpecialStringsMatch() throws Exception {
|
|
final Resources r = getContext().getResources();
|
|
final StringBuilder failures = new StringBuilder();
|
|
|
|
forEachLocale(new Runnable() {
|
|
public void run() {
|
|
contains(r, R.string.locale_notification, failures, "$NUM", "$FILTER");
|
|
contains(r, R.string.repeat_detail_byday, failures, "$I", "$D");
|
|
contains(r, R.string.CFC_tag_text, failures, "?");
|
|
contains(r, R.string.CFC_tag_contains_text, failures, "?");
|
|
contains(r, R.string.CFC_title_contains_text, failures, "?");
|
|
contains(r, R.string.CFC_dueBefore_text, failures, "?");
|
|
}
|
|
});
|
|
|
|
assertEquals(failures.toString(), 0,
|
|
failures.toString().replaceAll("[^\n]", "").length());
|
|
}
|
|
}
|