Browse Source

Merge branch 'PFW-1189' of https://github.com/3d-gussner/Prusa-Firmware into PFW-1189

3d-gussner 3 years ago
parent
commit
2281bd1ef7
3 changed files with 35 additions and 22 deletions
  1. 3 1
      lang/config.sh
  2. 22 11
      lang/lang-check.py
  3. 10 10
      lang/lang_en_cz.txt

+ 3 - 1
lang/config.sh

@@ -17,7 +17,9 @@ export OBJCOPY=$ARDUINO/hardware/tools/avr/bin/avr-objcopy
 export OBJDUMP=$ARDUINO/hardware/tools/avr/bin/avr-objdump
 #
 # Output folder:
-export OUTDIR="../../Prusa-Firmware-build"
+if [ -z "$OUTDIR" ]; then
+    export OUTDIR="../../Prusa-Firmware-build"
+fi
 #
 # Objects folder:
 export OBJDIR="$OUTDIR/sketch"

+ 22 - 11
lang/lang-check.py

@@ -15,12 +15,18 @@
 """Check lang files."""
 from argparse import ArgumentParser
 from traceback import print_exc
-from sys import stderr
+from sys import stdout, stderr
 import textwrap
 
-red = lambda text: '\033[0;31m' + text + '\033[0m'
-green = lambda text: '\033[0;32m' + text + '\033[0m'
-yellow = lambda text: '\033[0;33m' + text + '\033[0m'
+def color_maybe(color_attr, text):
+    if stdout.isatty():
+        return '\033[0;' + str(color_attr) + 'm' + text + '\033[0m'
+    else:
+        return text
+
+red = lambda text: color_maybe(31, text)
+green = lambda text: color_maybe(32, text)
+yellow = lambda text: color_maybe(33, text)
 
 def parse_txt(lang, no_warning):
     """Parse txt file and check strings to display definition."""
@@ -36,20 +42,23 @@ def parse_txt(lang, no_warning):
         while True:
             comment = src.readline().split(' ')
             #print (comment) #Debug
-            source = src.readline()[:-1]
+            source = src.readline()[:-1].strip('"')
             #print (source) #Debug
-            translation = src.readline()[:-1]
+            translation = src.readline()[:-1].strip('"')
+            if translation == '\\x00':
+                # crude hack to handle intentionally-empty translations
+                translation = ''
             #print (translation) #Debug
 #Wrap text to 20 chars and rows
             wrapper = textwrap.TextWrapper(width=20)
             #wrap original/source
             rows_count_source = 0
-            for line in wrapper.wrap(source.strip('"')):
+            for line in wrapper.wrap(source):
                 rows_count_source += 1
                 #print (line) #Debug
             #wrap translation
             rows_count_translation = 0
-            for line in wrapper.wrap(translation.strip('"')):
+            for line in wrapper.wrap(translation):
                 rows_count_translation += 1
                 #print (line) #Debug
 #End wrap text
@@ -76,9 +85,11 @@ def parse_txt(lang, no_warning):
             if rows is None:
                 rows = 1
 
-            if rows_count_translation > rows_count_source and rows_count_translation > rows:
-                print(red("[E]: Text %s is longer then definition on line %d rows diff=%d\n[EN]:Text %s cols=%d rows=%d\n" % (translation, lines, rows_count_translation-rows, source, cols, rows)))
-                
+            if (rows_count_translation > rows_count_source and rows_count_translation > rows) or \
+                    (rows == 1 and len(translation) > cols):
+                print(red('[E]: Text "%s" is longer then definition on line %d (rows diff=%d)\n'
+                          '[EN]:Text "%s" cols=%d rows=%d\n' % (translation, lines, rows_count_translation-rows, source, cols, rows)))
+
 
             if len(src.readline()) != 1:  # empty line
                 break

+ 10 - 10
lang/lang_en_cz.txt

@@ -140,7 +140,7 @@
 
 #MSG_CALIBRATING_HOME c=20
 "Calibrating home"
-"Kalibruji vychozi poz."
+"Kalibruji vychozi p."
 
 #MSG_CALIBRATE_BED c=18
 "Calibrate XYZ"
@@ -600,7 +600,7 @@
 
 #MSG_MEASURED_SKEW c=13
 "Measured skew"
-"Merene zkoseni"
+"Merene zkos."
 
 #MSG_MMU_FAILS c=15
 "MMU fails"
@@ -612,7 +612,7 @@
 
 #MSG_MMU_LOAD_FAILS c=15
 "MMU load fails"
-"MMU selhani zavadeni"
+"MMU selhani zav"
 
 #MSG_MMU_OK_RESUMING c=20 r=4
 "MMU OK. Resuming..."
@@ -640,7 +640,7 @@
 
 #MSG_MMU_POWER_FAILS c=15
 "MMU power fails"
-"MMU vypadky proudu"
+"MMU vyp. proudu"
 
 #MSG_STEALTH c=7
 "Stealth"
@@ -648,7 +648,7 @@
 
 #MSG_AUTO_POWER c=10
 "Auto power"
-"Automaticky"
+"Automat."
 
 #MSG_HIGH_POWER c=10
 "High power"
@@ -728,7 +728,7 @@
 
 #MSG_NOZZLE_FAN c=10
 "Nozzle FAN"
-"Vent. trysky"
+"V. trysky"
 
 #MSG_PAUSE_PRINT c=18
 "Pause print"
@@ -864,7 +864,7 @@
 
 #MSG_PRESS_KNOB c=20
 "Press the knob"
-"Stisknete hl. tlacitko"
+"Stisknete tlacitko"
 
 #MSG_PRINT_PAUSED c=20
 "Print paused"
@@ -880,7 +880,7 @@
 
 #MSG_PRINT_FAN c=10
 "Print FAN"
-"Tiskovy vent."
+"Tiskovy v."
 
 #MSG_WIZARD_LOAD_FILAMENT c=20 r=6
 "Please insert filament into the extruder, then press the knob to load it."
@@ -1040,7 +1040,7 @@
 
 #MSG_SEVERE_SKEW c=13
 "Severe skew:"
-"Tezke zkoseni:"
+"Tezke zkos.:"
 
 #MSG_SORT_ALPHA c=8
 "Alphabet"
@@ -1056,7 +1056,7 @@
 
 #MSG_SLIGHT_SKEW c=13
 "Slight skew:"
-"Lehke zkoseni:"
+"Lehke zkos.:"
 
 #MSG_SOUND c=7
 "Sound"