Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Include checking of locale not enabled by default when looking for mi…
Browse files Browse the repository at this point in the history
…ssing locale in version
  • Loading branch information
Alex Eng committed Nov 22, 2013
1 parent 875628a commit 706d137
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
Expand Up @@ -167,7 +167,8 @@ public void setStatus(char initial) {

public List<HLocale> suggestLocales(final String query) {
if (supportedLocales == null) {
supportedLocales = localeServiceImpl.getSupportedLocales();
supportedLocales =
localeServiceImpl.getSupportedLocales();
}

Collection<HLocale> filtered =
Expand Down
Expand Up @@ -46,6 +46,8 @@ public interface LocaleService {

boolean localeSupported(@Nonnull LocaleId locale);

boolean localeEnabledByDefault(@Nonnull LocaleId locale);

List<HLocale> getSupportedLocales();

HLocale getByLocaleId(@Nonnull LocaleId locale);
Expand Down
Expand Up @@ -180,6 +180,12 @@ public boolean localeSupported(@Nonnull LocaleId locale) {
return entity != null && entity.isActive();
}

@Override
public boolean localeEnabledByDefault(@Nonnull LocaleId locale) {
HLocale entity = localeDAO.findByLocaleId(locale);
return entity != null && entity.isEnabledByDefault();
}

@Override
public @Nonnull
HLocale validateLocaleByProject(@Nonnull LocaleId locale,
Expand Down
Expand Up @@ -35,6 +35,7 @@
import org.zanata.model.HLocale;
import org.zanata.model.HPerson;
import org.zanata.model.HProjectIteration;
import org.zanata.service.LocaleService;
import org.zanata.service.VersionGroupService;
import org.zanata.service.VersionLocaleKey;
import org.zanata.service.VersionStateCache;
Expand All @@ -61,6 +62,9 @@ public class VersionGroupServiceImpl implements VersionGroupService {
@In
private VersionStateCache versionStateCacheImpl;

@In
private LocaleService localeServiceImpl;

@Override
public Map<VersionLocaleKey, WordStatistic> getLocaleStatistic(
String groupSlug, LocaleId localeId) {
Expand Down Expand Up @@ -170,7 +174,8 @@ public Map<LocaleId, List<HProjectIteration>> getMissingLocaleVersionMap(
for (HLocale activeLocale : group.getActiveLocales()) {
List<HProjectIteration> versionList = Lists.newArrayList();
for (HProjectIteration version : group.getProjectIterations()) {
if (!isLocaleActivatedInVersion(version, activeLocale)) {
if (!isLocaleActivatedInVersion(version, activeLocale)
&& !isLocaleEnabledByDefault(activeLocale)) {
versionList.add(version);
}
}
Expand Down Expand Up @@ -206,4 +211,8 @@ private boolean isLocaleActivatedInVersion(HProjectIteration version,
}
return true; // no overrides of locales from version or it's project
}

private boolean isLocaleEnabledByDefault(HLocale locale) {
return localeServiceImpl.localeEnabledByDefault(locale.getLocaleId());
}
}

0 comments on commit 706d137

Please sign in to comment.