Search in sources :

Example 11 with Language

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);
}
Also used : XHTMLFilter(org.omegat.filters3.xml.xhtml.XHTMLFilter) Language(org.omegat.util.Language) File(java.io.File) FilterContext(org.omegat.filters2.FilterContext) Test(org.junit.Test)

Example 12 with Language

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);
}
Also used : XHTMLFilter(org.omegat.filters3.xml.xhtml.XHTMLFilter) Language(org.omegat.util.Language) File(java.io.File) FilterContext(org.omegat.filters2.FilterContext) Test(org.junit.Test)

Example 13 with Language

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.
}
Also used : Entry(java.util.Map.Entry) Language(org.omegat.util.Language) Test(org.junit.Test)

Example 14 with Language

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) {
    }
}
Also used : Entry(java.util.Map.Entry) Language(org.omegat.util.Language) Test(org.junit.Test)

Example 15 with Language

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();
}
Also used : ExternalLinked(org.omegat.core.data.TMXEntry.ExternalLinked) EntryKey(org.omegat.core.data.EntryKey) StatisticsInfo(org.omegat.core.statistics.StatisticsInfo) ProjectProperties(org.omegat.core.data.ProjectProperties) IProject(org.omegat.core.data.IProject) ExternalLinked(org.omegat.core.data.TMXEntry.ExternalLinked) ITokenizer(org.omegat.tokenizer.ITokenizer) Language(org.omegat.util.Language) SourceTextEntry(org.omegat.core.data.SourceTextEntry) List(java.util.List) PrepareTMXEntry(org.omegat.core.data.PrepareTMXEntry) Map(java.util.Map) PrepareTMXEntry(org.omegat.core.data.PrepareTMXEntry) TMXEntry(org.omegat.core.data.TMXEntry) Before(org.junit.Before)

Aggregations

Language (org.omegat.util.Language)43 Test (org.junit.Test)16 File (java.io.File)13 ArrayList (java.util.ArrayList)13 Map (java.util.Map)7 FilterContext (org.omegat.filters2.FilterContext)7 List (java.util.List)6 IProject (org.omegat.core.data.IProject)6 SourceTextEntry (org.omegat.core.data.SourceTextEntry)5 HashMap (java.util.HashMap)4 Before (org.junit.Before)4 EntryKey (org.omegat.core.data.EntryKey)4 ProjectTMX (org.omegat.core.data.ProjectTMX)4 TMXEntry (org.omegat.core.data.TMXEntry)4 XHTMLFilter (org.omegat.filters3.xml.xhtml.XHTMLFilter)4 DefaultTokenizer (org.omegat.tokenizer.DefaultTokenizer)4 ITokenizer (org.omegat.tokenizer.ITokenizer)4 IOException (java.io.IOException)3 Files (java.nio.file.Files)3 Matcher (java.util.regex.Matcher)3