Example #1
0
 public static List<Locale> shownLocales(PhetRequestCycle cycle) {
   String userAgent = cycle.getUserAgent();
   if (userAgent.startsWith(PhetRequestCycle.OFFLINE_USER_AGENT_PREFIX)) {
     List<Locale> result = new ArrayList<Locale>();
     String localeListString =
         userAgent.substring(PhetRequestCycle.OFFLINE_USER_AGENT_PREFIX.length());
     for (String localeString : localeListString.split(",")) {
       if (localeString.contains("activities-")) {
         localeString = localeString.replace("activities-", "");
       }
       try {
         Locale locale = LocaleUtils.stringToLocale(localeString);
         if (PhetWicketApplication.get().isVisibleLocale(locale)) {
           result.add(locale);
         }
       } catch (Exception e) {
         logger.warn(
             "shownLocales failure for user-agent \""
                 + userAgent
                 + "\" and locale string \""
                 + localeString
                 + "\"",
             e);
       }
     }
     return result;
   } else {
     if (!showAnyWebsiteTranslations(cycle)) {
       return Arrays.asList(WebsiteConstants.ENGLISH);
     } else {
       return PhetWicketApplication.get().getAllVisibleTranslationLocales();
     }
   }
 }
Example #2
0
 public static String[] getDistributionServers(PhetRequestCycle cycle) {
   if (cycle.isInstaller()) {
     return new String[] {PhetWicketApplication.get().getWebsiteProperties().getWebHostname()};
   } else {
     return PhetWicketApplication.DATA_SERVERS;
   }
 }