コード例 #1
0
def test_get_catalogs_for_xx_without_outdated(dir):
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES').makedirs()
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'test1.po').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'test1.mo').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'test2.po').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'test2.mo').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'test3.pot').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'test3.mo').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'sub').makedirs()
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'sub' / 'test4.po').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'sub' / 'test4.mo').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'sub' / 'test5.po').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'sub' / 'test5.mo').write_text('#')

    catalogs = i18n.get_catalogs([dir / 'loc1'], 'xx', force_all=False)
    assert not catalogs

    catalogs = i18n.get_catalogs([dir / 'loc1'], 'xx', force_all=True)
    domains = set(c.domain for c in catalogs)
    assert domains == set([
        'test1',
        'test2',
        path.normpath('sub/test4'),
        path.normpath('sub/test5'),
    ])
コード例 #2
0
ファイル: test_util_i18n.py プロジェクト: tu44okawa3/sphinx
def test_get_catalogs_for_xx_without_outdated(dir):
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES').makedirs()
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'test1.po').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'test1.mo').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'test2.po').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'test2.mo').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'test3.pot').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'test3.mo').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'sub').makedirs()
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'sub' / 'test4.po').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'sub' / 'test4.mo').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'sub' / 'test5.po').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'sub' / 'test5.mo').write_text('#')

    catalogs = i18n.get_catalogs([dir / 'loc1'], 'xx', force_all=False)
    assert not catalogs

    catalogs = i18n.get_catalogs([dir / 'loc1'], 'xx', force_all=True)
    domains = set(c.domain for c in catalogs)
    assert domains == set([
        'test1',
        'test2',
        path.normpath('sub/test4'),
        path.normpath('sub/test5'),
    ])
コード例 #3
0
ファイル: __init__.py プロジェクト: tu44okawa3/sphinx
 def compile_update_catalogs(self):
     catalogs = i18n.get_catalogs(
         [path.join(self.srcdir, x) for x in self.config.locale_dirs],
         self.config.language)
     message = 'targets for %d po files that are out of date' % len(
         catalogs)
     self.compile_catalogs(catalogs, message)
コード例 #4
0
ファイル: test_util_i18n.py プロジェクト: tu44okawa3/sphinx
def test_get_catalogs_for_en(dir):
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES').makedirs()
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'xx_dom.po').write_text('#')
    (dir / 'loc1' / 'en' / 'LC_MESSAGES').makedirs()
    (dir / 'loc1' / 'en' / 'LC_MESSAGES' / 'en_dom.po').write_text('#')

    catalogs = i18n.get_catalogs([dir / 'loc1'], 'en', force_all=False)
    domains = set(c.domain for c in catalogs)
    assert domains == set(['en_dom'])
コード例 #5
0
def test_get_catalogs_for_en(dir):
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES').makedirs()
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'xx_dom.po').write_text('#')
    (dir / 'loc1' / 'en' / 'LC_MESSAGES').makedirs()
    (dir / 'loc1' / 'en' / 'LC_MESSAGES' / 'en_dom.po').write_text('#')

    catalogs = i18n.get_catalogs([dir / 'loc1'], 'en', force_all=False)
    domains = set(c.domain for c in catalogs)
    assert domains == set(['en_dom'])
コード例 #6
0
def test_get_catalogs_from_multiple_locale_dirs(dir):
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES').makedirs()
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'test1.po').write_text('#')
    (dir / 'loc2' / 'xx' / 'LC_MESSAGES').makedirs()
    (dir / 'loc2' / 'xx' / 'LC_MESSAGES' / 'test1.po').write_text('#')
    (dir / 'loc2' / 'xx' / 'LC_MESSAGES' / 'test2.po').write_text('#')

    catalogs = i18n.get_catalogs([dir / 'loc1', dir / 'loc2'], 'xx')
    domains = sorted(c.domain for c in catalogs)
    assert domains == ['test1', 'test1', 'test2']
コード例 #7
0
ファイル: test_util_i18n.py プロジェクト: tu44okawa3/sphinx
def test_get_catalogs_from_multiple_locale_dirs(dir):
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES').makedirs()
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'test1.po').write_text('#')
    (dir / 'loc2' / 'xx' / 'LC_MESSAGES').makedirs()
    (dir / 'loc2' / 'xx' / 'LC_MESSAGES' / 'test1.po').write_text('#')
    (dir / 'loc2' / 'xx' / 'LC_MESSAGES' / 'test2.po').write_text('#')

    catalogs = i18n.get_catalogs([dir / 'loc1', dir / 'loc2'], 'xx')
    domains = sorted(c.domain for c in catalogs)
    assert domains == ['test1', 'test1', 'test2']
コード例 #8
0
ファイル: test_util_i18n.py プロジェクト: tu44okawa3/sphinx
def test_get_catalogs_with_compact(dir):
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES').makedirs()
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'test1.po').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'test2.po').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'sub').makedirs()
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'sub' / 'test3.po').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'sub' / 'test4.po').write_text('#')

    catalogs = i18n.get_catalogs([dir / 'loc1'], 'xx', gettext_compact=True)
    domains = set(c.domain for c in catalogs)
    assert domains == set(['test1', 'test2', 'sub'])
コード例 #9
0
def test_get_catalogs_with_compact(dir):
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES').makedirs()
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'test1.po').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'test2.po').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'sub').makedirs()
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'sub' / 'test3.po').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'sub' / 'test4.po').write_text('#')

    catalogs = i18n.get_catalogs([dir / 'loc1'], 'xx', gettext_compact=True)
    domains = set(c.domain for c in catalogs)
    assert domains == set(['test1', 'test2', 'sub'])
コード例 #10
0
ファイル: __init__.py プロジェクト: tu44okawa3/sphinx
    def compile_specific_catalogs(self, specified_files):
        def to_domain(fpath):
            docname, _ = path.splitext(path_stabilize(fpath))
            dom = find_catalog(docname, self.config.gettext_compact)
            return dom

        specified_domains = set(map(to_domain, specified_files))
        catalogs = i18n.get_catalogs(
            [path.join(self.srcdir, x) for x in self.config.locale_dirs],
            self.config.language, True)
        catalogs = [f for f in catalogs if f.domain in specified_domains]
        message = 'targets for %d po files that are specified' % len(catalogs)
        self.compile_catalogs(catalogs, message)
コード例 #11
0
ファイル: __init__.py プロジェクト: lehmannro/sphinx-mirror
    def compile_specific_catalogs(self, specified_files):
        def to_domain(fpath):
            docname, _ = path.splitext(path_stabilize(fpath))
            dom = find_catalog(docname, self.config.gettext_compact)
            return dom

        specified_domains = set(map(to_domain, specified_files))
        catalogs = i18n.get_catalogs(
            [path.join(self.srcdir, x) for x in self.config.locale_dirs],
            self.config.language, True)
        catalogs = [f for f in catalogs if f.domain in specified_domains]
        message = 'targets for %d po files that are specified' % len(catalogs)
        self.compile_catalogs(catalogs, message)
コード例 #12
0
ファイル: test_util_i18n.py プロジェクト: tu44okawa3/sphinx
def test_get_catalogs_for_xx(dir):
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES').makedirs()
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'test1.po').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'test2.po').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'test3.pot').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'sub').makedirs()
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'sub' / 'test4.po').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'sub' / 'test5.po').write_text('#')
    (dir / 'loc1' / 'en' / 'LC_MESSAGES').makedirs()
    (dir / 'loc1' / 'en' / 'LC_MESSAGES' / 'test6.po').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_ALL').makedirs()
    (dir / 'loc1' / 'xx' / 'LC_ALL' / 'test7.po').write_text('#')

    catalogs = i18n.get_catalogs([dir / 'loc1'], 'xx', force_all=False)
    domains = set(c.domain for c in catalogs)
    assert domains == set([
        'test1',
        'test2',
        path.normpath('sub/test4'),
        path.normpath('sub/test5'),
    ])
コード例 #13
0
def test_get_catalogs_for_xx(dir):
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES').makedirs()
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'test1.po').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'test2.po').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'test3.pot').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'sub').makedirs()
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'sub' / 'test4.po').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_MESSAGES' / 'sub' / 'test5.po').write_text('#')
    (dir / 'loc1' / 'en' / 'LC_MESSAGES').makedirs()
    (dir / 'loc1' / 'en' / 'LC_MESSAGES' / 'test6.po').write_text('#')
    (dir / 'loc1' / 'xx' / 'LC_ALL').makedirs()
    (dir / 'loc1' / 'xx' / 'LC_ALL' / 'test7.po').write_text('#')

    catalogs = i18n.get_catalogs([dir / 'loc1'], 'xx', force_all=False)
    domains = set(c.domain for c in catalogs)
    assert domains == set([
        'test1',
        'test2',
        path.normpath('sub/test4'),
        path.normpath('sub/test5'),
    ])
コード例 #14
0
ファイル: test_util_i18n.py プロジェクト: tu44okawa3/sphinx
def test_get_catalogs_with_non_existent_locale_dirs():
    catalogs = i18n.get_catalogs(['dummy'], 'xx')
    assert not catalogs
コード例 #15
0
ファイル: __init__.py プロジェクト: tu44okawa3/sphinx
 def compile_all_catalogs(self):
     catalogs = i18n.get_catalogs(
         [path.join(self.srcdir, x) for x in self.config.locale_dirs],
         self.config.language, True)
     message = 'all of %d po files' % len(catalogs)
     self.compile_catalogs(catalogs, message)
コード例 #16
0
ファイル: __init__.py プロジェクト: lehmannro/sphinx-mirror
 def compile_update_catalogs(self):
     catalogs = i18n.get_catalogs(
         [path.join(self.srcdir, x) for x in self.config.locale_dirs],
         self.config.language)
     message = 'targets for %d po files that are out of date' % len(catalogs)
     self.compile_catalogs(catalogs, message)
コード例 #17
0
ファイル: __init__.py プロジェクト: lehmannro/sphinx-mirror
 def compile_all_catalogs(self):
     catalogs = i18n.get_catalogs(
         [path.join(self.srcdir, x) for x in self.config.locale_dirs],
         self.config.language, True)
     message = 'all of %d po files' % len(catalogs)
     self.compile_catalogs(catalogs, message)
コード例 #18
0
def test_get_catalogs_with_non_existent_locale(dir):
    catalogs = i18n.get_catalogs([dir / 'loc1'], 'xx')
    assert not catalogs

    catalogs = i18n.get_catalogs([dir / 'loc1'], None)
    assert not catalogs
コード例 #19
0
ファイル: test_util_i18n.py プロジェクト: tu44okawa3/sphinx
def test_get_catalogs_with_non_existent_locale(dir):
    catalogs = i18n.get_catalogs([dir / 'loc1'], 'xx')
    assert not catalogs

    catalogs = i18n.get_catalogs([dir / 'loc1'], None)
    assert not catalogs
コード例 #20
0
def test_get_catalogs_with_non_existent_locale_dirs():
    catalogs = i18n.get_catalogs(['dummy'], 'xx')
    assert not catalogs