Feature #15454

Improve PO rules: Add check for square bracket count

Added by emmapeel 2018-03-23 11:41:01 . Updated 2020-04-23 10:32:47 .

Status:
Confirmed
Priority:
Low
Assignee:
Category:
Internationalization
Target version:
Start date:
2018-03-23
Due date:
% Done:

0%

Feature Branch:
Type of work:
Communicate
Blueprint:

Starter:
Affected tool:
Translation Platform
Deliverable for:

Description

Our beautiful translators are human after all, and sometimes they don’t copy the ikiwiki syntax quite right.

A simple check could be added to make sure the source and target strings have the same amount of [ and ] characters.

Reasoning:

- If there is an error on the number of brackets, ikiwiki will build without errors but the interface will be broken.


Subtasks


History

#1 Updated by Anonymous 2018-04-24 15:25:49

  • Subject changed from New check to check_po.sh: Check [ and ] characters to New check to check_po.sh: Check for square bracket count
  • Assignee deleted (None)
  • Target version set to Tails_3.8
  • QA Check deleted (Dev Needed)

#2 Updated by Anonymous 2018-04-24 15:26:14

  • Subject changed from New check to check_po.sh: Check for square bracket count to Improve check_po.sh: Add check for square bracket count

#3 Updated by Anonymous 2018-04-24 15:26:25

#4 Updated by Anonymous 2018-05-29 09:18:18

If we add more such checks to check_po.sh we will soon saturate what this file does. It’s written in bash after all. But let’s keep this ticket somewhere, and eventually create some tools for translators who translate using vim or similar at some point.

#5 Updated by Anonymous 2018-06-12 14:28:00

  • Subject changed from Improve check_po.sh: Add check for square bracket count to Improve PO rules: Add check for square bracket count

We might want to add such a check in unify_po_headers.sh instead (this file makes our PO files comply to our rules) and change it’s name..

#6 Updated by Anonymous 2018-06-19 14:03:59

Feel free to improve upon:


#!/bin/sh
# -*- mode: sh; sh-basic-offset: 4; indent-tabs-mode: nil; -*-
# vim: set filetype=sh sw=4 sts=4 expandtab autoindent:
# Usage: ./check_matching_brackets [2-letter language code]

set -e

if [ $# -ge 1 ] ; then
    FILE_GLOB="*.${1}.po"
else
    FILE_GLOB='*.po'
fi

CPUS=$(egrep '^processor[[:space:]]+:' /proc/cpuinfo | wc -l)

# FNAME is full path (./pathto/file.inital.de.po)
# BASENAME is only the name of the file (file.inital.de.po)
# BASENAME1 is the name without po (file.inital.de)
# LANG the language we expect (de)

find -wholename ./tmp -prune -o \( -iname "$FILE_GLOB" -print0 \) \
        | xargs -0 --max-procs="$CPUS" --max-args=64 -I {} \
        awk -v RS= '{if (split($i,a,"[") != split($i,b,"]")) {print "\n"FILENAME"\n"": "$0}}' "{}"

This does mostly work, but we have very weird splits in the po files sometimes which have [[ and ]] in different msgstrings.

#7 Updated by intrigeri 2018-06-26 16:28:05

  • Target version changed from Tails_3.8 to Tails_3.9

#8 Updated by Anonymous 2018-08-07 12:52:46

  • Assignee deleted ()

I’m not interested in implementing this.

#9 Updated by intrigeri 2018-08-07 13:41:04

  • Target version deleted (Tails_3.9)

#10 Updated by intrigeri 2019-06-27 17:14:14

  • Affected tool set to Translation Platform

#11 Updated by intrigeri 2019-06-27 17:14:23

#12 Updated by intrigeri 2019-09-13 10:11:36

  • Type of work changed from Code to Communicate

Next step: request this feature upstream.

#13 Updated by emmapeel 2020-04-23 10:32:47

We don’t need to create or own ‘walker’ through the strings, or .po parser.

We can use the classes available on the Checks module from weblate, see the different types of checks at https://docs.weblate.org/en/weblate-3.5.1/user/checks.html and example check at https://github.com/WeblateOrg/weblate/blob/master/weblate/examples/check_foo.py or https://github.com/WeblateOrg/weblate/blob/master/weblate/examples/check_czech.py