Procházet zdrojové kódy

Avoid annoying email message when creating translations

Bob Mottram před 9 roky
rodič
revize
70d115a2dd

+ 2
- 0
Makefile Zobrazit soubor

7
 	bash -c "./translate make"
7
 	bash -c "./translate make"
8
 debug:
8
 debug:
9
 	bash -c "./translate make"
9
 	bash -c "./translate make"
10
+translations:
11
+	bash -c "./translate translations"
10
 source:
12
 source:
11
 	tar -cvf ../${APP}_${VERSION}.orig.tar ../${APP}-${VERSION} --exclude-vcs
13
 	tar -cvf ../${APP}_${VERSION}.orig.tar ../${APP}-${VERSION} --exclude-vcs
12
 	gzip -f9n ../${APP}_${VERSION}.orig.tar
14
 	gzip -f9n ../${APP}_${VERSION}.orig.tar

+ 8
- 0
locale/de/freedombone-controlpanel.json Zobrazit soubor

93
     "Change the name of this system": "",
93
     "Change the name of this system": "",
94
     "New local network name": "",
94
     "New local network name": "",
95
     "The name of this system on your local network was changed successfully": "",
95
     "The name of this system on your local network was changed successfully": "",
96
+    "Set the TLS date/time source": "",
97
+    "Enter a domain name to use as a TLS time source.\\n\\nFactors to consider when choosing a source are whether you wish that site to know that your system is 'alive' and also what might happen if an adversary were to try to mess with the date/time from that domain (i.e. how much blowback would there be).": "",
98
+    "Don't include the 'https'": "",
99
+    "That doesn't look like a domain name": "",
100
+    "Set a static local IP address": "",
101
+    "In order to forward incoming internet traffic to this system most internet routers need to know a static local IP address to send the data to.\\n\\n\nEnter a static local IP address for this system.\\n\\nIt will typically be 192.168.1.x": "",
102
+    "Set the IP address of your internet router/modem": "",
103
+    "Set the local IP address for your internet router or ADSL modem.\\n\\nIt will typically be 192.168.1.1, 192.168.1.254, or similar": "",
96
     "Backup and Restore": "",
104
     "Backup and Restore": "",
97
     "Choose an operation:": "",
105
     "Choose an operation:": "",
98
     "Backup data to USB drive": "",
106
     "Backup data to USB drive": "",

+ 1
- 1
locale/de/freedombone-image.json Zobrazit soubor

2
     "Config file $CONFIG_FILENAME not found": "",
2
     "Config file $CONFIG_FILENAME not found": "",
3
     "Your password chould contain at least ${MINIMUM_PASSWORD_LENGTH} characters": "",
3
     "Your password chould contain at least ${MINIMUM_PASSWORD_LENGTH} characters": "",
4
     "\nImage was created.\n\nYou will be able to log into it with:\n": "",
4
     "\nImage was created.\n\nYou will be able to log into it with:\n": "",
5
-    "    ssh $USERNAME@$DEFAULT_DOMAIN_NAME -p 2222\n\n    Password: $PASSWORD\n": "",
5
+    "    ssh $USERNAME@$DEFAULT_DOMAIN_NAME -p $SSH_PORT\n\n    Password: $PASSWORD\n": "",
6
     "    Username: $USERNAME\n    Password: $PASSWORD\n": "",
6
     "    Username: $USERNAME\n    Password: $PASSWORD\n": "",
7
     "\n    Username: $USERNAME\n    Password: $PASSWORD\n": "",
7
     "\n    Username: $USERNAME\n    Password: $PASSWORD\n": "",
8
     "Username: $USERNAME\nPassword: $PASSWORD": ""
8
     "Username: $USERNAME\nPassword: $PASSWORD": ""

+ 2
- 0
locale/de/freedombone-sec.json Zobrazit soubor

20
     "An existing certificate for $renew_domain was not found": "",
20
     "An existing certificate for $renew_domain was not found": "",
21
     "Invalid domain name: $renew_domain": "",
21
     "Invalid domain name: $renew_domain": "",
22
     "Renew a Let's Encrypt certificate": "",
22
     "Renew a Let's Encrypt certificate": "",
23
+    "Create a new Let's Encrypt certificate": "",
24
+    "Invalid domain name: $new_domain": "",
23
     "Import file $IMPORT_FILE not found": "",
25
     "Import file $IMPORT_FILE not found": "",
24
     "Security settings exported to $EXPORT_FILE": ""
26
     "Security settings exported to $EXPORT_FILE": ""
25
 }
27
 }

+ 8
- 0
locale/es/freedombone-controlpanel.json Zobrazit soubor

93
     "Change the name of this system": "",
93
     "Change the name of this system": "",
94
     "New local network name": "",
94
     "New local network name": "",
95
     "The name of this system on your local network was changed successfully": "",
95
     "The name of this system on your local network was changed successfully": "",
96
+    "Set the TLS date/time source": "",
97
+    "Enter a domain name to use as a TLS time source.\\n\\nFactors to consider when choosing a source are whether you wish that site to know that your system is 'alive' and also what might happen if an adversary were to try to mess with the date/time from that domain (i.e. how much blowback would there be).": "",
98
+    "Don't include the 'https'": "",
99
+    "That doesn't look like a domain name": "",
100
+    "Set a static local IP address": "",
101
+    "In order to forward incoming internet traffic to this system most internet routers need to know a static local IP address to send the data to.\\n\\n\nEnter a static local IP address for this system.\\n\\nIt will typically be 192.168.1.x": "",
102
+    "Set the IP address of your internet router/modem": "",
103
+    "Set the local IP address for your internet router or ADSL modem.\\n\\nIt will typically be 192.168.1.1, 192.168.1.254, or similar": "",
96
     "Backup and Restore": "",
104
     "Backup and Restore": "",
97
     "Choose an operation:": "",
105
     "Choose an operation:": "",
98
     "Backup data to USB drive": "",
106
     "Backup data to USB drive": "",

+ 1
- 1
locale/es/freedombone-image.json Zobrazit soubor

2
     "Config file $CONFIG_FILENAME not found": "",
2
     "Config file $CONFIG_FILENAME not found": "",
3
     "Your password chould contain at least ${MINIMUM_PASSWORD_LENGTH} characters": "",
3
     "Your password chould contain at least ${MINIMUM_PASSWORD_LENGTH} characters": "",
4
     "\nImage was created.\n\nYou will be able to log into it with:\n": "",
4
     "\nImage was created.\n\nYou will be able to log into it with:\n": "",
5
-    "    ssh $USERNAME@$DEFAULT_DOMAIN_NAME -p 2222\n\n    Password: $PASSWORD\n": "",
5
+    "    ssh $USERNAME@$DEFAULT_DOMAIN_NAME -p $SSH_PORT\n\n    Password: $PASSWORD\n": "",
6
     "    Username: $USERNAME\n    Password: $PASSWORD\n": "",
6
     "    Username: $USERNAME\n    Password: $PASSWORD\n": "",
7
     "\n    Username: $USERNAME\n    Password: $PASSWORD\n": "",
7
     "\n    Username: $USERNAME\n    Password: $PASSWORD\n": "",
8
     "Username: $USERNAME\nPassword: $PASSWORD": ""
8
     "Username: $USERNAME\nPassword: $PASSWORD": ""

+ 2
- 0
locale/es/freedombone-sec.json Zobrazit soubor

20
     "An existing certificate for $renew_domain was not found": "",
20
     "An existing certificate for $renew_domain was not found": "",
21
     "Invalid domain name: $renew_domain": "",
21
     "Invalid domain name: $renew_domain": "",
22
     "Renew a Let's Encrypt certificate": "",
22
     "Renew a Let's Encrypt certificate": "",
23
+    "Create a new Let's Encrypt certificate": "",
24
+    "Invalid domain name: $new_domain": "",
23
     "Import file $IMPORT_FILE not found": "",
25
     "Import file $IMPORT_FILE not found": "",
24
     "Security settings exported to $EXPORT_FILE": ""
26
     "Security settings exported to $EXPORT_FILE": ""
25
 }
27
 }

+ 8
- 0
locale/fr/freedombone-controlpanel.json Zobrazit soubor

93
     "Change the name of this system": "",
93
     "Change the name of this system": "",
94
     "New local network name": "",
94
     "New local network name": "",
95
     "The name of this system on your local network was changed successfully": "",
95
     "The name of this system on your local network was changed successfully": "",
96
+    "Set the TLS date/time source": "",
97
+    "Enter a domain name to use as a TLS time source.\\n\\nFactors to consider when choosing a source are whether you wish that site to know that your system is 'alive' and also what might happen if an adversary were to try to mess with the date/time from that domain (i.e. how much blowback would there be).": "",
98
+    "Don't include the 'https'": "",
99
+    "That doesn't look like a domain name": "",
100
+    "Set a static local IP address": "",
101
+    "In order to forward incoming internet traffic to this system most internet routers need to know a static local IP address to send the data to.\\n\\n\nEnter a static local IP address for this system.\\n\\nIt will typically be 192.168.1.x": "",
102
+    "Set the IP address of your internet router/modem": "",
103
+    "Set the local IP address for your internet router or ADSL modem.\\n\\nIt will typically be 192.168.1.1, 192.168.1.254, or similar": "",
96
     "Backup and Restore": "",
104
     "Backup and Restore": "",
97
     "Choose an operation:": "",
105
     "Choose an operation:": "",
98
     "Backup data to USB drive": "",
106
     "Backup data to USB drive": "",

+ 1
- 1
locale/fr/freedombone-image.json Zobrazit soubor

2
     "Config file $CONFIG_FILENAME not found": "",
2
     "Config file $CONFIG_FILENAME not found": "",
3
     "Your password chould contain at least ${MINIMUM_PASSWORD_LENGTH} characters": "",
3
     "Your password chould contain at least ${MINIMUM_PASSWORD_LENGTH} characters": "",
4
     "\nImage was created.\n\nYou will be able to log into it with:\n": "",
4
     "\nImage was created.\n\nYou will be able to log into it with:\n": "",
5
-    "    ssh $USERNAME@$DEFAULT_DOMAIN_NAME -p 2222\n\n    Password: $PASSWORD\n": "",
5
+    "    ssh $USERNAME@$DEFAULT_DOMAIN_NAME -p $SSH_PORT\n\n    Password: $PASSWORD\n": "",
6
     "    Username: $USERNAME\n    Password: $PASSWORD\n": "",
6
     "    Username: $USERNAME\n    Password: $PASSWORD\n": "",
7
     "\n    Username: $USERNAME\n    Password: $PASSWORD\n": "",
7
     "\n    Username: $USERNAME\n    Password: $PASSWORD\n": "",
8
     "Username: $USERNAME\nPassword: $PASSWORD": ""
8
     "Username: $USERNAME\nPassword: $PASSWORD": ""

+ 2
- 0
locale/fr/freedombone-sec.json Zobrazit soubor

20
     "An existing certificate for $renew_domain was not found": "",
20
     "An existing certificate for $renew_domain was not found": "",
21
     "Invalid domain name: $renew_domain": "",
21
     "Invalid domain name: $renew_domain": "",
22
     "Renew a Let's Encrypt certificate": "",
22
     "Renew a Let's Encrypt certificate": "",
23
+    "Create a new Let's Encrypt certificate": "",
24
+    "Invalid domain name: $new_domain": "",
23
     "Import file $IMPORT_FILE not found": "",
25
     "Import file $IMPORT_FILE not found": "",
24
     "Security settings exported to $EXPORT_FILE": ""
26
     "Security settings exported to $EXPORT_FILE": ""
25
 }
27
 }

+ 14
- 6
translate Zobrazit soubor

33
 # languages to translate into
33
 # languages to translate into
34
 language=( fr de es )
34
 language=( fr de es )
35
 
35
 
36
+MY_EMAIL_ADDRESS='bob@robotics.uk.to'
37
+
36
 COMMAND_FILES=src/${PROJECT_NAME}*
38
 COMMAND_FILES=src/${PROJECT_NAME}*
37
 
39
 
38
 function install_i18next-conv {
40
 function install_i18next-conv {
52
 }
54
 }
53
 
55
 
54
 function create_translation_files {
56
 function create_translation_files {
57
+	create_arg=$1
55
     if [ ! -d /tmp/${PROJECT_NAME} ]; then
58
     if [ ! -d /tmp/${PROJECT_NAME} ]; then
56
         mkdir -p /tmp/${PROJECT_NAME}
59
         mkdir -p /tmp/${PROJECT_NAME}
57
     fi
60
     fi
59
     for f in $COMMAND_FILES
62
     for f in $COMMAND_FILES
60
     do
63
     do
61
         COMMAND_NAME=$(echo $f | awk -F '/' '{print $2}')
64
         COMMAND_NAME=$(echo $f | awk -F '/' '{print $2}')
62
-        bash --dump-po-strings src/${COMMAND_NAME} | xgettext -L PO -o /tmp/${PROJECT_NAME}/${COMMAND_NAME}.pot -
65
+        bash --dump-po-strings src/${COMMAND_NAME} | xgettext --msgid-bugs-address=$MY_EMAIL_ADDRESS -L PO -o /tmp/${PROJECT_NAME}/${COMMAND_NAME}.pot -
63
         if [ -f /tmp/${PROJECT_NAME}/${COMMAND_NAME}.pot ]; then
66
         if [ -f /tmp/${PROJECT_NAME}/${COMMAND_NAME}.pot ]; then
64
             for lang in "${language[@]}"
67
             for lang in "${language[@]}"
65
             do
68
             do
67
                     mkdir -p locale/${lang}
70
                     mkdir -p locale/${lang}
68
                 fi
71
                 fi
69
 
72
 
70
-                if [ ! -f locale/${lang}/${COMMAND_NAME}.json ]; then
73
+                if [[ ! -f locale/${lang}/${COMMAND_NAME}.json || "$create_arg" == "overwrite" ]]; then
71
                     # create po file
74
                     # create po file
72
                     echo "Creating ${lang} Translation file for ${COMMAND_NAME}..."
75
                     echo "Creating ${lang} Translation file for ${COMMAND_NAME}..."
73
-                    msginit -l ${lang} -i /tmp/${PROJECT_NAME}/${COMMAND_NAME}.pot -o locale/${lang}/${COMMAND_NAME}.po
76
+                    msginit --no-translator -l ${lang} -i /tmp/${PROJECT_NAME}/${COMMAND_NAME}.pot -o locale/${lang}/${COMMAND_NAME}.po
77
+					echo 'testing'
74
 
78
 
75
                     # convert po to json
79
                     # convert po to json
76
                     if [ -f /usr/bin/i18next-conv ]; then
80
                     if [ -f /usr/bin/i18next-conv ]; then
77
                         if [ -f locale/${lang}/${COMMAND_NAME}.po ]; then
81
                         if [ -f locale/${lang}/${COMMAND_NAME}.po ]; then
78
-                            if [ ! -f locale/${lang}/${COMMAND_NAME}.json ]; then
79
-                                i18next-conv -l ${lang} -s locale/${lang}/${COMMAND_NAME}.po -t locale/${lang}/${COMMAND_NAME}.json
80
-                            fi
82
+                            i18next-conv -l ${lang} -s locale/${lang}/${COMMAND_NAME}.po -t locale/${lang}/${COMMAND_NAME}.json
81
                         fi
83
                         fi
82
                     fi
84
                     fi
83
 
85
 
125
     done
127
     done
126
 }
128
 }
127
 
129
 
130
+if [[ $1 == "translation"* ]]; then
131
+    install_i18next-conv
132
+    create_translation_files overwrite
133
+    exit 0
134
+fi
135
+
128
 if [[ $1 == "make" ]]; then
136
 if [[ $1 == "make" ]]; then
129
     install_i18next-conv
137
     install_i18next-conv
130
     create_translation_files
138
     create_translation_files