@Override public void afterCheckProject(@NonNull Context context) { if (context.getPhase() == 1) { // NOTE - this will look for the presence of translation strings. // If you create a resource folder but don't actually place a file in it // we won't detect that, but it seems like a smaller problem. checkTranslations(context); mFileToNames = null; if (mMissingLocations != null || mExtraLocations != null) { context.getDriver().requestRepeat(this, Scope.ALL_RESOURCES_SCOPE); } } else { assert context.getPhase() == 2; reportMap(context, MISSING, mMissingLocations); reportMap(context, EXTRA, mExtraLocations); mMissingLocations = null; mExtraLocations = null; mDescriptions = null; } }
public List<Resource> findUnused(List<Resource> resources) { List<Resource> roots = findRoots(resources); Map<Resource,Boolean> seen = new IdentityHashMap<>(resources.size()); for (Resource root : roots) { visit(root, seen); } List<Resource> unused = Lists.newArrayListWithExpectedSize(resources.size()); for (Resource resource : resources) { if (!resource.isReachable() // Styles not yet handled correctly: don't mark as unused && resource.type != ResourceType.ATTR && resource.type != ResourceType.DECLARE_STYLEABLE && resource.type != ResourceType.STYLEABLE // Don't flag known service keys read by library && !TranslationDetector.isServiceKey(resource.name)) { unused.add(resource); } } return unused; }
String language = getLanguageTag(name); if (language == null) { language = defaultLanguage; List<String> resConfigLanguages = getResConfigLanguages(context.getMainProject()); if (resConfigLanguages != null) { List<String> keys = Lists.newArrayList(languageToStrings.keySet()); if (message == null) { message = String.format("\"`%1$s`\" is not translated in %2$s", s, getLanguageDescription(language)); } else { message = message + ", " + getLanguageDescription(language);
String language = getLanguageTag(context.file.getParentFile().getName()); if (language == null) { if (context.getDriver().isSuppressed(context, MISSING, element)) { String language = getLanguageTag(context.file.getParentFile().getName()); if (language != null) { if (context.getDriver().isSuppressed(context, EXTRA, element)) { } else if (isServiceKey(name) allItemsAreReferences(element)) {
String language = getLanguageTag(context.file.getParentFile().getName()); if (language == null) { if (context.getDriver().isSuppressed(context, MISSING, element)) { String language = getLanguageTag(context.file.getParentFile().getName()); if (language != null) { if (context.getDriver().isSuppressed(context, EXTRA, element)) { allItemsAreReferences(element)) {
@Override public void afterCheckProject(Context context) { // NOTE - this will look for the presence of translation strings. // If you create a resource folder but don't actually place a file in it // we won't detect that, but it seems like a smaller problem. checkTranslations(context); mFileToNames = null; }
@Nullable private static List<String> getResConfigLanguages(@NonNull Project project) { if (project.isGradleProject() && project.getGradleProjectModel() != null && project.getCurrentVariant() != null) { Set<String> relevantDensities = Sets.newHashSet(); Variant variant = project.getCurrentVariant(); List<String> variantFlavors = variant.getProductFlavors(); AndroidProject gradleProjectModel = project.getGradleProjectModel(); addResConfigsFromFlavor(relevantDensities, null, project.getGradleProjectModel().getDefaultConfig()); for (ProductFlavorContainer container : gradleProjectModel.getProductFlavors()) { addResConfigsFromFlavor(relevantDensities, variantFlavors, container); } if (!relevantDensities.isEmpty()) { ArrayList<String> strings = Lists.newArrayList(relevantDensities); Collections.sort(strings); return strings; } } return null; }
String message = String.format( "For locale %1$s the following quantities should also be defined: %2$s", TranslationDetector.getLanguageDescription(language), Quantity.formatSet(missing)); context.report(MISSING, element, context.getLocation(element), message); String message = String.format( "For language %1$s the following quantities are not relevant: %2$s", TranslationDetector.getLanguageDescription(language), Quantity.formatSet(extra)); context.report(EXTRA, element, context.getLocation(element), message);
List<String> sorted = new ArrayList<String>(difference); Collections.sort(sorted); Location location = getLocation(language, parentFolderToLanguage); context.client.report(context, MISSING, location, String.format("Locale %1$s is missing translations for: %2$s", List<String> sorted = new ArrayList<String>(difference); Collections.sort(sorted); Location location = getLocation(language, parentFolderToLanguage); context.client.report(context, EXTRA, location, String.format( "Locale %1$s is translating names not found in default locale: %2$s",
String language = getLanguageTag(name); if (language == null) { language = defaultLanguage; List<String> resConfigLanguages = getResConfigLanguages(context.getMainProject()); if (resConfigLanguages != null) { List<String> keys = Lists.newArrayList(languageToStrings.keySet()); if (message == null) { message = String.format("\"`%1$s`\" is not translated in %2$s", s, getLanguageDescription(language)); } else { message = message + ", " + getLanguageDescription(language);
@Nullable private static List<String> getResConfigLanguages(@NonNull Project project) { if (project.isGradleProject() && project.getGradleProjectModel() != null && project.getCurrentVariant() != null) { Set<String> relevantDensities = Sets.newHashSet(); Variant variant = project.getCurrentVariant(); List<String> variantFlavors = variant.getProductFlavors(); AndroidProject gradleProjectModel = project.getGradleProjectModel(); addResConfigsFromFlavor(relevantDensities, null, project.getGradleProjectModel().getDefaultConfig()); for (ProductFlavorContainer container : gradleProjectModel.getProductFlavors()) { addResConfigsFromFlavor(relevantDensities, variantFlavors, container); } if (!relevantDensities.isEmpty()) { ArrayList<String> strings = Lists.newArrayList(relevantDensities); Collections.sort(strings); return strings; } } return null; }
String message = String.format( "For locale %1$s the following quantities should also be defined: %2$s", TranslationDetector.getLanguageDescription(language), Quantity.formatSet(missing)); context.report(MISSING, element, context.getLocation(element), message); String message = String.format( "For language %1$s the following quantities are not relevant: %2$s", TranslationDetector.getLanguageDescription(language), Quantity.formatSet(extra)); context.report(EXTRA, element, context.getLocation(element), message);
@Override public void afterCheckProject(@NonNull Context context) { if (context.getPhase() == 1) { // NOTE - this will look for the presence of translation strings. // If you create a resource folder but don't actually place a file in it // we won't detect that, but it seems like a smaller problem. checkTranslations(context); mFileToNames = null; if (mMissingLocations != null || mExtraLocations != null) { context.getDriver().requestRepeat(this, Scope.ALL_RESOURCES_SCOPE); } } else { assert context.getPhase() == 2; reportMap(context, MISSING, mMissingLocations); reportMap(context, EXTRA, mExtraLocations); mMissingLocations = null; mExtraLocations = null; mDescriptions = null; } }
if (TranslationDetector.isServiceKey(name)) { return;