2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-17 04:25:42 +00:00

Translation fixes (#8263)

* Translation fixes

- Simplifies translations strings
- Removes some similar duplicate strings
- Reduces passing of tokens into translation

* Adds script for detecting close matches in translation source strings

* Updates for custom script

* Detect duplicate strings (ignoring case)

* Fix some duplicate backend strings

* Fix duplicate strings in frontend

* Fix more duplicate strings

* Run check_source_strings in CI

* Fixes for unit tests

* Fix another broken string

* Revert some changes

* Fix f-string

* Fix old migration files

* Reduce front-end duplication

* Further updates

* Revert change

* Updates
This commit is contained in:
Oliver
2024-10-09 22:32:34 +11:00
committed by GitHub
parent 0b87dc9372
commit dde6aab8b4
47 changed files with 170 additions and 81 deletions

View File

@ -204,7 +204,7 @@ def convert_physical_value(value: str, unit: Optional[str] = None, strip_units=T
if unit:
raise ValidationError(_(f'Could not convert {original} to {unit}'))
else:
raise ValidationError(_('Invalid quantity supplied'))
raise ValidationError(_('Invalid quantity provided'))
# Calculate the "magnitude" of the value, as a float
# If the value is specified strangely (e.g. as a fraction or a dozen), this can cause issues
@ -218,7 +218,7 @@ def convert_physical_value(value: str, unit: Optional[str] = None, strip_units=T
magnitude = float(ureg.Quantity(magnitude).to_base_units().magnitude)
except Exception as exc:
raise ValidationError(_(f'Invalid quantity supplied ({exc})'))
raise ValidationError(_('Invalid quantity provided') + f': ({exc})')
if strip_units:
return magnitude

View File

@ -551,7 +551,7 @@ def extract_serial_numbers(input_string, expected_quantity: int, starting_value=
if a == b:
# Invalid group
add_error(_(f'Invalid group range: {group}'))
add_error(_(f'Invalid group: {group}'))
continue
group_items = []
@ -594,7 +594,7 @@ def extract_serial_numbers(input_string, expected_quantity: int, starting_value=
for item in group_items:
add_serial(item)
else:
add_error(_(f'Invalid group range: {group}'))
add_error(_(f'Invalid group: {group}'))
else:
# In the case of a different number of hyphens, simply add the entire group
@ -612,14 +612,14 @@ def extract_serial_numbers(input_string, expected_quantity: int, starting_value=
sequence_count = max(0, expected_quantity - len(serials))
if len(items) > 2 or len(items) == 0:
add_error(_(f'Invalid group sequence: {group}'))
add_error(_(f'Invalid group: {group}'))
continue
elif len(items) == 2:
try:
if items[1]:
sequence_count = int(items[1]) + 1
except ValueError:
add_error(_(f'Invalid group sequence: {group}'))
add_error(_(f'Invalid group: {group}'))
continue
value = items[0]
@ -638,7 +638,7 @@ def extract_serial_numbers(input_string, expected_quantity: int, starting_value=
for item in sequence_items:
add_serial(item)
else:
add_error(_(f'Invalid group sequence: {group}'))
add_error(_(f'Invalid group: {group}'))
else:
# At this point, we assume that the 'group' is just a single serial value

View File

@ -25,7 +25,7 @@ def send_simple_login_email(user, link):
)
send_mail(
_(f'[{site_name}] Log in to the app'),
f'[{site_name}] ' + _('Log in to the app'),
email_plaintext_message,
settings.DEFAULT_FROM_EMAIL,
[user.email],

View File

@ -624,7 +624,7 @@ class DataFileUploadSerializer(serializers.Serializer):
accepted_file_types = ['xls', 'xlsx', 'csv', 'tsv', 'xml']
if ext not in accepted_file_types:
raise serializers.ValidationError(_('Unsupported file type'))
raise serializers.ValidationError(_('Unsupported file format'))
# Impose a 50MB limit on uploaded BOM files
max_upload_file_size = 50 * 1024 * 1024

View File

@ -60,7 +60,7 @@ class FileManager:
file.seek(0)
else:
fmt = ext.upper()
raise ValidationError(_(f'Unsupported file format: {fmt}'))
raise ValidationError(_('Unsupported file format') + f': {fmt}')
except UnicodeEncodeError:
raise ValidationError(_('Error reading file (invalid encoding)'))

View File

@ -22,8 +22,8 @@ class UploadFileForm(forms.Form):
if name:
# Update label and help_text with file name
self.fields['file'].label = _(f'{name.title()} File')
self.fields['file'].help_text = _(f'Select {name} file to upload')
self.fields['file'].label = name.title() + ' ' + _('File')
self.fields['file'].help_text = _('Select file to upload')
def clean_file(self):
"""Run tabular file validation.

View File

@ -18,6 +18,6 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='inventreesetting',
name='key',
field=models.CharField(help_text='Settings key (must be unique - case insensitive', max_length=50, unique=True),
field=models.CharField(help_text='Settings key', max_length=50, unique=True),
),
]

View File

@ -18,7 +18,7 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('value', models.CharField(blank=True, help_text='Settings value', max_length=200)),
('key', models.CharField(help_text='Settings key (must be unique - case insensitive', max_length=50)),
('key', models.CharField(help_text='Settings key', max_length=50)),
('user', models.ForeignKey(blank=True, help_text='User', null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='User')),
],
options={

View File

@ -780,10 +780,7 @@ class BaseInvenTreeSetting(models.Model):
)
key = models.CharField(
max_length=50,
blank=False,
unique=False,
help_text=_('Settings key (must be unique - case insensitive)'),
max_length=50, blank=False, unique=False, help_text=_('Settings key')
)
value = models.CharField(
@ -2179,10 +2176,7 @@ class InvenTreeSetting(BaseInvenTreeSetting):
typ = 'inventree'
key = models.CharField(
max_length=50,
blank=False,
unique=True,
help_text=_('Settings key (must be unique - case insensitive'),
max_length=50, blank=False, unique=True, help_text=_('Settings key')
)
def to_native_value(self):
@ -2559,10 +2553,7 @@ class InvenTreeUserSetting(BaseInvenTreeSetting):
extra_unique_fields = ['user']
key = models.CharField(
max_length=50,
blank=False,
unique=False,
help_text=_('Settings key (must be unique - case insensitive'),
max_length=50, blank=False, unique=False, help_text=_('Settings key')
)
user = models.ForeignKey(

View File

@ -40,7 +40,7 @@ msgstr "למשתמש אין הרשאה לצפות במוזל הזה"
#: InvenTree/conversion.py:161
#, python-brace-format
msgid "Invalid unit provided ({unit})"
msgstr "סופקה יחידה שלא קיימת"
msgstr "סופקה יחידה שלא קיימת ({unit})"
#: InvenTree/conversion.py:178
msgid "No value provided"
@ -49,7 +49,7 @@ msgstr "לא צוין ערך"
#: InvenTree/conversion.py:205
#, python-brace-format
msgid "Could not convert {original} to {unit}"
msgstr "לא ניתן להמיר מקור ליחידה"
msgstr ""
#: InvenTree/conversion.py:207
msgid "Invalid quantity supplied"

View File

@ -27,7 +27,7 @@ class Migration(migrations.Migration):
name='MachineSetting',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('key', models.CharField(help_text='Settings key (must be unique - case insensitive)', max_length=50)),
('key', models.CharField(help_text='Settings key', max_length=50)),
('value', models.CharField(blank=True, help_text='Settings value', max_length=2000)),
('config_type', models.CharField(choices=[('M', 'Machine'), ('D', 'Driver')], max_length=1, verbose_name='Config type')),
('machine_config', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='settings', to='machine.machineconfig', verbose_name='Machine Config')),

View File

@ -143,7 +143,7 @@ src="{% static 'img/blank_image.png' %}"
{% if order.supplier %}
<a href="{% url 'company-detail' order.supplier.id %}">{{ order.supplier.name }}</a>{% include "clip.html" %}
{% else %}
<em>{% trans "No suppplier information available" %}</em>
<em>{% trans "No supplier information available" %}</em>
{% endif %}
</td>
</tr>

View File

@ -82,7 +82,7 @@ class BomUploadTest(InvenTreeAPITestCase):
"""POST with an unsupported file type."""
response = self.post_bom('sample.txt', b'hello world', expected_code=400)
self.assertIn('Unsupported file type', str(response.data['data_file']))
self.assertIn('Unsupported file format', str(response.data['data_file']))
def test_broken_file(self):
"""Test upload with broken (corrupted) files."""

View File

@ -15,7 +15,7 @@ class Migration(migrations.Migration):
name='PluginSetting',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('key', models.CharField(help_text='Settings key (must be unique - case insensitive', max_length=50)),
('key', models.CharField(help_text='Settings key', max_length=50)),
('value', models.CharField(blank=True, help_text='Settings value', max_length=200)),
('plugin', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='settings', to='plugin.pluginconfig', verbose_name='Plugin')),
],

View File

@ -13,6 +13,6 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='pluginsetting',
name='key',
field=models.CharField(help_text='Settings key (must be unique - case insensitive)', max_length=50),
field=models.CharField(help_text='Settings key', max_length=50),
),
]

View File

@ -17,7 +17,7 @@ class Migration(migrations.Migration):
name='NotificationUserSetting',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('key', models.CharField(help_text='Settings key (must be unique - case insensitive)', max_length=50)),
('key', models.CharField(help_text='Settings key', max_length=50)),
('value', models.CharField(blank=True, help_text='Settings value', max_length=200)),
('method', models.CharField(max_length=255, verbose_name='Method')),
('user', models.ForeignKey(blank=True, help_text='User', null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='User')),

View File

@ -2046,7 +2046,7 @@ function loadSalesOrderLineItemTable(table, options={}) {
if (options.allow_edit && (row.shipped < row.quantity)) {
if (part.trackable) {
buttons += makeIconButton('fa-hashtag icon-green', 'button-add-by-sn', pk, '{% trans "Allocate serial numbers" %}');
buttons += makeIconButton('fa-hashtag icon-green', 'button-add-by-sn', pk, '{% trans "Allocate Serial Numbers" %}');
}
buttons += makeIconButton('fa-sign-in-alt icon-green', 'button-add', pk, '{% trans "Allocate stock" %}');
if (part.purchaseable) {

View File

@ -617,7 +617,7 @@ function findStockItemBySerialNumber(part_id) {
handleFormErrors(
{
'serial': [
'{% trans "Enter a serial number" %}',
'{% trans "Enter serial number" %}',
]
}, fields, opts
);
@ -1445,14 +1445,14 @@ function removeStockRow(e) {
function passFailBadge(result) {
if (result) {
return `<span class='badge badge-right rounded-pill bg-success'>{% trans "PASS" %}</span>`;
return `<span class='badge badge-right rounded-pill bg-success'>{% trans "Pass" %}</span>`;
} else {
return `<span class='badge badge-right rounded-pill bg-danger'>{% trans "FAIL" %}</span>`;
return `<span class='badge badge-right rounded-pill bg-danger'>{% trans "Fail" %}</span>`;
}
}
function noResultBadge() {
return `<span class='badge badge-right rounded-pill bg-info'>{% trans "NO RESULT" %}</span>`;
return `<span class='badge badge-right rounded-pill bg-info'>{% trans "No result" %}</span>`;
}
function formatDate(row, date, options={}) {

View File

@ -10,7 +10,7 @@
<p>
{% trans "An error occurred while attempting to login via your social network account." %}
<br>
{% trans "Contact your system administrator for further information." %}
{% trans "Contact your system administrator for further information" %}
</p>
<hr>