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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations