コード例 #1
0
 def test_plural(self):
     source = '''key =
 { $number ->
     [1] Simple String
    *[other] Other Simple String
 }'''
     assert_equal(as_simple_translation(source), 'Other Simple String')
コード例 #2
0
 def test_attribute_select_expression(self):
     source = '''key
 .placeholder = { PLATFORM() ->
     [win] Simple String
    *[other] Other Simple String
 }'''
     assert_equal(as_simple_translation(source), 'Other Simple String')
コード例 #3
0
 def test_multiline(self):
     source = '''key =
 Simple String
 In Multiple
 Lines'''
     assert_equal(as_simple_translation(source),
                  'Simple String\nIn Multiple\nLines')
コード例 #4
0
def simplify_ftl_tm_entries(apps, schema):
    """
    Reformat all FTL source strings and translations in TranslationMemoryEntry
    table with as_simple_translation().

    See bug 1576120 for more details.
    """
    TranslationMemoryEntry = apps.get_model("base", "TranslationMemoryEntry")

    tm_entries = TranslationMemoryEntry.objects.filter(entity__resource__format="ftl")

    for tme in tm_entries:
        tme.source = as_simple_translation(tme.source)
        tme.target = as_simple_translation(tme.target)

    bulk_update(
        tm_entries, update_fields=["source", "target"], batch_size=1000,
    )
コード例 #5
0
 def test_wrapped_select_expression(self):
     source = '''key =
 Anne liked your comment on { $photo_count ->
     [male] his
     [female] her
    *[other] their
 } post.'''
     assert_equal(as_simple_translation(source),
                  'Anne liked your comment on their post.')
コード例 #6
0
def regenerate_ftl_entries_with_comments(apps, schema):
    """
    Regenerate source column in TranslationMemoryEntry for all FTL strings
    that are potentially comments instead of strings.

    See bug 1581594 for more details.
    """
    TranslationMemoryEntry = apps.get_model('base', 'TranslationMemoryEntry')

    tm_entries = (TranslationMemoryEntry.objects.filter(
        entity__resource__format='ftl',
        source__contains="#").prefetch_related('entity', 'translation'))

    for tme in tm_entries:
        tme.source = as_simple_translation(tme.entity.string)

    bulk_update(
        tm_entries,
        update_fields=['source', 'target'],
        batch_size=1000,
    )
コード例 #7
0
def test_helper_as_simple_translation(k):
    string, expected = SIMPLE_TRANSLATION_TESTS[k]
    assert as_simple_translation(string) == expected
コード例 #8
0
 def test_simple(self):
     source = 'key = Simple String'
     assert_equal(as_simple_translation(source), 'Simple String')
コード例 #9
0
 def test_non_ftl(self):
     source = 'Simple String'
     assert_equal(as_simple_translation(source), 'Simple String')
コード例 #10
0
 def test_empty_string(self):
     source = ''
     assert_equal(as_simple_translation(source), '')
コード例 #11
0
 def test_other_ftl(self):
     source = 'warning-upgrade = { LINK("Link text", title: "Link title") }Simple String'
     assert_equal(as_simple_translation(source), 'Simple String')
コード例 #12
0
 def test_attributes(self):
     source = '''key
 .attribute = Simple String
 .other = Other Simple String'''
     assert_equal(as_simple_translation(source), 'Simple String')
コード例 #13
0
 def test_attribute(self):
     source = '''key
 .placeholder = Simple String'''
     assert_equal(as_simple_translation(source), 'Simple String')
コード例 #14
0
ファイル: test_helpers.py プロジェクト: mathjazz/pontoon
def test_helper_as_simple_translation(k):
    string, expected = SIMPLE_TRANSLATION_TESTS[k]
    assert as_simple_translation(string) == expected