Ejemplo n.º 1
0
    def test_merge_two_changesets(self):
        self.ctx.add_transforms('aboutDownloads.ftl', [
            FTL.Entity(
                id=FTL.Identifier('title'),
                value=LITERAL_FROM(
                    'aboutDownloads.dtd',
                    'aboutDownloads.title'
                )
            ),
            FTL.Entity(
                id=FTL.Identifier('header'),
                value=LITERAL_FROM(
                    'aboutDownloads.dtd',
                    'aboutDownloads.header'
                )
            ),
        ])

        changeset_a = {
            ('aboutDownloads.dtd', 'aboutDownloads.title'),
        }

        changeset_b = {
            ('aboutDownloads.dtd', 'aboutDownloads.header')
        }

        expected_a = {
            'aboutDownloads.ftl': ftl_resource_to_json('''
        # This Source Code Form is subject to the terms of the Mozilla Public
        # License, v. 2.0. If a copy of the MPL was not distributed with this
        # file, You can obtain one at http://mozilla.org/MPL/2.0/.

        title = Pobrane pliki
            ''')
        }

        expected_b = {
            'aboutDownloads.ftl': ftl_resource_to_json('''
        # This Source Code Form is subject to the terms of the Mozilla Public
        # License, v. 2.0. If a copy of the MPL was not distributed with this
        # file, You can obtain one at http://mozilla.org/MPL/2.0/.

        title = Pobrane pliki
        header = Twoje pobrane pliki
            ''')
        }

        merged_a = to_json(self.ctx.merge_changeset(changeset_a))
        self.assertDictEqual(merged_a, expected_a)

        merged_b = to_json(self.ctx.merge_changeset(changeset_b))
        self.assertDictEqual(merged_b, expected_b)
Ejemplo n.º 2
0
    def test_merge_context_some_messages(self):
        changeset = {
            ('aboutDownloads.dtd', 'aboutDownloads.title'),
            ('aboutDownloads.dtd', 'aboutDownloads.header'),
            ('aboutDownloads.properties', 'downloadState.downloading'),
            ('aboutDownloads.properties', 'downloadState.canceled'),
        }

        expected = {
            'aboutDownloads.ftl': ftl_resource_to_json('''
        # This Source Code Form is subject to the terms of the Mozilla Public
        # License, v. 2.0. If a copy of the MPL was not distributed with this
        # file, You can obtain one at http://mozilla.org/MPL/2.0/.

        title                      = Pobrane pliki
        header                     = Twoje pobrane pliki
        download-state-downloading = Pobieranie…
        download-state-canceled    = Anulowane
            ''')
        }

        self.assertDictEqual(
            to_json(self.ctx.merge_changeset(changeset)),
            expected
        )
Ejemplo n.º 3
0
    def test_merge_single_message(self):
        self.ctx.add_transforms('aboutDownloads.ftl', [
            FTL.Entity(
                id=FTL.Identifier('title'),
                value=LITERAL_FROM(
                    'aboutDownloads.dtd',
                    'aboutDownloads.title'
                )
            ),
        ])

        expected = {
            'aboutDownloads.ftl': ftl_resource_to_json('''
        # This Source Code Form is subject to the terms of the Mozilla Public
        # License, v. 2.0. If a copy of the MPL was not distributed with this
        # file, You can obtain one at http://mozilla.org/MPL/2.0/.

        title = Pobrane pliki
            ''')
        }

        self.assertDictEqual(
            to_json(self.ctx.merge_changeset()),
            expected
        )
Ejemplo n.º 4
0
    def test_three_way_two_entities(self):
        ab_cd_ftl = parse(FTLParser, ftl('''
            # This Source Code Form is subject to the terms of …

            empty = Brak pobranych plików
        '''))

        subset = ('title', 'download-state-downloading')
        resource = merge_resource(
            self, self.en_us_ftl, ab_cd_ftl, self.transforms,
            in_changeset=lambda x: x in subset
        )

        self.assertEqual(
            resource.toJSON(),
            ftl_resource_to_json('''
                # This Source Code Form is subject to the terms of …

                # A generic comment.

                title = Pobrane pliki
                empty = Brak pobranych plików

                # A section comment.
                [[ Menu items ]]

                download-state-downloading = Pobieranie…
            ''')
        )
Ejemplo n.º 5
0
    def test_merge_three_way(self):
        resource = merge_resource(
            self, self.en_us_ftl, self.ab_cd_ftl, self.transforms,
            in_changeset=lambda x: True
        )

        self.assertEqual(
            resource.toJSON(),
            ftl_resource_to_json('''
                # This Source Code Form is subject to the terms of …

                # A generic comment.

                title = Pobrane pliki
                empty = Brak pobranych plików

                # A section comment.
                [[ Menu items ]]

                # A message comment.
                open-menuitem =
                    [html/label] Otwórz

                download-state-downloading = Pobieranie…

            ''')
        )
Ejemplo n.º 6
0
    def test_missing_localization_file(self):
        expected = {
            'toolbar.ftl': ftl_resource_to_json('''
        # This Source Code Form is subject to the terms of the Mozilla Public
        # License, v. 2.0. If a copy of the MPL was not distributed with this
        # file, You can obtain one at http://mozilla.org/MPL/2.0/.
            ''')
        }

        self.assertDictEqual(
            to_json(self.ctx.merge_changeset()),
            expected
        )
Ejemplo n.º 7
0
    def test_merge_context_all_messages(self):
        expected = {
            'aboutDialog.ftl': ftl_resource_to_json('''
        # This Source Code Form is subject to the terms of the Mozilla Public
        # License, v. 2.0. If a copy of the MPL was not distributed with this
        # file, You can obtain one at http://mozilla.org/MPL/2.0/.

        update-failed = Aktualizacja się nie powiodła. <a>Pobierz</a>.
        channel-desc  = "Obecnie korzystasz z kanału { $channelname }. "
        community     = Program { $brand-short-name } został opracowany przez <a>organizację { $vendor-short-name }</a>, która jest <a>globalną społecznością</a>, starającą się zapewnić, by…
            ''')
        }

        self.assertDictEqual(
            to_json(self.ctx.merge_changeset()),
            expected
        )
Ejemplo n.º 8
0
    def test_merge_context_all_messages(self):
        expected = {
            'aboutDownloads.ftl': ftl_resource_to_json('''
        # This Source Code Form is subject to the terms of the Mozilla Public
        # License, v. 2.0. If a copy of the MPL was not distributed with this
        # file, You can obtain one at http://mozilla.org/MPL/2.0/.

        title  = Pobrane pliki
        header = Twoje pobrane pliki
        empty  = Brak pobranych plików

        open-menuitem =
            [html/label] Otwórz
        retry-menuitem =
            [html/label] Spróbuj ponownie
        remove-menuitem =
            [html/label] Usuń
        pause-menuitem =
            [html/label] Wstrzymaj
        resume-menuitem =
            [html/label] Wznów
        cancel-menuitem =
            [html/label] Anuluj
        remove-all-menuitem =
            [html/label] Usuń wszystko

        delete-all-title   = Usuń wszystko
        delete-all-message = { $num ->
            [one] Usunąć pobrany plik?
            [few] Usunąć { $num } pobrane pliki?
           *[many] Usunąć { $num } pobranych plików?
        }

        download-state-downloading = Pobieranie…
        download-state-canceled    = Anulowane
        download-state-failed      = Nieudane
        download-state-paused      = Wstrzymane
        download-state-starting    = Rozpoczynanie…
        download-size-unknown      = Nieznany rozmiar
            ''')
        }

        self.assertDictEqual(
            to_json(self.ctx.merge_changeset()),
            expected
        )
Ejemplo n.º 9
0
    def test_two_way_one_entity(self):
        subset = ('title',)
        resource = merge_resource(
            self, self.en_us_ftl, FTL.Resource(), self.transforms,
            in_changeset=lambda x: x in subset
        )

        self.assertEqual(
            resource.toJSON(),
            ftl_resource_to_json('''
                # This Source Code Form is subject to the terms of …

                # A generic comment.

                title = Pobrane pliki
            ''')
        )
Ejemplo n.º 10
0
    def test_merge_two_way(self):
        resource = merge_resource(
            self, self.en_us_ftl, FTL.Resource(), self.transforms,
            in_changeset=lambda x: True
        )

        self.assertEqual(
            resource.toJSON(),
            ftl_resource_to_json('''
                title = Pobrane pliki
                about = Hardcoded Value

                open-menuitem =
                    [html/label] Otwórz

                download-state-downloading = Pobieranie…
            ''')
        )
Ejemplo n.º 11
0
    def test_merge_context_some_messages(self):
        changeset = {
            ('aboutDialog.dtd', 'update.failed.start'),
        }

        expected = {
            'aboutDialog.ftl': ftl_resource_to_json('''
        # This Source Code Form is subject to the terms of the Mozilla Public
        # License, v. 2.0. If a copy of the MPL was not distributed with this
        # file, You can obtain one at http://mozilla.org/MPL/2.0/.

        update-failed = Aktualizacja się nie powiodła. <a>Pobierz</a>.
            ''')
        }

        self.assertDictEqual(
            to_json(self.ctx.merge_changeset(changeset)),
            expected
        )
Ejemplo n.º 12
0
    def test_merge_three_way(self):
        resource = merge_resource(
            self, self.en_us_ftl, self.ab_cd_ftl, self.transforms,
            in_changeset=lambda x: True
        )

        self.assertEqual(
            resource.toJSON(),
            ftl_resource_to_json('''
                title = Pobrane pliki
                empty = Brak pobranych plików
                about = Previously Hardcoded Value

                open-menuitem =
                    [html/label] Otwórz

                download-state-downloading = Pobieranie…
            ''')
        )
Ejemplo n.º 13
0
    def test_hardcoded_node(self):
        self.ctx.add_transforms('aboutDownloads.ftl', [
            FTL.Entity(
                id=FTL.Identifier('about'),
                value=LITERAL('Hardcoded Value')
            ),
        ])

        expected = {
            'aboutDownloads.ftl': ftl_resource_to_json('''
        # This Source Code Form is subject to the terms of the Mozilla Public
        # License, v. 2.0. If a copy of the MPL was not distributed with this
        # file, You can obtain one at http://mozilla.org/MPL/2.0/.

        about = Hardcoded Value
            ''')
        }

        self.assertDictEqual(
            to_json(self.ctx.merge_changeset()),
            expected
        )
Ejemplo n.º 14
0
    def test_two_way_two_entities(self):
        subset = ('title', 'download-state-downloading')
        resource = merge_resource(
            self, self.en_us_ftl, FTL.Resource(), self.transforms,
            in_changeset=lambda x: x in subset
        )

        self.assertEqual(
            resource.toJSON(),
            ftl_resource_to_json('''
                # This Source Code Form is subject to the terms of …

                # A generic comment.

                title = Pobrane pliki

                # A section comment.
                [[ Menu items ]]

                download-state-downloading = Pobieranie…
            ''')
        )
Ejemplo n.º 15
0
    def test_three_way_one_entity_existing_section(self):
        ab_cd_ftl = parse(FTLParser, ftl('''
            # This Source Code Form is subject to the terms of …

            empty = Brak pobranych plików

            # A section comment.
            [[ Menu items ]]

            # A message comment.
            open-menuitem =
                [html/label] Otwórz
        '''))

        subset = ('title',)
        resource = merge_resource(
            self, self.en_us_ftl, ab_cd_ftl, self.transforms,
            in_changeset=lambda x: x in subset
        )

        self.assertEqual(
            resource.toJSON(),
            ftl_resource_to_json('''
                # This Source Code Form is subject to the terms of …

                # A generic comment.

                title = Pobrane pliki
                empty = Brak pobranych plików

                # A section comment.
                [[ Menu items ]]

                # A message comment.
                open-menuitem =
                    [html/label] Otwórz
            ''')
        )
Ejemplo n.º 16
0
    def test_three_way_one_entity(self):
        ab_cd_ftl = parse(FTLParser, ftl('''
            # This Source Code Form is subject to the terms of …

            empty = Brak pobranych plików
        '''))

        subset = ('title',)
        resource = merge_resource(
            self, self.en_us_ftl, ab_cd_ftl, self.transforms,
            in_changeset=lambda x: x in subset
        )

        self.assertEqual(
            resource.toJSON(),
            ftl_resource_to_json('''
                # This Source Code Form is subject to the terms of …

                # A generic comment.

                title = Pobrane pliki
                empty = Brak pobranych plików
            ''')
        )