diff --git a/common/template_fieldnames.cpp b/common/template_fieldnames.cpp index 9675ab56bc..78d9a1c1d3 100644 --- a/common/template_fieldnames.cpp +++ b/common/template_fieldnames.cpp @@ -27,8 +27,12 @@ using namespace TFIELD_T; +#define REFCANONICAL "Reference" +#define VALCANONICAL "Value" +#define FTPCANONICAL "Footprint" +#define DSHCANONICAL "Datasheet" -const wxString TEMPLATE_FIELDNAME::GetDefaultFieldName( int aFieldNdx ) +const wxString TEMPLATE_FIELDNAME::GetDefaultFieldName( int aFieldNdx, bool aTranslate ) { static void* locale = nullptr; static wxString referenceDefault; @@ -37,14 +41,25 @@ const wxString TEMPLATE_FIELDNAME::GetDefaultFieldName( int aFieldNdx ) static wxString datasheetDefault; static wxString fieldDefault; + if( !aTranslate ) + { + switch( aFieldNdx ) + { + case REFERENCE: return REFCANONICAL; // The component reference, R1, C1, etc. + case VALUE: return VALCANONICAL; // The component value + name + case FOOTPRINT: return FTPCANONICAL; // The footprint for use with Pcbnew + case DATASHEET: return DSHCANONICAL; // Link to a datasheet for component + } + } + // Fetching translations can take a surprising amount of time when loading libraries, // so only do it when necessary. if( Pgm().GetLocale() != locale ) { - referenceDefault = _( "Reference" ); - valueDefault = _( "Value" ); - footprintDefault = _( "Footprint" ); - datasheetDefault = _( "Datasheet" ); + referenceDefault = _( REFCANONICAL ); + valueDefault = _( VALCANONICAL ); + footprintDefault = _( FTPCANONICAL ); + datasheetDefault = _( DSHCANONICAL ); fieldDefault = _( "Field%d" ); locale = Pgm().GetLocale(); } @@ -58,8 +73,15 @@ const wxString TEMPLATE_FIELDNAME::GetDefaultFieldName( int aFieldNdx ) case DATASHEET: return datasheetDefault; // Link to a datasheet for component default: return wxString::Format( fieldDefault, aFieldNdx ); } + } +#undef REFCANONICAL +#undef VALCANONICAL +#undef FTPCANONICAL +#undef DSHCANONICAL + + void TEMPLATE_FIELDNAME::Format( OUTPUTFORMATTER* out, int nestLevel ) const { out->Print( nestLevel, "(field (name %s)", out->Quotew( m_Name ).c_str() ); diff --git a/common/template_fieldnames.h b/common/template_fieldnames.h index 6f55a3df91..caa025bd4a 100644 --- a/common/template_fieldnames.h +++ b/common/template_fieldnames.h @@ -120,8 +120,9 @@ struct TEMPLATE_FIELDNAME * returns a default symbol field name for field \a aFieldNdx for all components. * These fieldnames are not modifiable, but template fieldnames are. * @param aFieldNdx The field number index, > 0 + * @param aTranslate If true, return the translated field name, else get the canonical name */ - static const wxString GetDefaultFieldName( int aFieldNdx ); + static const wxString GetDefaultFieldName( int aFieldNdx, bool aTranslate = true ); }; typedef std::vector< TEMPLATE_FIELDNAME > TEMPLATE_FIELDNAMES; diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp index 077b385d5b..a44263a00a 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp @@ -985,7 +985,7 @@ void SCH_SEXPR_PLUGIN::saveField( SCH_FIELD* aField, int aNestLevel ) if( aField->GetParent()->Type() == SCH_COMPONENT_T ) { if( aField->GetId() >= 0 && aField->GetId() < MANDATORY_FIELDS ) - fieldName = TEMPLATE_FIELDNAME::GetDefaultFieldName( aField->GetId() ); + fieldName = TEMPLATE_FIELDNAME::GetDefaultFieldName( aField->GetId(), false ); } else if( aField->GetParent()->Type() == SCH_SHEET_T ) {