diff --git a/chrome/content/zotero/xpcom/data/cachedTypes.js b/chrome/content/zotero/xpcom/data/cachedTypes.js index 68009a681d..1d5ce84540 100644 --- a/chrome/content/zotero/xpcom/data/cachedTypes.js +++ b/chrome/content/zotero/xpcom/data/cachedTypes.js @@ -442,7 +442,12 @@ Zotero.ItemTypes = new function() { return _customLabels[id]; } - return Zotero.Schema.globalSchemaLocale.itemTypes[typeName]; + var label = Zotero.Schema.globalSchemaLocale.itemTypes[typeName]; + if (!label) { + Zotero.logError(`Localized string not available for item type '${typeName}'`); + label = Zotero.Utilities.Internal.camelToTitleCase(typeName); + } + return label; } this.getImageSrc = function (itemType) { diff --git a/chrome/content/zotero/xpcom/data/itemFields.js b/chrome/content/zotero/xpcom/data/itemFields.js index d344485b6e..38e50970b4 100644 --- a/chrome/content/zotero/xpcom/data/itemFields.js +++ b/chrome/content/zotero/xpcom/data/itemFields.js @@ -77,15 +77,12 @@ Zotero.ItemFields = new function() { for (let field of fields) { let isBaseField = baseFields.includes(field.fieldID); - let label; - try { - label = field.label || Zotero.Schema.globalSchemaLocale.fields[field.fieldName]; - } - // Some base fields aren't localized - catch (e) { - if (!isBaseField) { - throw e; - } + let label = field.label || Zotero.Schema.globalSchemaLocale.fields[field.fieldName]; + // If string not available, use the field name, except for some base fields that aren't + // used in the UI and therefore aren't localized + if (!label && !['number', 'type', 'medium'].includes(field.fieldName)) { + Zotero.logError(`Localized string not available for field '${field.fieldName}'`); + label = Zotero.Utilities.Internal.camelToTitleCase(field.fieldName); } _fields[field.fieldID] = { diff --git a/chrome/content/zotero/xpcom/utilities_internal.js b/chrome/content/zotero/xpcom/utilities_internal.js index cdf50259bd..505d2b525b 100644 --- a/chrome/content/zotero/xpcom/utilities_internal.js +++ b/chrome/content/zotero/xpcom/utilities_internal.js @@ -1375,6 +1375,12 @@ Zotero.Utilities.Internal = { }, + camelToTitleCase: function (str) { + str = str.replace(/([A-Z])/g, " $1"); + return str.charAt(0).toUpperCase() + str.slice(1); + }, + + resolveLocale: function (locale, locales) { // If the locale exists as-is, use it if (locales.includes(locale)) {