Re: Biblioteca WEG

After using many find + sed commands and finish with kate editor I can change the font to Liberation Sans in Catanlan translation element directory but the diff to push to master was 2 X the entire size off collection like 145 Mio only the patch????!!!!!

[17:04:44] laurent@debian:~$ history | grep find
 
8596  find . -name "*.elmt" -exec sh -c sed -i'/font=/{n;s/Sans Serif,9,-1,5,50,0,0,0,0,0/Liberation Sans,9,-1,5,50,0,0,0,0,0,Regular/}'
8597  find . -name "*.elmt" -exec sh  sed -i'/font=/{n;s/Sans Serif,9,-1,5,50,0,0,0,0,0/Liberation Sans,9,-1,5,50,0,0,0,0,0,Regular/}'
 
8670  find . -name "*.elmt" -exec  sed -i -e 's/Sans Serif,10,-1,5,50,0,0,0,0,0/Liberation Sans,10,-1,5,50,0,0,0,0,0,Regular/g' {} \;
8671  find . -name "*.elmt" -exec  sed -i -e 's/Sans Serif,8,-1,5,50,0,0,0,0,0/Liberation Sans,8,-1,5,50,0,0,0,0,0,Regular/g' {} \;
8672  find . -name "*.elmt" -exec  sed -i -e 's/Sans Serif,7,-1,5,50,0,0,0,0,0/Liberation Sans,7,-1,5,50,0,0,0,0,0,Regular/g' {} \;
8673  find . -name "*.elmt" -exec  sed -i -e 's/Sans Serif,6,-1,5,50,0,0,0,0,0/Liberation Sans,6,-1,5,50,0,0,0,0,0,Regular/g' {} \;
8674  find . -name "*.elmt" -exec  sed -i -e 's/Sans Serif,5,-1,5,50,0,0,0,0,0/Liberation Sans,5,-1,5,50,0,0,0,0,0,Regular/g' {} \;
8734  find . -name "*.elmt" -exec  sed -i -e 's/Sans Serif,5,-1,5,50,0,0,0,0,0,normal/Liberation Sans,5,-1,5,50,0,0,0,0,0,Regular/g' {} \;
.....................

https://download.qelectrotech.org/qet/s … onts.patch

What interests us is just extracting the Catalan translation strings from the diff.

See Xavier script's perl here: https://download.qelectrotech.org/qet/scripts/

BTW, we used these this perl scripts 15 years ago, now my memory fails me.



Note regarding the translation of elements: do not use the QET editor, but manually edit the elmt file using a text editor and add your country tag to the XLM file. Use spaces rather than tabs for alignment.
If you are using the QET Qt 5 editor, XML attributes will be saved randomly by default. This is a requirement requested by some to Qt 's team to avoid hacks, but in our case, the diff file is very large and incomprehensible...

Example:

<definition hotspot_x="35" hotspot_y="25" version="0.100.0" type="element" height="50" width="70" link_type="simple">
    <uuid uuid="{2b9f2e91-da08-497d-b065-bd2d68d716d9}"/>
    <names>
        <name lang="ca">Filtre</name>
        <name lang="fr">Filtre</name>
        <name lang="en">Filter</name>
        <name lang="es">Filtro</name>
        <name lang="nl">Filter</name>
        <name lang="it">Filtro</name>
        <name lang="ar">مُرشّح</name>
        <name lang="pl">Filtr</name>
        <name lang="cs">Filtr</name>
        <name lang="el">Φίλτρο</name>
    </names>
    <elementInformations/>

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: Biblioteca WEG

Salut Laurent,

when we want the fonts to be replaced correctly, we need to include the quote-signs into replacement!
For example:
From the original Oldtimer-Elements in the other thread, we find these font-descriptions:

Noto Sans ExtraBold,10,-1,0,81,0,0,0,0,0,Regular
Noto Sans ExtraBold,5,-1,0,81,0,0,0,0,0,Regular
Noto Sans ExtraBold,6,-1,0,81,0,0,0,0,0,Regular
Noto Sans ExtraBold,7,-1,0,81,0,0,0,0,0,Regular
Noto Sans ExtraBold,9,-1,0,81,0,0,0,0,0,Regular
Sans Serif,10,-1,0,50,0,0,0,0,0
Sans Serif,10,-1,5,50,0,0,0,0,0
Sans Serif,12,-1,0,50,0,0,0,0,0
Sans Serif,12,-1,5,50,0,0,0,0,0
Sans Serif,15,-1,5,50,0,0,0,0,0
Sans Serif,30,-1,5,50,0,0,0,0,0
Sans Serif,3,-1,5,50,0,0,0,0,0
Sans Serif,4,-1,0,50,0,0,0,0,0
Sans Serif,4,-1,5,0,0,0,0,0,0,normal
Sans Serif,4,-1,5,25,0,0,0,0,0
Sans Serif,4,-1,5,50,0,0,0,0,0
Sans Serif,5,-1,5,25,0,0,0,0,0
Sans Serif,5,-1,5,50,0,0,0,0,0
Sans Serif,6,-1,0,50,0,0,0,0,0
Sans Serif,6,-1,5,0,0,0,0,0,0,normal
Sans Serif,6,-1,5,25,0,0,0,0,0
Sans Serif,6,-1,5,50,0,0,0,0,0
Sans Serif,6,-1,5,50,0,0,0,0,0,Regular
Sans Serif,7,-1,0,50,0,0,0,0,0
Sans Serif,7,-1,5,25,0,0,0,0,0
Sans Serif,7,-1,5,50,0,0,0,0,0
Sans Serif,8,-1,5,0,0,0,0,0,0,normal
Sans Serif,8,-1,5,50,0,0,0,0,0
Sans Serif,9,-1,0,50,0,0,0,0,0
Sans Serif,9,-1,5,0,0,0,0,0,0,normal
Sans Serif,9,-1,5,50,0,0,0,0,0
Sans Serif,9,-1,5,50,0,0,0,0,0,Regular

Just looking at the last two lines we see double ... but not quite:
One font-string ends with a number and the other font-string also includes ",Regular".
If we only replace this

Sans Serif,9,-1,5,50,0,0,0,0,0

by this

Liberation Sans,9,-1,5,50,0,0,0,0,0,Regular

the last line would be changed to

Liberation Sans,9,-1,5,50,0,0,0,0,0,Regular,Regular

what would be wrong!

Inserting an additional element-name is another topic...

Fragen zu QET gehören in dieses Forum und werden nicht per PM beantwortet! – Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: Biblioteca WEG

@scorpio810:

Salut Laurent !

On the way to have a script to insert Catalan translation of names to existing elements, I updated elements with filenames containing blanks in their name by replacing blanks to underscores.
Stay tuned for upgraded elements with Catalan translations...  nomicons/wink

Gruß
  plc-user

Fragen zu QET gehören in dieses Forum und werden nicht per PM beantwortet! – Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: Biblioteca WEG

Hallo plc-user

I was added in 2013 this note for future...

cat patcher\ traduction.txt 
./apply_translation_diff.sh ~/qet_directory/diff.tmp
./set_name.sh elements/capteurs/actionneurs/bvs_oi-3-001-e.elmt es 'BVS OI-3-001-E'

./translations_stat.sh force

elementsA = Antoni_catalan translated

diff -urPp elementsA/ elements/ > 02sources.patch
./apply_translation_diff.sh /home/laurent/qet_element_moderation/Nouveau_dossier4/02sources.diff &> output.txt

Gruß

Laurent

Post's attachments

Attachment icon apply_translation_diff.sh 360 b, 3 downloads since 2025-12-11 

Attachment icon extract_translations_from_diff.sh 123 b, 3 downloads since 2025-12-11 

Attachment icon output.txt 119.97 kb, 7 downloads since 2025-12-11 

Attachment icon set_name.sh 1.14 kb, 3 downloads since 2025-12-11 

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: Biblioteca WEG

See also merge_it script.

Post's attachments

Attachment icon merge_it.sh 1.01 kb, 5 downloads since 2025-12-11 

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: Biblioteca WEG

plc-user wrote:

Salut Laurent,

when we want the fonts to be replaced correctly, we need to include the quote-signs into replacement!
For example:
From the original Oldtimer-Elements in the other thread, we find these font-descriptions:

Noto Sans ExtraBold,10,-1,0,81,0,0,0,0,0,Regular
Noto Sans ExtraBold,5,-1,0,81,0,0,0,0,0,Regular
Noto Sans ExtraBold,6,-1,0,81,0,0,0,0,0,Regular
Noto Sans ExtraBold,7,-1,0,81,0,0,0,0,0,Regular
Noto Sans ExtraBold,9,-1,0,81,0,0,0,0,0,Regular
Sans Serif,10,-1,0,50,0,0,0,0,0
Sans Serif,10,-1,5,50,0,0,0,0,0
Sans Serif,12,-1,0,50,0,0,0,0,0
Sans Serif,12,-1,5,50,0,0,0,0,0
Sans Serif,15,-1,5,50,0,0,0,0,0
Sans Serif,30,-1,5,50,0,0,0,0,0
Sans Serif,3,-1,5,50,0,0,0,0,0
Sans Serif,4,-1,0,50,0,0,0,0,0
Sans Serif,4,-1,5,0,0,0,0,0,0,normal
Sans Serif,4,-1,5,25,0,0,0,0,0
Sans Serif,4,-1,5,50,0,0,0,0,0
Sans Serif,5,-1,5,25,0,0,0,0,0
Sans Serif,5,-1,5,50,0,0,0,0,0
Sans Serif,6,-1,0,50,0,0,0,0,0
Sans Serif,6,-1,5,0,0,0,0,0,0,normal
Sans Serif,6,-1,5,25,0,0,0,0,0
Sans Serif,6,-1,5,50,0,0,0,0,0
Sans Serif,6,-1,5,50,0,0,0,0,0,Regular
Sans Serif,7,-1,0,50,0,0,0,0,0
Sans Serif,7,-1,5,25,0,0,0,0,0
Sans Serif,7,-1,5,50,0,0,0,0,0
Sans Serif,8,-1,5,0,0,0,0,0,0,normal
Sans Serif,8,-1,5,50,0,0,0,0,0
Sans Serif,9,-1,0,50,0,0,0,0,0
Sans Serif,9,-1,5,0,0,0,0,0,0,normal
Sans Serif,9,-1,5,50,0,0,0,0,0
Sans Serif,9,-1,5,50,0,0,0,0,0,Regular

Just looking at the last two lines we see double ... but not quite:
One font-string ends with a number and the other font-string also includes ",Regular".
If we only replace this

Sans Serif,9,-1,5,50,0,0,0,0,0

by this

Liberation Sans,9,-1,5,50,0,0,0,0,0,Regular

the last line would be changed to

Liberation Sans,9,-1,5,50,0,0,0,0,0,Regular,Regular

what would be wrong!

Inserting an additional element-name is another topic...

Hallo plc-user

so maybe this command work

find . -name "*.elmt" -exec  sed -i -e 's/Sans Serif,/Liberation Sans,/g' {} \;

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: Biblioteca WEG

Hallo plc-user!

I just saw your last commits, many thanks to push an very clean Catatan translation PR without noise off XML random attibutes and font family changes, very good job! \o/ nomicons/wink


If you could share your scripts for future translations we can't solving, I would be very grateful.
Yes, I know! It was very simple for end users to use the QET Element editor GUI to add new translations since they could edit .elmt files manually with a text editor.


Until further notice, we advise our translators to translate the ~ 8,500 elements in the official collection by opening each *.elmt file one by one in a good text editor and adding their translations of elements between the XML tags <names>  </names> in the following style:
<name lang="de">Energietechnik</name>
        <name lang="fr">Energie</name>
        <name lang="ar">طاقة</name>
        <name lang="en">Energy</name>
        <name lang="cs">Energie</name>
        <name lang="pl">Energia</name>
        <name lang="es">Energía</name>
        <name lang="it">Energia</name>
        <name lang="el">Ενέργεια</name>
        <name lang="nl">Energie</name>
        <name lang="ru">Сантехника</name>
        <name lang="da">Energi teknik</name>

I think it is easier for new contributors or translators to use QET's integrated editor to get a vector view of the symbol represented in order to better translate the element itself!

Translated with DeepL.com (free version)

Best regards,
Laurent

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: Biblioteca WEG

Salut Laurent !

Unfortunately, replacing fonts involves manual work, as especially commercial operating systems from Redmond append localized parts to font descriptions and don't even shy away from spaces!
Here are a few examples from before the introduction of the Liberation fonts:

Arial,4,-1,5,75,1,0,0,0,0,Gras Italique
Arial Narrow,11,-1,5,75,0,0,0,0,0,Negrito
Arial Narrow Hu,9,-1,5,50,0,0,0,0,0, Normal
Calibri,6,-1,5,75,0,0,0,0,0,Bold
DINosaur Medium,9,-1,5,57,0,0,0,0,0,Medium
MS Shell Dlg 2,10,-1,5,50,0,0,0,0,0,Normál
MS Shell Dlg 2,1,-1,5,50,0,0,0,0,0,obyčejné
MS Shell Dlg 2,4,-1,5,75,0,0,0,0,0,Grassetto
MS Shell Dlg 2,4,-1,5,75,0,0,0,0,0,tučné
MS Shell Dlg 2,8,-1,5,75,0,0,0,0,0,Félkövér
Sans Serif,4,-1,5,0,0,0,0,0,0,ncrmal
URW Gothic [urw],4,-1,5,63,0,0,0,0,0,Demi

As you can see, we definitely have to take the entire font string into account when replacing fonts.
I don't have a complete script for this, but the search/replace function in DoubleCommander helps to avoid having to deal with each file individually.
At least a “translation table” has to be created manually. I don't yet know what a script for processing the files should look like.
For the extraction of font-strings from element-files, I use this part of a bash-script:

for i in  `find . -name "*.elmt"` ; do
  cat "$i" | grep font=\" | awk -F "font=\"" '{ print $2 }' | \
             awk -F "\"" '{ print $1 }' >> /tmp/tempfile.txt
  done
cat /tmp/tempfile.txt | sort | uniq > /tmp/fontstrings.txt

With this list we need to check, which of the Liberation-fonts matches the original best and create a translation-table.

In my opinion, we should only include elements in the official collection that are limited to the four fonts supplied by QET!

Fragen zu QET gehören in dieses Forum und werden nicht per PM beantwortet! – Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: Biblioteca WEG

Salut Laurent !

scorpio810 wrote:

I just saw your last commits, many thanks to push an very clean Catatan translation PR without noise off XML random attibutes and font family changes, very good job! \o/ nomicons/wink

Thank you for the compliment!   nomicons/smile

To create this "clean" diff I used a script to add the translation from the same directory-structure as the official collection!
It searches the given directory for element-files and inside the files for the new translation, takes this and writes that to the same file in the structure of official collection.
Afterwards a new function of QET_ElementScaler sorts the localized names.

Here's the script:

#!/bin/bash
 
# Dieses Skript sucht nach Zeilen, die ein bestimmtes Muster enthalten,
# extrahiert diese und fügt sie in der Zieldatei nach einer Zeile ein,
# die ein anderes Muster enthält.
 
# Konfiguration
SourceDir="Antoni/"
DestDir="QET/"
# Muster, das in der Quelldatei gesucht wird, um Zeilen zu extrahieren
SOURCE_PATTERN="<name lang=\"ca\">"
# Muster, das in der Zieldatei gesucht wird, um die Einfügeposition zu finden (Einfügen erfolgt NACH dieser Zeile)
DEST_PATTERN="<names>"
 
# und nun in einer Schleife alle Element-Dateien bearbeiten
for SOURCE_FILE in  `find ./$SourceDir -name "*.elmt"` ; do
  DEST_FILE=${SOURCE_FILE/"$SourceDir"/"$DestDir"}
  # zur Kontrolle die Dateinamen aufschreiben
  #echo "Source: $SOURCE_FILE --> Destination: $DEST_FILE"
  # wenn die Ziel-Datei ncht existiert --> weiter!
  if [ ! -e "$DEST_FILE" ]; then
    echo "Destination-File '$DEST_FILE' does not exist --> use next SourceFile"
    continue
  fi
  # Wenn in der Ziel-Datei schon eine Zeile mit dem Muster existiert, dann nicht (!) einfügen
  LineInDestFile=$(grep "$SOURCE_PATTERN" "$DEST_FILE")
  if [ -n "$LineInDestFile" ]; then
      echo "Line with '$SOURCE_PATTERN' already exists in '$DEST_FILE'!"
      continue
  fi
  # Zeile(n) aus der Quelldatei extrahieren, die dem Muster entsprechen
  LINES_TO_INSERT=$(grep "$SOURCE_PATTERN" "$SOURCE_FILE")
  # Überprüfen, ob überhaupt Zeilen gefunden wurden
  if [ -z "$LINES_TO_INSERT" ]; then
    echo "Could not find '$SOURCE_PATTERN' in '$SOURCE_FILE'!"
    continue
  fi
  # die extrahierten Zeilen in die Zieldatei einfügen
  # --> sed mit der Option 'a' (append/anhängen nach der passenden Zeile)
  #     die Variable LINES_TO_INSERT kann mehrere Zeilenumbrüche enthalten: Formatieren für sed
  #     Zeilenumbrüche (\n) ersetzen durch das sed-spezifische Escaping (Backslash + tatsächlicher Zeilenumbruch)
  FORMATTED_INSERT=$(echo "$LINES_TO_INSERT" | sed 's/$/\\/')
  FORMATTED_INSERT=${FORMATTED_INSERT%\\} # letzten, unnötigen Backslash entfernen
 
  # sed-Befehl: Finde das Muster in der Zieldatei (/DEST_PATTERN/), hänge die formatierten Zeilen an (a\)
  # sed -i bearbeitet die Datei direkt.
  sed -i "/$DEST_PATTERN/a\\
  $FORMATTED_INSERT"
"$DEST_FILE"
 
  echo "Lines with '$SOURCE_PATTERN' have been inserted after '$DEST_PATTERN' in '$DEST_FILE'."
 
  # zum Schluss räumen wir die frisch ergänzte Datei ein wenig auf
  # und sortieren die Übersetzungen nach Länder-Kürzel:
  /usr/local/bin/QET_ElementScaler --OverwriteOriginal --OnlyCleanMeta "$DEST_FILE"
 
  done

I guess this script can be used in the future, if somebody creates another new language.

Gruß
  plc-user

Fragen zu QET gehören in dieses Forum und werden nicht per PM beantwortet! – Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !