From 6837fc5d562d0f8a7685d0f7106b79e9e15ced0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yago=20Gonz=C3=A1lez?= Date: Sun, 6 May 2018 11:40:31 +0200 Subject: [PATCH] i18n: Add missing strings for custom profile fields and fix capitalization. The "Short/Long Text" option for custom profile fields wasn't properly capitalized (i.e. "Text" should have been all lowercase), and also wasn't properly tagged for translation. For the sake of consistency, the change to proper capitalization has also been applied to the models and any tests involving this feature. Due to a bug in Django, it complained about the models having changed and thus not being consistent with the migrations. That isn't actually true (since the database stores the numeric values for each key), but the migrations have been modified to avoid this error. This does not affect the migrations' behaviour in any way. --- frontend_tests/casper_tests/10-admin.js | 4 ++-- frontend_tests/node_tests/templates.js | 8 ++++---- static/js/settings_account.js | 4 ++-- zerver/lib/slack_data_to_zulip_data.py | 2 +- zerver/migrations/0073_custom_profile_fields.py | 2 +- .../migrations/0153_remove_int_float_custom_fields.py | 2 +- zerver/migrations/0160_add_choice_field.py | 2 +- zerver/migrations/0165_add_date_to_profile_field.py | 2 +- zerver/migrations/0166_add_url_to_profile_field.py | 2 +- zerver/models.py | 10 +++++----- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/frontend_tests/casper_tests/10-admin.js b/frontend_tests/casper_tests/10-admin.js index d3acdf9715..c6b42bd35e 100644 --- a/frontend_tests/casper_tests/10-admin.js +++ b/frontend_tests/casper_tests/10-admin.js @@ -203,7 +203,7 @@ casper.then(function () { }); casper.waitUntilVisible('.profile-field-row span.profile_field_name', function () { casper.test.assertSelectorHasText('.profile-field-row span.profile_field_name', 'Teams'); - casper.test.assertSelectorHasText('.profile-field-row span.profile_field_type', 'Short Text'); + casper.test.assertSelectorHasText('.profile-field-row span.profile_field_type', 'Short text'); casper.click('.profile-field-row button.open-edit-form'); }); }); @@ -223,7 +223,7 @@ casper.then(function () { }); casper.waitForSelectorTextChange('.profile-field-row span.profile_field_name', function () { casper.test.assertSelectorHasText('.profile-field-row span.profile_field_name', 'team'); - casper.test.assertSelectorHasText('.profile-field-row span.profile_field_type', 'Short Text'); + casper.test.assertSelectorHasText('.profile-field-row span.profile_field_type', 'Short text'); casper.click('.profile-field-row button.delete'); }); }); diff --git a/frontend_tests/node_tests/templates.js b/frontend_tests/node_tests/templates.js index 9e7655cc17..1edd0b5f74 100644 --- a/frontend_tests/node_tests/templates.js +++ b/frontend_tests/node_tests/templates.js @@ -194,7 +194,7 @@ function render(template_name, args) { var args = { profile_field: { name: "teams", - type: "Long Text", + type: "Long text", }, can_modify: true, }; @@ -209,14 +209,14 @@ function render(template_name, args) { var td = $(html).find('tr.profile-field-row:first td'); assert.equal(field_name.text(), 'teams'); - assert.equal(field_type.text(), 'Long Text'); + assert.equal(field_type.text(), 'Long text'); assert.equal(td.length, 4); // When the logged in user is not admin args = { profile_field: { name: "teams", - type: "Long Text", + type: "Long text", }, can_modify: false, }; @@ -231,7 +231,7 @@ function render(template_name, args) { td = $(html).find('tr.profile-field-row:first td'); assert.equal(field_name.text(), 'teams'); - assert.equal(field_type.text(), 'Long Text'); + assert.equal(field_type.text(), 'Long text'); assert.equal(td.length, 3); }()); diff --git a/static/js/settings_account.js b/static/js/settings_account.js index 1363145dcd..4e71c021e7 100644 --- a/static/js/settings_account.js +++ b/static/js/settings_account.js @@ -60,11 +60,11 @@ exports.add_custom_profile_fields_to_settings = function () { var field_type = settings_profile_fields.field_type_id_to_string(field.type); var type; var value = people.my_custom_profile_data(field.id); - var is_long_text = field_type === "Long Text"; + var is_long_text = field_type === "Long text"; var is_choice_field = field_type === "Choice"; var field_choices = []; - if (field_type === "Long Text" || field_type === "Short Text") { + if (field_type === "Long text" || field_type === "Short text") { type = "text"; } else if (field_type === "Choice") { type = "choice"; diff --git a/zerver/lib/slack_data_to_zulip_data.py b/zerver/lib/slack_data_to_zulip_data.py index 49bc8169b5..fcc712ab98 100755 --- a/zerver/lib/slack_data_to_zulip_data.py +++ b/zerver/lib/slack_data_to_zulip_data.py @@ -280,7 +280,7 @@ def process_customprofilefields(customprofilefield: List[ZerverFieldsT], for field in customprofilefield: for field_value in customprofilefield_value: if field_value['field'] == field['id'] and len(field_value['value']) > 50: - field['field_type'] = 2 # corresponding to Long Text + field['field_type'] = 2 # corresponding to Long text break def get_user_email(user: ZerverFieldsT, domain_name: str) -> str: diff --git a/zerver/migrations/0073_custom_profile_fields.py b/zerver/migrations/0073_custom_profile_fields.py index 074a77b9c2..b5a88c4d29 100644 --- a/zerver/migrations/0073_custom_profile_fields.py +++ b/zerver/migrations/0073_custom_profile_fields.py @@ -17,7 +17,7 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=100)), - ('field_type', models.PositiveSmallIntegerField(choices=[(1, 'Integer'), (2, 'Float'), (3, 'Short Text'), (4, 'Long Text')], default=3)), + ('field_type', models.PositiveSmallIntegerField(choices=[(1, 'Integer'), (2, 'Float'), (3, 'Short text'), (4, 'Long text')], default=3)), ('realm', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='zerver.Realm')), ], ), diff --git a/zerver/migrations/0153_remove_int_float_custom_fields.py b/zerver/migrations/0153_remove_int_float_custom_fields.py index 9bb601c95f..bcd2789282 100644 --- a/zerver/migrations/0153_remove_int_float_custom_fields.py +++ b/zerver/migrations/0153_remove_int_float_custom_fields.py @@ -15,6 +15,6 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='customprofilefield', name='field_type', - field=models.PositiveSmallIntegerField(choices=[(1, 'Short Text'), (2, 'Long Text')], default=1), + field=models.PositiveSmallIntegerField(choices=[(1, 'Short text'), (2, 'Long text')], default=1), ), ] diff --git a/zerver/migrations/0160_add_choice_field.py b/zerver/migrations/0160_add_choice_field.py index f789dda870..f0a4ff442b 100644 --- a/zerver/migrations/0160_add_choice_field.py +++ b/zerver/migrations/0160_add_choice_field.py @@ -20,6 +20,6 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='customprofilefield', name='field_type', - field=models.PositiveSmallIntegerField(choices=[(1, 'Short Text'), (2, 'Long Text'), (3, 'Choice')], default=1), + field=models.PositiveSmallIntegerField(choices=[(1, 'Short text'), (2, 'Long text'), (3, 'Choice')], default=1), ), ] diff --git a/zerver/migrations/0165_add_date_to_profile_field.py b/zerver/migrations/0165_add_date_to_profile_field.py index 31290490dc..3908ea4a03 100644 --- a/zerver/migrations/0165_add_date_to_profile_field.py +++ b/zerver/migrations/0165_add_date_to_profile_field.py @@ -15,6 +15,6 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='customprofilefield', name='field_type', - field=models.PositiveSmallIntegerField(choices=[(1, 'Short Text'), (2, 'Long Text'), (4, 'Date'), (3, 'Choice')], default=1), + field=models.PositiveSmallIntegerField(choices=[(1, 'Short text'), (2, 'Long text'), (4, 'Date'), (3, 'Choice')], default=1), ), ] diff --git a/zerver/migrations/0166_add_url_to_profile_field.py b/zerver/migrations/0166_add_url_to_profile_field.py index 0d80af35b2..246176ab92 100644 --- a/zerver/migrations/0166_add_url_to_profile_field.py +++ b/zerver/migrations/0166_add_url_to_profile_field.py @@ -15,6 +15,6 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='customprofilefield', name='field_type', - field=models.PositiveSmallIntegerField(choices=[(1, 'Short Text'), (2, 'Long Text'), (4, 'Date'), (5, 'URL'), (3, 'Choice')], default=1), + field=models.PositiveSmallIntegerField(choices=[(1, 'Short text'), (2, 'Long text'), (4, 'Date'), (5, 'URL'), (3, 'Choice')], default=1), ), ] diff --git a/zerver/models.py b/zerver/models.py index 2896454c47..32f3eb1748 100644 --- a/zerver/models.py +++ b/zerver/models.py @@ -1905,7 +1905,7 @@ class CustomProfileField(models.Model): # These are the fields whose validators require field_data # argument as well. EXTENDED_FIELD_TYPE_DATA = [ - (CHOICE, 'Choice', validate_choice_field, str), + (CHOICE, str(_('Choice')), validate_choice_field, str), ] # type: FieldTypeData EXTENDED_FIELD_VALIDATORS = { @@ -1914,10 +1914,10 @@ class CustomProfileField(models.Model): FIELD_TYPE_DATA = [ # Type, Name, Validator, Converter - (SHORT_TEXT, u'Short Text', check_short_string, str), - (LONG_TEXT, u'Long Text', check_long_string, str), - (DATE, u'Date', check_date, str), - (URL, u'URL', check_url, str), + (SHORT_TEXT, str(_('Short text')), check_short_string, str), + (LONG_TEXT, str(_('Long text')), check_long_string, str), + (DATE, str(_('Date')), check_date, str), + (URL, str(_('URL')), check_url, str), ] # type: FieldTypeData ALL_FIELD_TYPES = FIELD_TYPE_DATA + EXTENDED_FIELD_TYPE_DATA