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.
This commit is contained in:
Yago González
2018-05-06 11:40:31 +02:00
committed by Tim Abbott
parent 6e149a7594
commit 6837fc5d56
10 changed files with 19 additions and 19 deletions

View File

@@ -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');
});
});

View File

@@ -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);
}());

View File

@@ -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";

View File

@@ -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:

View File

@@ -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')),
],
),

View File

@@ -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),
),
]

View File

@@ -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),
),
]

View File

@@ -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),
),
]

View File

@@ -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),
),
]

View File

@@ -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