Translate the linux metadata files

This commit is contained in:
Ian McInerney 2021-01-16 18:09:59 +00:00
parent 1a025ae7ba
commit 43baf2e3f2
13 changed files with 168 additions and 118 deletions

View File

@ -971,16 +971,6 @@ add_custom_target( uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" )
#################################################
# Generate platform metadata files
#################################################
if( APPLE )
include( ${CMAKE_MODULE_PATH}/WritePlatformMetadata_macos.cmake )
elseif( UNIX )
include( ${CMAKE_MODULE_PATH}/WritePlatformMetadata_linux.cmake )
endif()
#================================================
# Installation
#================================================
@ -996,45 +986,6 @@ if( UNIX AND NOT APPLE )
)
endif()
###
# FreeDesktop .desktop and MIME resources
###
if( UNIX AND NOT APPLE )
# Set paths
set( UNIX_MIME_DIR resources/linux/mime )
set( UNIX_MIME_FILES ${UNIX_MIME_DIR}/mime )
set( UNIX_ICON_FILES ${UNIX_MIME_DIR}/icons )
set( UNIX_APPLICATIONS_FILES ${UNIX_MIME_DIR}/applications )
set( UNIX_APPDATA_FILES ${PROJECT_BINARY_DIR}/resources/linux/appdata )
# Install Mime directory
install( DIRECTORY ${UNIX_ICON_FILES}
DESTINATION share
COMPONENT resources
)
# Install Icons
install( DIRECTORY ${UNIX_MIME_FILES}
DESTINATION share
COMPONENT resources
)
# Install Applications directory (.desktop files)
install( DIRECTORY ${UNIX_APPLICATIONS_FILES}
DESTINATION share
COMPONENT resources
)
# Install AppStream directory (app store entry)
install( DIRECTORY ${UNIX_APPDATA_FILES}
DESTINATION share
COMPONENT resources
FILES_MATCHING
PATTERN "*appdata.xml"
PATTERN "*.in" EXCLUDE
)
endif()
include( CTest )
enable_testing()
@ -1061,6 +1012,7 @@ endif()
#================================================
# Binaries ( CMake targets )
add_subdirectory( resources )
add_subdirectory( thirdparty )
add_subdirectory( bitmaps_png )
add_subdirectory( libs )
@ -1079,7 +1031,7 @@ add_subdirectory( tools )
add_subdirectory( utils )
add_subdirectory( qa )
# Resources
# Demos
if( KICAD_INSTALL_DEMOS )
add_subdirectory( demos )
endif ( KICAD_INSTALL_DEMOS )

View File

@ -149,3 +149,50 @@ function( translate_language LANG OUT_FILE)
COMPONENT resources )
endif()
endfunction()
# Function linux_metadata_translation
#
# This is a macro to handle the translation of the linux metadata files using
# the existing .po files.
#
# Arguments:
# - SRC_FILE is the file to use as the translation source
# - OUT_FILE is the file (including directory) to save the translations to
# - PO_DIR is the directory containing the raw po files
macro( linux_metadata_translation SRC_FILE OUT_FILE PO_DIR )
get_filename_component( OUT_DIR ${OUT_FILE} DIRECTORY )
get_filename_component( OUT_FNAME ${OUT_FILE} NAME )
file( MAKE_DIRECTORY ${OUT_DIR} )
# Figure out the type of file we are translating
set( OPT_TYPE "" )
set( SED_CMD "" )
if( ${SRC_FILE} MATCHES ".*\.desktop\.in" )
set( OPT_TYPE "--desktop" )
elseif( ${SRC_FILE} MATCHES ".*\.xml\.in" )
set( OPT_TYPE "--xml" )
endif ()
# Add the command to translate the file
if( KICAD_BUILD_I18N )
add_custom_command(
OUTPUT ${OUT_FILE}
DEPENDS ${SRC_FILE}
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE}
${OPT_TYPE} --template=${SRC_FILE}
-d ${PO_DIR}
-o ${OUT_FILE}
COMMENT "Translating ${OUT_FNAME}"
)
else()
add_custom_command(
OUTPUT ${OUT_FILE}
DEPENDS ${SRC_FILE}
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_FILE}" "${OUT_FILE}"
COMMENT "Copying ${OUT_FNAME}"
)
endif()
endmacro()

View File

@ -1,8 +1,8 @@
#
# This program source code file is part of KICAD, a free EDA CAD application.
#
# Copyright (C) 2019 Ian McInerney <Ian.S.McInerney@ieee.org>
# Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
# Copyright (C) 2019-2020 Ian McInerney <Ian.S.McInerney@ieee.org>
# Copyright (C) 2019-2020 KiCad Developers, see AUTHORS.txt for contributors.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -25,10 +25,13 @@
# This file will configure the linux appdata.xml file to include the version
# and build date.
# It requires the following variables to be defined before its call:
# SRC_PATH - The root directory for the source
# BUILD_PATH - The root directory for the build directory
message( STATUS "Creating linux metadata" )
# Create the KiCad version strings
set( SRC_PATH ${PROJECT_SOURCE_DIR} )
include( ${CMAKE_MODULE_PATH}/KiCadVersion.cmake )
include( ${CMAKE_MODULE_PATH}/KiCadFullVersion.cmake )
@ -36,11 +39,11 @@ include( ${CMAKE_MODULE_PATH}/KiCadFullVersion.cmake )
string( TIMESTAMP KICAD_CONFIG_TIMESTAMP "%Y-%m-%d" )
# Configure the KiCad appdata file
configure_file( ${PROJECT_SOURCE_DIR}/resources/linux/appdata/kicad.appdata.xml.in
${PROJECT_BINARY_DIR}/resources/linux/appdata/kicad.appdata.xml
configure_file( ${SRC_PATH}/resources/linux/appdata/kicad.appdata.xml.in
${BUILD_PATH}/resources/linux/appdata/kicad.appdata.xml.in
@ONLY )
# Ensure the file was configured successfully
if( NOT EXISTS ${PROJECT_BINARY_DIR}/resources/linux/appdata/kicad.appdata.xml )
message( FATAL_ERROR "Configuration failed to write file kicad.appdata.xml." )
if( NOT EXISTS ${BUILD_PATH}/resources/linux/appdata/kicad.appdata.xml.in )
message( FATAL_ERROR "Configuration failed to write file kicad.appdata.xml.in" )
endif()

94
resources/CMakeLists.txt Normal file
View File

@ -0,0 +1,94 @@
#################################################
# Generate platform metadata files
#################################################
if( APPLE )
#TODO Generate this at runtime as well
include( ${CMAKE_MODULE_PATH}/WritePlatformMetadata_macos.cmake )
elseif( UNIX )
# Add the command to configure the linux appdata file with the version information
add_custom_command(
OUTPUT ${PROJECT_BINARY_DIR}/resources/linux/appdata/kicad.appdata.xml.in
COMMAND ${CMAKE_COMMAND}
-DSRC_PATH=${PROJECT_SOURCE_DIR}
-DBUILD_PATH=${PROJECT_BINARY_DIR}
-DCMAKE_MODULE_PATH=${PROJECT_SOURCE_DIR}/CMakeModules
-P ${CMAKE_MODULE_PATH}/WritePlatformMetadata_linux.cmake
COMMENT "Configuring Linux appdata"
)
# Read the appdata from the binary directory because it has been configured by Cmake already
# to have the version string in it
linux_metadata_translation( ${PROJECT_BINARY_DIR}/resources/linux/appdata/kicad.appdata.xml.in
${PROJECT_BINARY_DIR}/resources/linux/appdata/kicad.appdata.xml
${PROJECT_SOURCE_DIR}/translation/pofiles )
# All the desktop files are read from the source directory
linux_metadata_translation( ${PROJECT_SOURCE_DIR}/resources/linux/launchers/bitmap2component.desktop.in
${PROJECT_BINARY_DIR}/resources/linux/launchers/bitmap2component.desktop
${PROJECT_SOURCE_DIR}/translation/pofiles )
linux_metadata_translation( ${PROJECT_SOURCE_DIR}/resources/linux/launchers/eeschema.desktop.in
${PROJECT_BINARY_DIR}/resources/linux/launchers/eeschema.desktop
${PROJECT_SOURCE_DIR}/translation/pofiles )
linux_metadata_translation( ${PROJECT_SOURCE_DIR}/resources/linux/launchers/gerbview.desktop.in
${PROJECT_BINARY_DIR}/resources/linux/launchers/gerbview.desktop
${PROJECT_SOURCE_DIR}/translation/pofiles )
linux_metadata_translation( ${PROJECT_SOURCE_DIR}/resources/linux/launchers/kicad.desktop.in
${PROJECT_BINARY_DIR}/resources/linux/launchers/kicad.desktop
${PROJECT_SOURCE_DIR}/translation/pofiles )
linux_metadata_translation( ${PROJECT_SOURCE_DIR}/resources/linux/launchers/pcbcalculator.desktop.in
${PROJECT_BINARY_DIR}/resources/linux/launchers/pcbcalculator.desktop
${PROJECT_SOURCE_DIR}/translation/pofiles )
linux_metadata_translation( ${PROJECT_SOURCE_DIR}/resources/linux/launchers/pcbnew.desktop.in
${PROJECT_BINARY_DIR}/resources/linux/launchers/pcbnew.desktop
${PROJECT_SOURCE_DIR}/translation/pofiles )
add_custom_target( metadata ALL
DEPENDS ${PROJECT_BINARY_DIR}/resources/linux/appdata/kicad.appdata.xml
${PROJECT_BINARY_DIR}/resources/linux/launchers/bitmap2component.desktop
${PROJECT_BINARY_DIR}/resources/linux/launchers/eeschema.desktop
${PROJECT_BINARY_DIR}/resources/linux/launchers/gerbview.desktop
${PROJECT_BINARY_DIR}/resources/linux/launchers/kicad.desktop
${PROJECT_BINARY_DIR}/resources/linux/launchers/pcbcalculator.desktop
${PROJECT_BINARY_DIR}/resources/linux/launchers/pcbnew.desktop
)
# Set paths
set( UNIX_MIME_DIR linux/mime )
set( UNIX_MIME_FILES ${UNIX_MIME_DIR}/mime )
set( UNIX_ICON_FILES ${UNIX_MIME_DIR}/icons )
# Install Mime directory
install( DIRECTORY ${UNIX_ICON_FILES}
TYPE DATA
COMPONENT resources
)
# Install Icons
install( DIRECTORY ${UNIX_MIME_FILES}/
DESTINATION ${CMAKE_INSTALL_DATADIR}/mime/packages
COMPONENT resources
)
# Install application launchers (.desktop files)
install( DIRECTORY ${PROJECT_BINARY_DIR}/resources/linux/launchers/
DESTINATION ${CMAKE_INSTALL_DATADIR}/applications
COMPONENT resources
FILES_MATCHING
PATTERN "*.desktop"
PATTERN "*.in" EXCLUDE
)
# Install appstream metadata (app store entry)
install( DIRECTORY ${PROJECT_BINARY_DIR}/resources/linux/appdata/
DESTINATION ${CMAKE_INSTALL_DATADIR}/appdata
COMPONENT resources
FILES_MATCHING
PATTERN "*appdata.xml"
PATTERN "*.in" EXCLUDE
)
endif()

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (C) 2016-2017 Lubomir Rintel <lkundrak@v3.sk> -->
<!-- Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors. -->
<!-- Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors. -->
<component type="desktop">
<id>org.kicad_pcb.kicad</id>
<name>KiCad</name>
@ -11,9 +11,6 @@
<metadata_license>CC-BY-SA-4.0</metadata_license>
<summary>EDA Suite</summary>
<summary xml:lang="de">EDA Lösung</summary>
<summary xml:lang="it">Suite EDA</summary>
<summary xml:lang="sv">EDA Programpaket</summary>
<provides>
<binary>kicad</binary>
@ -38,26 +35,9 @@
<description>
<p>
A Cross Platform and Open Source Electronics Design Automation Suite.
KiCad is a Cross Platform and Open Source Electronics Design Automation Suite.
The programs handle Schematic Capture, and PCB Layout with Gerber output.
</p>
<p xml:lang="de">
KiCad ist eine Plattform übergreifende freie Software Lösung für
Elektronische Design-Automation (EDA). KiCad enthält Programme zum
Entwickeln und Bearbeiten von elektronischen Schaltplänen und Leiterplatten
als auch zum Export von Leiterplatten, z.B. per Gerber Format.
</p>
<p xml:lang="it">
KiCad è una soluzione software EDA (Electronic Design Automation) gratuita
e multipiattaforma. Contiene programmi per lo sviluppo e la modifica di
schemi elettrici e circuiti stampati esportabili in formato Gerber.
</p>
<p xml:lang="sv">
KiCad är ett plattformslös och öppen källkods programpaket för elektronisk
design automatisering. KiCad innehåller program för utveckling och redigering
av kretsscheman och tryckta kretskort samt för export av kretskort,
t.ex. med Gerber-format.
</p>
</description>
<screenshots>

View File

@ -7,8 +7,4 @@ Categories=Science;Electronics;
Exec=bitmap2component
Name=Bitmap to Component Converter
GenericName=Bitmap to Component Converter
GenericName[it]=Convertitore da bitmap a componente
GenericName[zh_CN]=
Comment=Create a component from a bitmap for use with KiCad
Comment[it]=Crea un componente KiCad da un'immagine bitmap
Comment[zh_CN]= KiCad

View File

@ -0,0 +1,11 @@
[Desktop Entry]
Version=1.0
Terminal=false
Icon=eeschema
Type=Application
Categories=Science;Electronics;
Exec=eeschema %f
MimeType=application/x-kicad-schematic;
Name=Eeschema (Standalone)
GenericName=Electronic schematic capture
Comment=KiCad electronic schematic design (standalone)

View File

@ -8,8 +8,4 @@ Exec=gerbview
MimeType=application/x-gerber;application/x-excellon
Name=GerbView
GenericName=Gerber File Viewer
GenericName[it]=Visualizzatore file Gerber
GenericName[zh_CN]=Gerber
Comment=View Gerber files
Comment[it]=Visualizza file in formato Gerber
Comment[zh_CN]= Gerber

View File

@ -8,10 +8,5 @@ Exec=kicad %f
MimeType=application/x-kicad-project;
Name=KiCad
GenericName=EDA Suite
GenericName[it]=CAD elettronico
GenericName[zh_CN]=EDA
Comment=Electronic Design Automation suite
Comment[fr]=Suite logicielle de conception électronique
Comment[it]=Suite di progettazione circuiti elettronici
Comment[zh_CN]=
X-Desktop-File-Install-Version=0.22

View File

@ -7,7 +7,4 @@ Categories=Science;Electronics;
Exec=pcb_calculator
Name=PCB Calculator
GenericName=PCB Calculator
GenericName[zh_CN]=PCB
Comment=Calculator for various electronics-related computations
Comment[it]=Calcolatore per CAD e varie grandezze elettroniche
Comment[zh_CN]=

View File

@ -8,8 +8,4 @@ Exec=pcbnew %f
MimeType=application/x-kicad-pcb;
Name=Pcbnew (Standalone)
GenericName=PCB layout
GenericName[it]=Disegno PCB
GenericName[zh_CN]=PCB
Comment=KiCad printed circuit board layout (standalone)
Comment[it]=Disegno di circuiti stampati con KiCad (standalone)
Comment[zh_CN]=KiCad ()

View File

@ -1,17 +0,0 @@
[Desktop Entry]
Version=1.0
Terminal=false
Icon=eeschema
Type=Application
Categories=Science;Electronics;
Exec=eeschema %f
MimeType=application/x-kicad-schematic;
Name=Eeschema (Standalone)
GenericName=Electronic schematic capture
GenericName[fr]=Saisie de schéma électronique
GenericName[it]=Disegno di schemi elettrici
GenericName[zh_CN]=
Comment=KiCad electronic schematic design (standalone)
Comment[fr]=Dessiner des schémas électroniques (Standalone)
Comment[it]=Progettazione di schemi elettrici (Standalone)
Comment[zh_CN]=KiCad ()

View File

@ -63,7 +63,7 @@ cd $SOURCEDIR
#Generate/update template pot file
find $POTDIRS -name '*.cpp' -or -name '*.h' |
sort |
xgettext -f- -k_ -k_HKI -kwxPLURAL:1,2 --force-po --from-code utf-8 -o $LOCALDIR/kicad.pot
xgettext -f- -k_ -k_HKI -kwxPLURAL:1,2 --force-po --from-code utf-8 -o $LOCALDIR/pofiles/kicad.pot
LINGUAS=`cat $LOCALDIR/pofiles/LINGUAS|grep -v '^#'|grep -v '^\s*$'` #Read file without comment and empty lines
@ -93,7 +93,7 @@ for i in $LINGUAS
do
echo "## $i"
if [ "$i" = "en" ] ; then
msgmerge --no-location --no-fuzzy-matching --force-po $LOCALDIR/$i/kicad.po $LOCALDIR/kicad.pot -o $LOCALDIR/$i/kicad.po 2> /dev/null
msgmerge --no-location --no-fuzzy-matching --force-po $LOCALDIR/pofiles/$i.po $LOCALDIR/pofiles/kicad.pot -o $LOCALDIR/pofiles/$i.po 2> /dev/null
msgen $LOCALDIR/pofiles/$i.po -o $LOCALDIR/pofiles/$i.po.tmp && mv $LOCALDIR/pofiles/$i.po.tmp $LOCALDIR/pofiles/$i.po
else
msgmerge --force-po $LOCALDIR/pofiles/$i.po $LOCALDIR/pofiles/kicad.pot -o $LOCALDIR/pofiles/$i.po 2> /dev/null