Exemplo n.º 1
0
  private void initTranslatoins() {
    Dictionary dict = TM.getDictionary();

    try {
      dict.loadWords(
          "en", "us", TPTLazyLoadingLayout.class.getResource("i18n/en_us.properties"), false);
      dict.loadWords(
          "ru", "ru", TPTLazyLoadingLayout.class.getResource("i18n/ru_ru.properties"), false);
    } catch (IOException io) {
      // no-op
    }
  }
Exemplo n.º 2
0
  /**
   * This method cleanups resources from previous app instance. When Vaadin app is created using CDI
   * injection, http session does not die after app.close() which results the same application
   * instance to be used for the next application.
   */
  private void cleanupPreviousResources() {
    // Remove all old windows, if any
    Collection<Window> oldWindows = getWindows();
    for (Window w : oldWindows) {
      removeWindow(w);
    }

    // Remove all i18n data
    if (internationalizationDictionary != null) {
      internationalizationDictionary.clear();
    }
  }
Exemplo n.º 3
0
  /** Loads property files with translations from the theme-name/i18n folder (if exists) */
  private void loadInternationalizationFiles() {
    Collection<File> themes = ThemeUtils.discoverThemesHierarchyOfTheme(getContext(), getTheme());

    for (File themeFolder : themes) {
      if (themeFolder.exists() && themeFolder.isDirectory()) {
        try {
          internationalizationDictionary.loadTranslationFilesFromThemeFolder(themeFolder);
        } catch (IOException e) {
          System.err.println(
              String.format(
                  "Cannot load translation files from the theme folder %s : %s",
                  themeFolder, e.getMessage()));
        }
      }
    }
  }