def test_translate_object(self): """Test that translating text from the database works as expected.""" # Test that the object stays the same if no translation exists service = Service(name='Richmond Clinic', description='English description') translated_service = translate_object(service, 'es_US') self.assertEquals(translated_service.description, 'English description') # Test that the object is translated when a translation exists service.translations.append( ServiceTranslation(language_code='es_US', description='Spanish description')) translated_service = translate_object(service, 'es_US') self.assertEquals(translated_service.description, 'Spanish description')
def service(service_id): """Display the profile page for a service organization.""" service = translate_object( Service.query.get(service_id), current_app.config['BABEL_DEFAULT_LOCALE'] ) return render_template('service_profile.html', service=service)
def test_translate_object(self): """Test that translating text from the database works as expected.""" # Test that the object stays the same if no translation exists service = Service( name='Richmond Clinic', description='English description' ) translated_service = translate_object(service, 'es_US') self.assertEquals(translated_service.description, 'English description') # Test that the object is translated when a translation exists service.translations.append( ServiceTranslation( language_code='es_US', description='Spanish description' ) ) translated_service = translate_object(service, 'es_US') self.assertEquals(translated_service.description, 'Spanish description')
def service(service_id): """Display the profile page for a service organization.""" service = translate_object(Service.query.get(service_id), current_app.config['BABEL_DEFAULT_LOCALE']) return render_template('service_profile.html', service=service)