diff --git a/kicad/cli/command.h b/kicad/cli/command.h index 3439ce17ae..d535e8b29a 100644 --- a/kicad/cli/command.h +++ b/kicad/cli/command.h @@ -24,6 +24,8 @@ #include #include +#define UTF8STDSTR( s ) ( std::string( s.utf8_str() ) ) + namespace CLI { diff --git a/kicad/cli/command_export_pcb_base.cpp b/kicad/cli/command_export_pcb_base.cpp index 50b300cd17..029f7c5f63 100644 --- a/kicad/cli/command_export_pcb_base.cpp +++ b/kicad/cli/command_export_pcb_base.cpp @@ -32,9 +32,9 @@ CLI::EXPORT_PCB_BASE_COMMAND::EXPORT_PCB_BASE_COMMAND( std::string aName ) : COM { m_argParser.add_argument( "-o", ARG_OUTPUT ) .default_value( std::string() ) - .help( "output file name" ); + .help( UTF8STDSTR( _( "Output file name" ) ) ); - m_argParser.add_argument( ARG_INPUT ).help( "input file" ); + m_argParser.add_argument( ARG_INPUT ).help( UTF8STDSTR( _( "Input file" ) ) ); for( int layer = 0; layer < PCB_LAYER_ID_COUNT; ++layer ) { @@ -87,8 +87,9 @@ void CLI::EXPORT_PCB_BASE_COMMAND::addLayerArg( bool aRequire ) { m_argParser.add_argument( "-l", ARG_LAYERS ) .default_value( std::string() ) - .help( "comma separated list of untranslated layer names to include such as " - "F.Cu,B.Cu" ); + .help( UTF8STDSTR( + _( "Comma separated list of untranslated layer names to include such as " + "F.Cu,B.Cu" ) ) ); m_requireLayers = aRequire; } diff --git a/kicad/cli/command_export_pcb_drill.cpp b/kicad/cli/command_export_pcb_drill.cpp index 4725adbdd6..887c8be69d 100644 --- a/kicad/cli/command_export_pcb_drill.cpp +++ b/kicad/cli/command_export_pcb_drill.cpp @@ -44,51 +44,51 @@ CLI::EXPORT_PCB_DRILL_COMMAND::EXPORT_PCB_DRILL_COMMAND() : EXPORT_PCB_BASE_COMM { m_argParser.add_argument( ARG_FORMAT ) .default_value( std::string( "excellon" ) ) - .help( "valid options are either excellon or gerber" ); + .help( UTF8STDSTR( _( "Valid options excellon, gerber." ) ) ); m_argParser.add_argument( ARG_EXCELLON_ZEROS_FORMAT ) .default_value( std::string( "decimal" ) ) - .help( "valid options are: decimal,supressleading,surpresstrailing,keep" ); + .help( UTF8STDSTR( _( "Valid options are: decimal,supressleading,surpresstrailing,keep." ) ) ); m_argParser.add_argument( ARG_DRILL_ORIGIN ) .default_value( std::string( "absolute" ) ) - .help( "valid options are: absolute,plot" ); + .help( UTF8STDSTR( _( "Valid options are: absolute,plot" ) ) ); m_argParser.add_argument( "-u", ARG_UNITS ) .default_value( std::string( "in" ) ) - .help( "output units, valid options are in or mm" ); + .help( UTF8STDSTR( _( "Output units, valid options:in,mm" ) ) ); m_argParser.add_argument( ARG_EXCELLON_MIRRORY ) - .help( "Mirror Y axis" ) + .help( UTF8STDSTR( _( "Mirror Y axis" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( ARG_EXCELLON_MINIMALHEAD ) - .help( "Minimal header" ) + .help( UTF8STDSTR( _( "Minimal header" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( ARG_EXCELLON_SEPARATE_TH ) - .help( "PTH and NPTH in separate files file" ) + .help( UTF8STDSTR( _( "PTH and NPTH in separate files file" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( ARG_GENERATE_MAP ) - .help( "Generate map / summary of drill hits" ) + .help( UTF8STDSTR( _( "Generate map / summary of drill hits" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( ARG_MAP_FORMAT ) .default_value( std::string( "pdf" ) ) - .help( "valid options are: pdf,gerberx2,ps,dxf,svg" ); + .help( UTF8STDSTR( _( "Valid options: pdf,gerberx2,ps,dxf,svg" ) ) ); m_argParser.add_argument( ARG_SEPARATE_FILES ) - .help( "Generate independent files for NPTH and PTH holes" ) + .help( UTF8STDSTR( _( "Generate independent files for NPTH and PTH holes" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( ARG_GERBER_PRECISION ) - .help( "Precision of gerber coordinates (5 or 6)" ) + .help( UTF8STDSTR( _( "Precision of gerber coordinates (5 or 6)" ) ) ) .default_value( 5 ); } diff --git a/kicad/cli/command_export_pcb_dxf.cpp b/kicad/cli/command_export_pcb_dxf.cpp index 2cc6498a83..d0ba004090 100644 --- a/kicad/cli/command_export_pcb_dxf.cpp +++ b/kicad/cli/command_export_pcb_dxf.cpp @@ -41,23 +41,23 @@ CLI::EXPORT_PCB_DXF_COMMAND::EXPORT_PCB_DXF_COMMAND() : EXPORT_PCB_BASE_COMMAND( addLayerArg( true ); m_argParser.add_argument( "-ird", ARG_INCLUDE_REFDES ) - .help( "Include the reference designator text" ) + .help( UTF8STDSTR( _( "Include the reference designator text" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( "-iv", ARG_INCLUDE_VALUE ) - .help( "Include the value text" ) + .help( UTF8STDSTR( _( "Include the value text" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( "-uc", ARG_USE_CONTOURS ) - .help( "Plot graphic items using their contours" ) + .help( UTF8STDSTR( _( "Plot graphic items using their contours" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( "-ou", ARG_OUTPUT_UNITS ) .default_value( std::string( "in" ) ) - .help( "output file name" ); + .help( UTF8STDSTR( _( "Output units, valid options: mm, in" ) ) ); } diff --git a/kicad/cli/command_export_pcb_gerber.cpp b/kicad/cli/command_export_pcb_gerber.cpp index c053849c01..b6405d7355 100644 --- a/kicad/cli/command_export_pcb_gerber.cpp +++ b/kicad/cli/command_export_pcb_gerber.cpp @@ -41,42 +41,43 @@ CLI::EXPORT_PCB_GERBER_COMMAND::EXPORT_PCB_GERBER_COMMAND() : EXPORT_PCB_BASE_CO addLayerArg( true ); m_argParser.add_argument( "-ird", ARG_INCLUDE_REFDES ) - .help( "Include the reference designator text" ) + .help( UTF8STDSTR( _( "Include the reference designator text" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( "-iv", ARG_INCLUDE_VALUE ) - .help( "Include the value text" ) + .help( UTF8STDSTR( _( "Include the value text" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( "-ibt", ARG_INCLUDE_BORDER_TITLE ) - .help( "Include the border and title block" ) + .help( UTF8STDSTR( _( "Include the border and title block" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( ARG_NO_X2 ) - .help( "Do not use the extended X2 format" ) + .help( UTF8STDSTR( _( "Do not use the extended X2 format" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( ARG_NO_NETLIST ) - .help( "Do not generate netlist attributes" ) + .help( UTF8STDSTR( _( "Do not generate netlist attributes" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( ARG_SUBTRACT_SOLDERMASK ) - .help( "Subtract soldermask from silkscreen" ) + .help( UTF8STDSTR( _( "Subtract soldermask from silkscreen" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( ARG_DISABLE_APERTURE_MACROS ) - .help( "Disable aperature macros" ) + .help( UTF8STDSTR( _( "Disable aperature macros" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( ARG_PRECISION ) - .help( "Precision of gerber coordinates (5 or 6)" ) + .help( UTF8STDSTR( + _( "Precision of gerber coordinates, valid options: 5 or 6" ) ) ) .default_value( 6 ); } diff --git a/kicad/cli/command_export_pcb_pdf.cpp b/kicad/cli/command_export_pcb_pdf.cpp index 85435d0338..44a7db40cf 100644 --- a/kicad/cli/command_export_pcb_pdf.cpp +++ b/kicad/cli/command_export_pcb_pdf.cpp @@ -36,28 +36,29 @@ CLI::EXPORT_PCB_PDF_COMMAND::EXPORT_PCB_PDF_COMMAND() : EXPORT_PCB_BASE_COMMAND( addLayerArg( true ); m_argParser.add_argument( "-ird", ARG_INCLUDE_REFDES ) - .help( "Include the reference designator text" ) + .help( UTF8STDSTR( _( "Include the reference designator text" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( "-iv", ARG_INCLUDE_VALUE ) - .help( "Include the value text" ) + .help( UTF8STDSTR( _( "Include the value text" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( "-ibt", ARG_INCLUDE_BORDER_TITLE ) - .help( "Include the border and title block" ) + .help( UTF8STDSTR( _( "Include the border and title block" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( ARG_BLACKANDWHITE ) - .help( "Black and white only" ) + .help( UTF8STDSTR( _( "Black and white only" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( "-t", ARG_THEME ) .default_value( std::string() ) - .help( "Color theme to use (will default to pcbnew settings)" ); + .help( std::string( + _( "Color theme to use (will default to pcbnew settings)" ).ToUTF8() ) ); } diff --git a/kicad/cli/command_export_pcb_pos.cpp b/kicad/cli/command_export_pcb_pos.cpp index 85accf0b07..0538181889 100644 --- a/kicad/cli/command_export_pcb_pos.cpp +++ b/kicad/cli/command_export_pcb_pos.cpp @@ -43,38 +43,41 @@ CLI::EXPORT_PCB_POS_COMMAND::EXPORT_PCB_POS_COMMAND() : EXPORT_PCB_BASE_COMMAND( { m_argParser.add_argument( ARG_SIDE ) .default_value( std::string( "both" ) ) - .help( "valid options: front,back,both" ); + .help( UTF8STDSTR( _( + "Valid options: front,back,both. Gerber format only supports \"both\"." ) ) ); m_argParser.add_argument( ARG_FORMAT ) .default_value( std::string( "ascii" ) ) - .help( "valid options: ascii,csv,gerber" ); + .help( UTF8STDSTR( _( "Valid options: ascii,csv,gerber" ) ) ); m_argParser.add_argument( ARG_UNITS ) .default_value( std::string( "in" ) ) - .help( "output units, valid options are in or mm (ascii or csv only)" ); + .help( UTF8STDSTR( _( "Output units; ascii or csv format only; valid options: in,mm" ) ) ); m_argParser.add_argument( ARG_NEGATE_BOTTOM_X ) - .help( "Use negative X coordinates for footprints on bottom layer (ascii or csv only)" ) + .help( UTF8STDSTR( _( "Use negative X coordinates for footprints on bottom layer " + "(ascii or csv formats only)" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( ARG_USE_DRILL_FILE_ORIGIN ) - .help( "Use drill/place file origin (ascii or csv only)" ) + .help( UTF8STDSTR( _( "Use drill/place file origin (ascii or csv only)" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( ARG_SMD_ONLY ) - .help( "Include only SMD footprints (ascii or csv only)" ) + .help( UTF8STDSTR( _( "Include only SMD footprints (ascii or csv only)" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( ARG_EXCLUDE_FOOTPRINTS_TH ) - .help( "Exclue all footprints with through-hole pads (ascii or csv only)" ) + .help( UTF8STDSTR( + _( "Exclude all footprints with through-hole pads (ascii or csv only)" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( ARG_GERBER_BOARD_EDGE ) - .help( "Include board edge layer (gerber only)" ) + .help( UTF8STDSTR( _( "Include board edge layer (gerber only)" ) ) ) .implicit_value( true ) .default_value( false ); } diff --git a/kicad/cli/command_export_pcb_step.cpp b/kicad/cli/command_export_pcb_step.cpp index 0cbbdca3f6..d5d014721b 100644 --- a/kicad/cli/command_export_pcb_step.cpp +++ b/kicad/cli/command_export_pcb_step.cpp @@ -44,48 +44,48 @@ CLI::EXPORT_PCB_STEP_COMMAND::EXPORT_PCB_STEP_COMMAND() : COMMAND( "step" ) { m_argParser.add_argument( ARG_DRILL_ORIGIN ) - .help( "Use Drill Origin for output origin" ) + .help( UTF8STDSTR( _( "Use Drill Origin for output origin" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( ARG_GRID_ORIGIN ) - .help( "Use Grid Origin for output origin" ) + .help( UTF8STDSTR( _( "Use Grid Origin for output origin" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( ARG_NO_VIRTUAL ) - .help( "Exclude 3D models for components with 'virtual' attribute" ) + .help( UTF8STDSTR( _( "Exclude 3D models for components with 'virtual' attribute" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( "--subst-models" ) - .help( "Substitute STEP or IGS models with the same name in place of VRML models" ) + .help( UTF8STDSTR( _( "Substitute STEP or IGS models with the same name in place of VRML models" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( ARG_FORCE, "-f" ) - .help( "overwrite output file" ) + .help( UTF8STDSTR( _( "Overwrite output file" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( ARG_BOARD_ONLY ) - .help( "only generate a board with no components" ) + .help( UTF8STDSTR( _( "Only generate a board with no components" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( ARG_MIN_DISTANCE ) - .default_value( std::string() ) - .help( "Minimum distance between points to treat them as separate ones (default 0.01mm)" ); + .default_value( std::string( "0.01mm" ) ) + .help( UTF8STDSTR( _( "Minimum distance between points to treat them as separate ones" ) ) ); m_argParser.add_argument( ARG_USER_ORIGIN ) .default_value( std::string() ) - .help( "User-specified output origin ex. 1x1in, 1x1inch, 25.4x25.4mm (default mm)" ); + .help( UTF8STDSTR( _( "User-specified output origin ex. 1x1in, 1x1inch, 25.4x25.4mm (default unit mm)" ) ) ); m_argParser.add_argument( "-o", ARG_OUTPUT ) .default_value( std::string() ) - .help( "output file name" ); + .help( UTF8STDSTR( _( "Output file name" ) ) ); - m_argParser.add_argument( ARG_INPUT ).help( "input file" ); + m_argParser.add_argument( ARG_INPUT ).help( UTF8STDSTR( _( "Input file" ) ) ); } int CLI::EXPORT_PCB_STEP_COMMAND::Perform( KIWAY& aKiway ) diff --git a/kicad/cli/command_export_pcb_svg.cpp b/kicad/cli/command_export_pcb_svg.cpp index c770956ca2..51382357d7 100644 --- a/kicad/cli/command_export_pcb_svg.cpp +++ b/kicad/cli/command_export_pcb_svg.cpp @@ -39,21 +39,22 @@ CLI::EXPORT_PCB_SVG_COMMAND::EXPORT_PCB_SVG_COMMAND() : EXPORT_PCB_BASE_COMMAND( addLayerArg( true ); m_argParser.add_argument( "-m", ARG_MIRROR ) - .help( "Mirror the board (useful for trying to show bottom layers)" ) + .help( UTF8STDSTR( _( "Mirror the board (useful for trying to show bottom layers)" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( "-t", ARG_THEME ) .default_value( std::string() ) - .help( "Color theme to use (will default to pcbnew settings)" ); + .help( UTF8STDSTR( _( "Color theme to use (will default to pcbnew settings)" ) ) ); m_argParser.add_argument( ARG_BLACKANDWHITE ) - .help( "Black and white only" ) + .help( UTF8STDSTR( _( "Black and white only" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( ARG_PAGE_SIZE ) - .help( "Set page sizing mode (0 = page with frame and title block, 1 = current page size, 2 = board area only)" ) + .help( UTF8STDSTR( _( "Set page sizing mode (0 = page with frame and title block, 1 = " + "current page size, 2 = board area only)" ) ) ) .default_value( 0 ); } diff --git a/kicad/cli/command_export_sch_bom.cpp b/kicad/cli/command_export_sch_bom.cpp index 2debc14d42..c399b61415 100644 --- a/kicad/cli/command_export_sch_bom.cpp +++ b/kicad/cli/command_export_sch_bom.cpp @@ -33,7 +33,7 @@ CLI::EXPORT_SCH_BOM_COMMAND::EXPORT_SCH_BOM_COMMAND() : EXPORT_PCB_BASE_COMMAND( { m_argParser.add_argument( ARG_FORMAT ) .default_value( std::string( "xml" ) ) - .help( "Bom output format, valid options: xml" ); + .help( UTF8STDSTR( _( "Bom output format, valid options: xml" ) ) ); } diff --git a/kicad/cli/command_export_sch_netlist.cpp b/kicad/cli/command_export_sch_netlist.cpp index d6f46929fd..bbcff1f825 100644 --- a/kicad/cli/command_export_sch_netlist.cpp +++ b/kicad/cli/command_export_sch_netlist.cpp @@ -33,7 +33,7 @@ CLI::EXPORT_SCH_NETLIST_COMMAND::EXPORT_SCH_NETLIST_COMMAND() : EXPORT_PCB_BASE_ { m_argParser.add_argument( ARG_FORMAT ) .default_value( std::string( "kicadsexpr" ) ) - .help( "Netlist output format, valid options: kicadsexpr, kicadxml, cadstar, orcadpcb2, spice, spicemodel" ); + .help( UTF8STDSTR( _( "Netlist output format, valid options: kicadsexpr, kicadxml, cadstar, orcadpcb2, spice, spicemodel" ) ) ); } diff --git a/kicad/cli/command_export_sch_pdf.cpp b/kicad/cli/command_export_sch_pdf.cpp index 37af12f8e6..098b118f29 100644 --- a/kicad/cli/command_export_sch_pdf.cpp +++ b/kicad/cli/command_export_sch_pdf.cpp @@ -35,20 +35,20 @@ CLI::EXPORT_SCH_PDF_COMMAND::EXPORT_SCH_PDF_COMMAND() : EXPORT_PCB_BASE_COMMAND( { m_argParser.add_argument( "-t", ARG_THEME ) .default_value( std::string() ) - .help( "Color theme to use (will default to pcbnew settings)" ); + .help( UTF8STDSTR( _( "Color theme to use (will default to pcbnew settings)" ) ) ); m_argParser.add_argument( ARG_BLACKANDWHITE ) - .help( "Black and white only" ) + .help( UTF8STDSTR( _( "Black and white only" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( ARG_EXCLUDE_DRAWING_SHEET ) - .help( "No drawing sheet" ) + .help( UTF8STDSTR( _( "No drawing sheet" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( ARG_NO_BACKGROUND_COLOR ) - .help( "Avoid setting a background color (regardless of theme)" ) + .help( UTF8STDSTR( _( "Avoid setting a background color (regardless of theme)" ) ) ) .implicit_value( true ) .default_value( false ); } diff --git a/kicad/cli/command_export_sch_svg.cpp b/kicad/cli/command_export_sch_svg.cpp index fd5a774270..0292d9b807 100644 --- a/kicad/cli/command_export_sch_svg.cpp +++ b/kicad/cli/command_export_sch_svg.cpp @@ -35,20 +35,20 @@ CLI::EXPORT_SCH_SVG_COMMAND::EXPORT_SCH_SVG_COMMAND() : EXPORT_PCB_BASE_COMMAND( { m_argParser.add_argument( "-t", ARG_THEME ) .default_value( std::string() ) - .help( "Color theme to use (will default to pcbnew settings)" ); + .help( UTF8STDSTR( _( "Color theme to use (will default to pcbnew settings)" ) ) ); m_argParser.add_argument( ARG_BLACKANDWHITE ) - .help( "Black and white only" ) + .help( UTF8STDSTR( _( "Black and white only" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( ARG_EXCLUDE_DRAWING_SHEET ) - .help( "No drawing sheet" ) + .help( UTF8STDSTR( _( "No drawing sheet" ) ) ) .implicit_value( true ) .default_value( false ); m_argParser.add_argument( ARG_NO_BACKGROUND_COLOR ) - .help( "Avoid setting a background color (regardless of theme)" ) + .help( UTF8STDSTR( _( "Avoid setting a background color (regardless of theme)" ) ) ) .implicit_value( true ) .default_value( false ); } diff --git a/kicad/kicad_cli.cpp b/kicad/kicad_cli.cpp index 516af4068a..527c684aea 100644 --- a/kicad/kicad_cli.cpp +++ b/kicad/kicad_cli.cpp @@ -232,7 +232,7 @@ int PGM_KICAD::OnPgmRun() } catch( const std::runtime_error& err ) { - std::cout << err.what() << std::endl; + wxPrintf( "%s\n", err.what() ); // find the correct argparser object to output the command usage info COMMAND_ENTRY* cliCmd = nullptr; @@ -244,10 +244,16 @@ int PGM_KICAD::OnPgmRun() } } + // arg parser uses a stream overload for printing the help + // we want to intercept so we can wxString the utf8 contents + // because on windows our terminal codepage might not be utf8 + std::stringstream ss; if( cliCmd ) - std::cout << cliCmd->handler->GetArgParser(); + ss << cliCmd->handler->GetArgParser(); else - std::cout << argParser; + ss << argParser; + + wxPrintf( FROM_UTF8( ss.str().c_str() ) ); return CLI::EXIT_CODES::ERR_ARGS; } @@ -276,7 +282,10 @@ int PGM_KICAD::OnPgmRun() } else { - std::cout << argParser; + std::stringstream ss; + ss << argParser; + wxPrintf( FROM_UTF8( ss.str().c_str() ) ); + return CLI::EXIT_CODES::ERR_ARGS; } }