Search in sources :

Example 1 with ResourceDataBroker

use of org.languagetool.databroker.ResourceDataBroker in project languagetool by languagetool-org.

the class Ukrainian method getRuleFileNames.

@Override
public List<String> getRuleFileNames() {
    List<String> ruleFileNames = super.getRuleFileNames();
    ResourceDataBroker dataBroker = JLanguageTool.getDataBroker();
    String dirBase = dataBroker.getRulesDir() + "/" + getShortCode() + "/";
    for (String ruleFile : RULE_FILES) {
        ruleFileNames.add(dirBase + ruleFile);
    }
    return ruleFileNames;
}
Also used : ResourceDataBroker(org.languagetool.databroker.ResourceDataBroker)

Example 2 with ResourceDataBroker

use of org.languagetool.databroker.ResourceDataBroker in project languagetool by languagetool-org.

the class Slovak method getRuleFileNames.

@Override
public List<String> getRuleFileNames() {
    List<String> ruleFileNames = super.getRuleFileNames();
    ResourceDataBroker dataBroker = JLanguageTool.getDataBroker();
    String dirBase = dataBroker.getRulesDir() + "/" + getShortCode() + "/";
    for (String ruleFile : RULE_FILES) {
        ruleFileNames.add(dirBase + ruleFile);
    }
    return ruleFileNames;
}
Also used : ResourceDataBroker(org.languagetool.databroker.ResourceDataBroker)

Example 3 with ResourceDataBroker

use of org.languagetool.databroker.ResourceDataBroker in project languagetool by languagetool-org.

the class PatternRuleTest method skipCountryVariant.

private boolean skipCountryVariant(Language lang) {
    if (Languages.get().get(0).equals(lang)) {
        // test always the first one
        return false;
    }
    ResourceDataBroker dataBroker = JLanguageTool.getDataBroker();
    boolean hasGrammarFiles = false;
    for (String grammarFile : getGrammarFileNames(lang)) {
        if (dataBroker.ruleFileExists(grammarFile)) {
            hasGrammarFiles = true;
        }
    }
    return !hasGrammarFiles && Languages.get().size() > 1;
}
Also used : ResourceDataBroker(org.languagetool.databroker.ResourceDataBroker)

Example 4 with ResourceDataBroker

use of org.languagetool.databroker.ResourceDataBroker in project languagetool by languagetool-org.

the class LanguageComboBoxRenderer method getListCellRendererComponent.

@Override
public Component getListCellRendererComponent(JList list, LanguageAdapter adapter, int index, boolean isSelected, boolean cellHasFocus) {
    setComponentOrientation(list.getComponentOrientation());
    if (isSelected) {
        setBackground(list.getSelectionBackground());
        setForeground(list.getSelectionForeground());
    } else {
        setBackground(list.getBackground());
        setForeground(list.getForeground());
    }
    if (adapter != null) {
        Language lang = adapter.getLanguage();
        if (lang != null) {
            setText(getTranslatedName(lang));
            String langTag = lang.getLocaleWithCountryAndVariant().toLanguageTag();
            String country = lang.getLocaleWithCountryAndVariant().getCountry().toLowerCase();
            ResourceDataBroker dataBroker = JLanguageTool.getDataBroker();
            String filename = "flags/bytag/" + langTag + ".png";
            if (!dataBroker.resourceExists(filename)) {
                filename = "flags/" + country + ".png";
            }
            if (!dataBroker.resourceExists(filename)) {
                filename = "flags/empty.png";
            }
            ImageIcon icon = new ImageIcon(dataBroker.getFromResourceDirAsUrl(filename));
            setIcon(icon);
        } else {
            setText(adapter.getValue());
            setIcon(null);
        }
    }
    setEnabled(list.isEnabled());
    setFont(list.getFont());
    setBorder(BORDER);
    return this;
}
Also used : ImageIcon(javax.swing.ImageIcon) Language(org.languagetool.Language) ResourceDataBroker(org.languagetool.databroker.ResourceDataBroker)

Example 5 with ResourceDataBroker

use of org.languagetool.databroker.ResourceDataBroker in project languagetool by languagetool-org.

the class Language method getRuleFileNames.

/**
   * Get the location of the rule file(s) in a form like {@code /org/languagetool/rules/de/grammar.xml},
   * i.e. a path in the classpath.
   */
public List<String> getRuleFileNames() {
    List<String> ruleFiles = new ArrayList<>();
    ResourceDataBroker dataBroker = JLanguageTool.getDataBroker();
    ruleFiles.add(dataBroker.getRulesDir() + "/" + getShortCode() + "/" + JLanguageTool.PATTERN_FILE);
    if (getShortCodeWithCountryAndVariant().length() > 2) {
        String fileName = getShortCode() + "/" + getShortCodeWithCountryAndVariant() + "/" + JLanguageTool.PATTERN_FILE;
        if (dataBroker.ruleFileExists(fileName)) {
            ruleFiles.add(dataBroker.getRulesDir() + "/" + fileName);
        }
    }
    return ruleFiles;
}
Also used : ResourceDataBroker(org.languagetool.databroker.ResourceDataBroker)

Aggregations

ResourceDataBroker (org.languagetool.databroker.ResourceDataBroker)6 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ImageIcon (javax.swing.ImageIcon)1 Language (org.languagetool.Language)1 ConfusionSetLoader (org.languagetool.rules.ConfusionSetLoader)1