Don't write translated strings

Even though the translation isn't used, the choice of locale can create
unwanted diffs
This commit is contained in:
Seth Hillbrand 2020-10-23 19:52:43 -07:00
parent 1d559108c8
commit b7f115bf5f
3 changed files with 30 additions and 7 deletions

View File

@ -27,8 +27,12 @@
using namespace TFIELD_T; 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 void* locale = nullptr;
static wxString referenceDefault; static wxString referenceDefault;
@ -37,14 +41,25 @@ const wxString TEMPLATE_FIELDNAME::GetDefaultFieldName( int aFieldNdx )
static wxString datasheetDefault; static wxString datasheetDefault;
static wxString fieldDefault; 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, // Fetching translations can take a surprising amount of time when loading libraries,
// so only do it when necessary. // so only do it when necessary.
if( Pgm().GetLocale() != locale ) if( Pgm().GetLocale() != locale )
{ {
referenceDefault = _( "Reference" ); referenceDefault = _( REFCANONICAL );
valueDefault = _( "Value" ); valueDefault = _( VALCANONICAL );
footprintDefault = _( "Footprint" ); footprintDefault = _( FTPCANONICAL );
datasheetDefault = _( "Datasheet" ); datasheetDefault = _( DSHCANONICAL );
fieldDefault = _( "Field%d" ); fieldDefault = _( "Field%d" );
locale = Pgm().GetLocale(); locale = Pgm().GetLocale();
} }
@ -58,8 +73,15 @@ const wxString TEMPLATE_FIELDNAME::GetDefaultFieldName( int aFieldNdx )
case DATASHEET: return datasheetDefault; // Link to a datasheet for component case DATASHEET: return datasheetDefault; // Link to a datasheet for component
default: return wxString::Format( fieldDefault, aFieldNdx ); default: return wxString::Format( fieldDefault, aFieldNdx );
} }
} }
#undef REFCANONICAL
#undef VALCANONICAL
#undef FTPCANONICAL
#undef DSHCANONICAL
void TEMPLATE_FIELDNAME::Format( OUTPUTFORMATTER* out, int nestLevel ) const void TEMPLATE_FIELDNAME::Format( OUTPUTFORMATTER* out, int nestLevel ) const
{ {
out->Print( nestLevel, "(field (name %s)", out->Quotew( m_Name ).c_str() ); out->Print( nestLevel, "(field (name %s)", out->Quotew( m_Name ).c_str() );

View File

@ -120,8 +120,9 @@ struct TEMPLATE_FIELDNAME
* returns a default symbol field name for field \a aFieldNdx for all components. * returns a default symbol field name for field \a aFieldNdx for all components.
* These fieldnames are not modifiable, but template fieldnames are. * These fieldnames are not modifiable, but template fieldnames are.
* @param aFieldNdx The field number index, > 0 * @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; typedef std::vector< TEMPLATE_FIELDNAME > TEMPLATE_FIELDNAMES;

View File

@ -985,7 +985,7 @@ void SCH_SEXPR_PLUGIN::saveField( SCH_FIELD* aField, int aNestLevel )
if( aField->GetParent()->Type() == SCH_COMPONENT_T ) if( aField->GetParent()->Type() == SCH_COMPONENT_T )
{ {
if( aField->GetId() >= 0 && aField->GetId() < MANDATORY_FIELDS ) 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 ) else if( aField->GetParent()->Type() == SCH_SHEET_T )
{ {