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

Commit

Permalink
Fix suggest locale only limit to supported and enabled by default list
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed Nov 22, 2013
1 parent 2bdea09 commit dd2dc58
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 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.getSupportedAndEnabledByDefaultLocales();
}

Collection<HLocale> filtered =
Expand Down Expand Up @@ -211,7 +212,7 @@ public void addLanguage() {
/**
* Use FlashScopeBean to store message in page. Multiple ajax requests for
* re-rendering statistics after updating will clear FacesMessages.
*
*
* @param severity
* @param message
*/
Expand Down Expand Up @@ -370,7 +371,7 @@ public boolean validateLanguageName(String componentId) {
}

// check if locale enabled in server
if (!localeServiceImpl.localeSupported(localeId)) {
if (!localeServiceImpl.localeSupportedAndEnabledByDefault(localeId)) {
FacesMessages.instance().addToControl(
componentId,
zanataMessages
Expand Down
Expand Up @@ -48,6 +48,8 @@ public interface LocaleService {

List<HLocale> getSupportedLocales();

List<HLocale> getSupportedAndEnabledByDefaultLocales();

HLocale getByLocaleId(@Nonnull LocaleId locale);

HLocale getByLocaleId(@Nonnull String localeId);
Expand Down Expand Up @@ -92,4 +94,6 @@ Map<String, String> getIterationCustomizedLocalesItems(String projectSlug,

HTextFlowTarget getLastTranslated(String projectSlug, String iterationSlug,
LocaleId localeId);

boolean localeSupportedAndEnabledByDefault(@Nonnull LocaleId locale);
}
Expand Up @@ -53,7 +53,7 @@

/**
* This implementation provides all the business logic related to Locale.
*
*
*/
@Name("localeServiceImpl")
@Scope(ScopeType.STATELESS)
Expand Down Expand Up @@ -174,6 +174,18 @@ public List<HLocale> getSupportedLocales() {
return localeDAO.findAllActive();
}

@Override
public List<HLocale> getSupportedAndEnabledByDefaultLocales() {
return localeDAO.findAllActiveAndEnabledByDefault();
}

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

@Override
public boolean localeSupported(@Nonnull LocaleId locale) {
HLocale entity = localeDAO.findByLocaleId(locale);
Expand Down

0 comments on commit dd2dc58

Please sign in to comment.