use of org.omegat.util.Language in project omegat by omegat-org.
the class BrowseTaasCollectionsController method show.
public static void show() {
dialog = new BrowseTaasCollectionsUI(Core.getMainWindow().getApplicationFrame(), true);
final Language sourceLang = Core.getProject().getProjectProperties().getSourceLanguage();
final Language targetLang = Core.getProject().getProjectProperties().getTargetLanguage();
List<TaasCollection> list = Collections.emptyList();
CollectionsTable model = new CollectionsTable(list, sourceLang, targetLang);
dialog.tableCollections.setModel(model);
dialog.tableCollections.setColumnModel(createColumnModel());
dialog.labelStatus.setText(OStrings.getString("TAAS_STATUS_LIST"));
new SwingWorker<List<TaasCollection>, Void>() {
@Override
protected List<TaasCollection> doInBackground() throws Exception {
return TaaSPlugin.getClient().getCollectionsList();
}
@Override
protected void done() {
try {
List<TaasCollection> list = get();
removeUnusedCollections(list);
CollectionsTable model = new CollectionsTable(list, sourceLang, targetLang);
dialog.tableCollections.setModel(model);
TableRowSorter<CollectionsTable> sorter = new TableRowSorter<CollectionsTable>(model);
dialog.tableCollections.setRowSorter(sorter);
sorter.setSortKeys(Arrays.asList(new RowSorter.SortKey(0, SortOrder.ASCENDING)));
dialog.tableCollections.setColumnModel(createColumnModel());
dialog.labelStatus.setText(" ");
} catch (ExecutionException e) {
Throwable ex = e.getCause();
if (ex instanceof TaaSClient.FormatError) {
Log.logErrorRB(ex, "TAAS_FORMAT_ERROR", ex.getMessage());
dialog.labelStatus.setText(OStrings.getString("TAAS_FORMAT_ERROR"));
} else if (ex instanceof TaaSClient.Unauthorized) {
Log.logErrorRB(ex, "TAAS_UNAUTHORIZED_ERROR");
dialog.labelStatus.setText(OStrings.getString("TAAS_UNAUTHORIZED_ERROR"));
} else {
Log.logErrorRB(ex, "TAAS_GENERAL_ERROR", ex.getMessage());
dialog.labelStatus.setText(MessageFormat.format(OStrings.getString("TAAS_GENERAL_ERROR"), ex.getMessage()));
}
} catch (InterruptedException ex) {
}
}
}.execute();
dialog.btnDownload.addActionListener(DOWNLOAD_LISTENER);
StaticUIUtils.setEscapeClosable(dialog);
dialog.btnClose.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dialog.dispose();
}
});
dialog.setLocationRelativeTo(Core.getMainWindow().getApplicationFrame());
dialog.setVisible(true);
}
use of org.omegat.util.Language in project omegat by omegat-org.
the class BrowseTaasCollectionsController method removeUnusedCollections.
/**
* Removes collections with zero terms count.
*/
static void removeUnusedCollections(List<TaasCollection> list) {
final Language sourceLang = Core.getProject().getProjectProperties().getSourceLanguage();
final Language targetLang = Core.getProject().getProjectProperties().getTargetLanguage();
for (int i = 0; i < list.size(); i++) {
TaasCollection c = list.get(i);
if (getCountForLanguage(c, sourceLang) == 0 || getCountForLanguage(c, targetLang) == 0) {
list.remove(i);
i--;
}
}
}
use of org.omegat.util.Language in project omegat by omegat-org.
the class MainWindowMenuHandler method toolsAlignFilesMenuItemActionPerformed.
public void toolsAlignFilesMenuItemActionPerformed() {
AlignFilePickerController picker = new AlignFilePickerController();
if (Core.getProject().isProjectLoaded()) {
String srcRoot = Core.getProject().getProjectProperties().getSourceRoot();
String curFile = Core.getEditor().getCurrentFile();
if (curFile != null) {
picker.setSourceFile(srcRoot + curFile);
}
picker.setSourceDefaultDir(srcRoot);
picker.setDefaultSaveDir(Core.getProject().getProjectProperties().getTMRoot());
picker.setSourceLanguage(Core.getProject().getProjectProperties().getSourceLanguage());
picker.setTargetLanguage(Core.getProject().getProjectProperties().getTargetLanguage());
} else {
String srcLang = Preferences.getPreference(Preferences.SOURCE_LOCALE);
if (!StringUtil.isEmpty(srcLang)) {
picker.setSourceLanguage(new Language(srcLang));
}
String trgLang = Preferences.getPreference(Preferences.TARGET_LOCALE);
if (!StringUtil.isEmpty(trgLang)) {
picker.setTargetLanguage(new Language(trgLang));
}
}
picker.show(mainWindow);
}
use of org.omegat.util.Language in project omegat by omegat-org.
the class DictionariesManagerTest method setUp.
@Before
public final void setUp() throws Exception {
manager = new DictionariesManager(new IDictionaries() {
@Override
public void refresh() {
}
@Override
public void addDictionaryFactory(IDictionaryFactory factory) {
}
@Override
public void removeDictionaryFactory(IDictionaryFactory factory) {
}
}) {
@Override
protected boolean doFuzzyMatching() {
return true;
}
};
manager.setIndexLanguage(new Language(Locale.ENGLISH));
manager.setTokenizer(new DefaultTokenizer());
PrintWriter fw = new PrintWriter(IGNORE_FILE, "UTF-8");
fw.println(IGNORE_WORD);
fw.close();
assertFalse(fw.checkError());
}
use of org.omegat.util.Language in project omegat by omegat-org.
the class SegmenterTest method testGlue.
/**
* Test of glue method, of class org.omegat.core.segmentation.Segmenter.
*/
@Test
public void testGlue() {
List<StringBuilder> spaces = new ArrayList<StringBuilder>();
List<Rule> brules = new ArrayList<Rule>();
String oldString = "<br7>\n\n<br5>\n\nother";
List<String> segments = segmenter.segment(new Language("en"), oldString, spaces, brules);
String newString = segmenter.glue(new Language("en"), new Language("fr"), segments, spaces, brules);
assertEquals(oldString, newString);
}
Aggregations