def test_fetching_one_plural_translated_string(db_connection): data.add_language('polish', 'pl') resource_pk = data.add_resource('r').pk string_pk = data.add_or_update_base_string(resource_pk, 'one x', plural='%d xs', comment='comment', context='ctx') data.set_translated_string( 'pl', string_pk, translation='jeden iks', translator_comment='tcomment', plural_translations=dila.application.structures.PluralTranslations( few='%d iksy', many='%d iksów', other='%d iksów', )) data.shutdown_session() preserved_string = data.get_translated_string('pl', string_pk) assert preserved_string == dila.application.structures.TranslatedStringData( pk=string_pk, base_string='one x', plural='%d xs', context='ctx', translation='jeden iks', comment='comment', translator_comment='tcomment', resource_pk=resource_pk, plural_translations=dila.application.structures.PluralTranslations( few='%d iksy', many='%d iksów', other='%d iksów', ), )
def test_translating_string_into_multiple_languages(db_connection): data.add_language('polish', 'pl') data.add_language('dutch', 'nl') resource_pk = data.add_resource('r').pk string_pk = data.add_or_update_base_string(resource_pk, 'x', comment='comment', context='ctx') data.set_translated_string('pl', string_pk, translation='y', translator_comment='ytcomment') data.set_translated_string('nl', string_pk, translation='z', translator_comment='ztcomment') first_string = data.get_translated_string('pl', string_pk) second_string = data.get_translated_string('nl', string_pk) assert first_string == dila.application.structures.TranslatedStringData( pk=string_pk, base_string='x', plural='', context='ctx', translation='y', comment='comment', translator_comment='ytcomment', resource_pk=resource_pk, plural_translations=None, ) assert second_string == dila.application.structures.TranslatedStringData( pk=string_pk, base_string='x', plural='', context='ctx', translation='z', comment='comment', translator_comment='ztcomment', resource_pk=resource_pk, plural_translations=None, )
def test_fetching_one_untranslated_string(db_connection): data.add_language('polish', 'pl') resource_pk = data.add_resource('r').pk string_pk = data.add_or_update_base_string(resource_pk, 'x', comment='comment', context='ctx') preserved_string = data.get_translated_string('pl', string_pk) assert preserved_string == dila.application.structures.TranslatedStringData( pk=string_pk, base_string='x', plural='', context='ctx', translation='', comment='comment', translator_comment='', resource_pk=resource_pk, plural_translations=None, )
def get_translated_string(language_code, pk): return data.get_translated_string(language_code, pk)