Search in sources :

Example 31 with Language

use of org.omegat.util.Language in project omegat by omegat-org.

the class AlignerTest method testAlignerHeapMode.

@Test
public void testAlignerHeapMode() throws Exception {
    String srcFile = "test/data/align/heapSource.txt";
    Language srcLang = new Language(Locale.ENGLISH);
    String trgFile = "test/data/align/heapTarget.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;
    try {
        aligner.align();
        fail("Parsewise not supported for these files");
    } catch (UnsupportedOperationException ex) {
    }
    aligner.comparisonMode = ComparisonMode.ID;
    try {
        aligner.align();
        fail("ID not supported for these files");
    } catch (UnsupportedOperationException ex) {
    }
}
Also used : Language(org.omegat.util.Language) Test(org.junit.Test)

Example 32 with Language

use of org.omegat.util.Language in project omegat by omegat-org.

the class GlossaryAutoCompleterViewTest method setUp.

@Before
public final void setUp() {
    Core.setProject(new NotLoadedProject() {

        @Override
        public ITokenizer getTargetTokenizer() {
            return new DefaultTokenizer();
        }

        @Override
        public ProjectProperties getProjectProperties() {
            try {
                return new ProjectProperties() {

                    @Override
                    public Language getTargetLanguage() {
                        return new Language(Locale.ENGLISH);
                    }
                };
            } catch (Exception e) {
                return null;
            }
        }
    });
    TestCoreInitializer.initEditor(new IEditor() {

        @Override
        public String getCurrentFile() {
            return null;
        }

        @Override
        public String getCurrentTargetFile() {
            return null;
        }

        @Override
        public SourceTextEntry getCurrentEntry() {
            return null;
        }

        @Override
        public int getCurrentEntryNumber() {
            return 0;
        }

        @Override
        public void activateEntry() {
        }

        @Override
        public void commitAndDeactivate() {
        }

        @Override
        public void commitAndLeave() {
        }

        @Override
        public void nextEntry() {
        }

        @Override
        public void prevEntry() {
        }

        @Override
        public void nextEntryWithNote() {
        }

        @Override
        public void prevEntryWithNote() {
        }

        @Override
        public void nextUntranslatedEntry() {
        }

        @Override
        public void nextTranslatedEntry() {
        }

        @Override
        public void nextUniqueEntry() {
        }

        @Override
        public void gotoFile(int fileIndex) {
        }

        @Override
        public void gotoEntry(int entryNum) {
        }

        @Override
        public void gotoEntry(int entryNum, CaretPosition pos) {
        }

        @Override
        public void gotoEntry(String srcString, EntryKey key) {
        }

        @Override
        public void gotoEntryAfterFix(int fixedEntry, String fixedSource) {
        }

        @Override
        public void refreshViewAfterFix(List<Integer> fixedEntries) {
        }

        @Override
        public void refreshView(boolean doCommit) {
        }

        @Override
        public void requestFocus() {
        }

        @Override
        public void changeCase(CHANGE_CASE_TO newCase) {
        }

        @Override
        public void replaceEditText(String text) {
        }

        @Override
        public void replaceEditTextAndMark(String text) {
        }

        @Override
        public void insertText(String text) {
        }

        @Override
        public void insertTextAndMark(String text) {
        }

        @Override
        public void insertTag(String tag) {
        }

        @Override
        public void gotoHistoryForward() {
        }

        @Override
        public void gotoHistoryBack() {
        }

        @Override
        public IEditorSettings getSettings() {
            return null;
        }

        @Override
        public void undo() {
        }

        @Override
        public void redo() {
        }

        @Override
        public String getSelectedText() {
            return null;
        }

        @Override
        public void setAlternateTranslationForCurrentEntry(boolean alternate) {
        }

        @Override
        public void markActiveEntrySource(SourceTextEntry requiredActiveEntry, List<Mark> marks, String markerClassName) {
        }

        @Override
        public void registerPopupMenuConstructors(int priority, IPopupMenuConstructor constructor) {
        }

        @Override
        public void remarkOneMarker(String markerClassName) {
        }

        @Override
        public IEditorFilter getFilter() {
            return null;
        }

        @Override
        public void setFilter(IEditorFilter filter) {
        }

        @Override
        public void removeFilter() {
        }

        @Override
        public String getCurrentTranslation() {
            return null;
        }

        @Override
        public void windowDeactivated() {
        }

        @Override
        public void registerUntranslated() {
        }

        @Override
        public void registerEmptyTranslation() {
        }

        @Override
        public void registerIdenticalTranslation() {
        }

        @Override
        public IAutoCompleter getAutoCompleter() {
            return null;
        }
    });
    TestCoreInitializer.initGlossary(new IGlossaries() {

        @Override
        public List<GlossaryEntry> getDisplayedEntries() {
            return currentEntries;
        }

        @Override
        public void showCreateGlossaryEntryDialog(Frame parent) {
        }
    });
    currentEntries.clear();
}
Also used : IEditor(org.omegat.gui.editor.IEditor) Frame(java.awt.Frame) DefaultTokenizer(org.omegat.tokenizer.DefaultTokenizer) Mark(org.omegat.gui.editor.mark.Mark) ITokenizer(org.omegat.tokenizer.ITokenizer) Language(org.omegat.util.Language) SourceTextEntry(org.omegat.core.data.SourceTextEntry) ArrayList(java.util.ArrayList) List(java.util.List) IAutoCompleter(org.omegat.gui.editor.autocompleter.IAutoCompleter) EntryKey(org.omegat.core.data.EntryKey) IEditorFilter(org.omegat.gui.editor.IEditorFilter) IPopupMenuConstructor(org.omegat.gui.editor.IPopupMenuConstructor) IEditorSettings(org.omegat.gui.editor.IEditorSettings) ProjectProperties(org.omegat.core.data.ProjectProperties) NotLoadedProject(org.omegat.core.data.NotLoadedProject) Before(org.junit.Before)

Example 33 with Language

use of org.omegat.util.Language in project omegat by omegat-org.

the class GlossaryReaderTBXTest method testRead.

@Test
public void testRead() throws Exception {
    Core.setProject(new NotLoadedProject() {

        public ProjectProperties getProjectProperties() {
            try {
                return new ProjectProperties(new File("stub")) {

                    @Override
                    public Language getSourceLanguage() {
                        return new Language("en");
                    }

                    @Override
                    public Language getTargetLanguage() {
                        return new Language("hu");
                    }
                };
            } catch (Exception ex) {
                throw new RuntimeException(ex);
            }
        }
    });
    List<GlossaryEntry> g = GlossaryReaderTBX.read(new File("test/data/glossaries/sampleTBXfile.tbx"), false);
    assertEquals(1, g.size());
    assertEquals("alpha smoothing factor", g.get(0).getSrcText());
    assertEquals("hu translation", g.get(0).getLocText());
}
Also used : Language(org.omegat.util.Language) NotLoadedProject(org.omegat.core.data.NotLoadedProject) ProjectProperties(org.omegat.core.data.ProjectProperties) File(java.io.File) Test(org.junit.Test)

Example 34 with Language

use of org.omegat.util.Language in project omegat by omegat-org.

the class BundleTest method testBundleEncodings.

/**
 * Ensure that all UI string bundles have either US-ASCII encoding or ISO-8859-1 encoding. The spec requires the
 * latter, but ISO-8859-1 is a superset of ASCII so ASCII is also acceptable (and is widely used in practice).
 *
 * @see <a href=
 *      "https://docs.oracle.com/javase/8/docs/api/java/util/PropertyResourceBundle.html">PropertyResourceBundle</a>
 */
@Test
public void testBundleEncodings() throws Exception {
    // Test English bundle separately as its name corresponds to the
    // empty locale, and will not be resolved otherwise.
    assertEncoding("Bundle.properties");
    for (Language lang : Language.getLanguages()) {
        String bundle = "Bundle_" + lang.getLocaleCode() + ".properties";
        assertEncoding(bundle);
    }
}
Also used : Language(org.omegat.util.Language) Test(org.junit.Test)

Example 35 with Language

use of org.omegat.util.Language in project omegat by omegat-org.

the class BundleTest method testBundleLoading.

@Test
public void testBundleLoading() {
    // We must set the default locale to English first because we provide our
    // English bundle as the empty-locale default. If we don't do so, the
    // English bundle will never be tested in the case that the "default default"
    // is a language we provide a bundle for.
    Locale.setDefault(Locale.ENGLISH);
    for (Language lang : Language.getLanguages()) {
        ResourceBundle bundle = ResourceBundle.getBundle("org/omegat/Bundle", lang.getLocale());
        assertTrue(bundle.getKeys().hasMoreElements());
    }
}
Also used : Language(org.omegat.util.Language) ResourceBundle(java.util.ResourceBundle) Test(org.junit.Test)

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