use of org.omegat.util.Language in project omegat by omegat-org.
the class XHTMLFilterTest method testTranslate.
@Test
public void testTranslate() throws Exception {
String f = "test/data/filters/xhtml/file-XHTMLFilter.html";
XHTMLFilter filter = new XHTMLFilter();
filter.isFileSupported(new File(f), new TreeMap<String, String>(), new FilterContext(new Language("en"), new Language("be"), false));
translateXML(filter, f);
}
use of org.omegat.util.Language in project omegat by omegat-org.
the class XHTMLFilterTest method testParse.
@Test
public void testParse() throws Exception {
String f = "test/data/filters/xhtml/file-XHTMLFilter.html";
XHTMLFilter filter = new XHTMLFilter();
filter.isFileSupported(new File(f), new TreeMap<String, String>(), new FilterContext(new Language("en"), new Language("be"), false));
parse(filter, f);
}
use of org.omegat.util.Language in project omegat by omegat-org.
the class AlignerTest method testAlignerIDMode.
@Test
public void testAlignerIDMode() throws Exception {
String srcFile = "test/data/align/idSource.properties";
Language srcLang = new Language(Locale.ENGLISH);
String trgFile = "test/data/align/idTarget.properties";
Language trgLang = new Language(Locale.JAPANESE);
Aligner aligner = new Aligner(srcFile, srcLang, trgFile, trgLang);
// Aligner will default to ID alignment when possible, so load and then change mode.
aligner.loadFiles();
aligner.comparisonMode = ComparisonMode.HEAPWISE;
assertHeapResult(aligner.align());
aligner.comparisonMode = ComparisonMode.PARSEWISE;
try {
aligner.align();
fail("Parsewise mode not available for these files.");
} catch (UnsupportedOperationException ex) {
}
aligner.comparisonMode = ComparisonMode.ID;
List<Entry<String, String>> result = aligner.align();
assertEquals(4, result.size());
assertEntry("This is sentence one.", "\u3053\u308C\u304C1\u3064\u76EE\u306E\u30BB\u30F3\u30C6\u30F3\u30B9\u3002", result.get(0));
assertEntry("Short sentence.", "\u77ED\u3044\u6587\u3002", result.get(1));
assertEntry("And then this is a very, very, very long sentence.", "\u7D9A\u3044\u3066\u306F\u3068\u3066\u3082\u9577\u304F\u3066\u306A\u304C\u301C\u3044\u9577" + "\u86C7\u306E\u602A\u7269\u30BB\u30F3\u30C6\u30F3\u30B9\u3060\u304C\u3001\u3044" + "\u3064\u7D42\u308F\u308B\u306E\u3060\u308D\u3046\u304B\uFF1F", result.get(2));
assertEntry("Where shall it end?", "\u8AB0\u3082\u77E5\u3089\u306A\u3044\u3002", result.get(3));
// Key5 in source has no counterpart in target so it is dropped.
}
use of org.omegat.util.Language in project omegat by omegat-org.
the class AlignerTest method testAlignerParseMode.
@Test
public void testAlignerParseMode() throws Exception {
String srcFile = "test/data/align/parseSource.txt";
Language srcLang = new Language(Locale.ENGLISH);
String trgFile = "test/data/align/parseTarget.txt";
Language trgLang = new Language(Locale.JAPANESE);
Aligner aligner = new Aligner(srcFile, srcLang, trgFile, trgLang);
aligner.comparisonMode = ComparisonMode.HEAPWISE;
assertHeapResult(aligner.align());
aligner.comparisonMode = ComparisonMode.PARSEWISE;
List<Entry<String, String>> result = aligner.align();
assertEquals(4, result.size());
assertEntry("This is sentence one.", "\u3053\u308C\u304C1\u3064\u76EE\u306E\u30BB\u30F3\u30C6\u30F3\u30B9\u3002", result.get(0));
assertEntry("Short sentence.", "\u77ED\u3044\u6587\u3002", result.get(1));
assertEntry("And then this is a very, very, very long sentence.", "\u7D9A\u3044\u3066\u306F\u3068\u3066\u3082\u9577\u304F\u3066\u306A\u304C\u301C\u3044\u9577" + "\u86C7\u306E\u602A\u7269\u30BB\u30F3\u30C6\u30F3\u30B9\u3060\u304C\u3001\u3044" + "\u3064\u7D42\u308F\u308B\u306E\u3060\u308D\u3046\u304B\uFF1F", result.get(2));
assertEntry("Where shall it end? No one knows.", "\u8AB0\u3082\u77E5\u3089\u306A\u3044\u3002", result.get(3));
aligner.comparisonMode = ComparisonMode.ID;
try {
aligner.align();
fail("ID not supported for these files");
} catch (UnsupportedOperationException ex) {
}
}
use of org.omegat.util.Language in project omegat by omegat-org.
the class FalseFriendsTest method setUp.
@Before
public final void setUp() {
final ProjectProperties props = new ProjectProperties() {
public Language getSourceLanguage() {
return new Language("en");
}
public Language getTargetLanguage() {
return new Language("pl");
}
};
Core.setProject(new IProject() {
public void setTranslation(SourceTextEntry entry, PrepareTMXEntry trans, boolean defaultTranslation, TMXEntry.ExternalLinked externalLinked) {
}
public void setTranslation(SourceTextEntry entry, PrepareTMXEntry trans, boolean defaultTranslation, ExternalLinked externalLinked, AllTranslations previousTranslations) throws OptimisticLockingFail {
}
public void setNote(SourceTextEntry entry, TMXEntry oldTrans, String note) {
}
public void saveProjectProperties() throws Exception {
}
public void saveProject(boolean doTeamSync) {
}
public void iterateByMultipleTranslations(MultipleTranslationsIterator it) {
}
public void iterateByDefaultTranslations(DefaultTranslationsIterator it) {
}
public boolean isProjectModified() {
return false;
}
public boolean isProjectLoaded() {
return true;
}
public boolean isOrphaned(EntryKey entry) {
return false;
}
public boolean isOrphaned(String source) {
return false;
}
public TMXEntry getTranslationInfo(SourceTextEntry ste) {
return null;
}
public AllTranslations getAllTranslations(SourceTextEntry ste) {
return null;
}
public Map<String, ExternalTMX> getTransMemories() {
return null;
}
public ITokenizer getTargetTokenizer() {
return null;
}
public StatisticsInfo getStatistics() {
return null;
}
public ITokenizer getSourceTokenizer() {
return null;
}
public ProjectProperties getProjectProperties() {
return props;
}
public List<FileInfo> getProjectFiles() {
return null;
}
public Map<Language, ProjectTMX> getOtherTargetLanguageTMs() {
return null;
}
public List<SourceTextEntry> getAllEntries() {
return null;
}
public void compileProject(String sourcePattern) throws Exception {
}
public void closeProject() {
}
public List<String> getSourceFilesOrder() {
return null;
}
public void setSourceFilesOrder(List<String> filesList) {
}
@Override
public String getTargetPathForSourceFile(String sourceFile) {
return null;
}
@Override
public boolean isTeamSyncPrepared() {
return false;
}
@Override
public void teamSync() {
}
@Override
public void teamSyncPrepare() throws Exception {
}
@Override
public boolean isRemoteProject() {
return false;
}
@Override
public void commitSourceFiles() throws Exception {
}
@Override
public void compileProjectAndCommit(String sourcePattern, boolean doPostProcessing, boolean commitTargetFiles) throws Exception {
}
});
LanguageToolWrapper.setBridgeFromCurrentProject();
}
Aggregations