Avoid annoying email message when creating translations

This commit is contained in:
Bob Mottram 2015-12-07 15:14:25 +00:00
parent 4a9bed8e9c
commit 70d115a2dd
11 changed files with 49 additions and 9 deletions

View File

@ -7,6 +7,8 @@ all:
bash -c "./translate make" bash -c "./translate make"
debug: debug:
bash -c "./translate make" bash -c "./translate make"
translations:
bash -c "./translate translations"
source: source:
tar -cvf ../${APP}_${VERSION}.orig.tar ../${APP}-${VERSION} --exclude-vcs tar -cvf ../${APP}_${VERSION}.orig.tar ../${APP}-${VERSION} --exclude-vcs
gzip -f9n ../${APP}_${VERSION}.orig.tar gzip -f9n ../${APP}_${VERSION}.orig.tar

View File

@ -93,6 +93,14 @@
"Change the name of this system": "", "Change the name of this system": "",
"New local network name": "", "New local network name": "",
"The name of this system on your local network was changed successfully": "", "The name of this system on your local network was changed successfully": "",
"Set the TLS date/time source": "",
"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).": "",
"Don't include the 'https'": "",
"That doesn't look like a domain name": "",
"Set a static local IP address": "",
"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": "",
"Set the IP address of your internet router/modem": "",
"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": "",
"Backup and Restore": "", "Backup and Restore": "",
"Choose an operation:": "", "Choose an operation:": "",
"Backup data to USB drive": "", "Backup data to USB drive": "",

View File

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

View File

@ -20,6 +20,8 @@
"An existing certificate for $renew_domain was not found": "", "An existing certificate for $renew_domain was not found": "",
"Invalid domain name: $renew_domain": "", "Invalid domain name: $renew_domain": "",
"Renew a Let's Encrypt certificate": "", "Renew a Let's Encrypt certificate": "",
"Create a new Let's Encrypt certificate": "",
"Invalid domain name: $new_domain": "",
"Import file $IMPORT_FILE not found": "", "Import file $IMPORT_FILE not found": "",
"Security settings exported to $EXPORT_FILE": "" "Security settings exported to $EXPORT_FILE": ""
} }

View File

@ -93,6 +93,14 @@
"Change the name of this system": "", "Change the name of this system": "",
"New local network name": "", "New local network name": "",
"The name of this system on your local network was changed successfully": "", "The name of this system on your local network was changed successfully": "",
"Set the TLS date/time source": "",
"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).": "",
"Don't include the 'https'": "",
"That doesn't look like a domain name": "",
"Set a static local IP address": "",
"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": "",
"Set the IP address of your internet router/modem": "",
"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": "",
"Backup and Restore": "", "Backup and Restore": "",
"Choose an operation:": "", "Choose an operation:": "",
"Backup data to USB drive": "", "Backup data to USB drive": "",

View File

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

View File

@ -20,6 +20,8 @@
"An existing certificate for $renew_domain was not found": "", "An existing certificate for $renew_domain was not found": "",
"Invalid domain name: $renew_domain": "", "Invalid domain name: $renew_domain": "",
"Renew a Let's Encrypt certificate": "", "Renew a Let's Encrypt certificate": "",
"Create a new Let's Encrypt certificate": "",
"Invalid domain name: $new_domain": "",
"Import file $IMPORT_FILE not found": "", "Import file $IMPORT_FILE not found": "",
"Security settings exported to $EXPORT_FILE": "" "Security settings exported to $EXPORT_FILE": ""
} }

View File

@ -93,6 +93,14 @@
"Change the name of this system": "", "Change the name of this system": "",
"New local network name": "", "New local network name": "",
"The name of this system on your local network was changed successfully": "", "The name of this system on your local network was changed successfully": "",
"Set the TLS date/time source": "",
"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).": "",
"Don't include the 'https'": "",
"That doesn't look like a domain name": "",
"Set a static local IP address": "",
"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": "",
"Set the IP address of your internet router/modem": "",
"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": "",
"Backup and Restore": "", "Backup and Restore": "",
"Choose an operation:": "", "Choose an operation:": "",
"Backup data to USB drive": "", "Backup data to USB drive": "",

View File

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

View File

@ -20,6 +20,8 @@
"An existing certificate for $renew_domain was not found": "", "An existing certificate for $renew_domain was not found": "",
"Invalid domain name: $renew_domain": "", "Invalid domain name: $renew_domain": "",
"Renew a Let's Encrypt certificate": "", "Renew a Let's Encrypt certificate": "",
"Create a new Let's Encrypt certificate": "",
"Invalid domain name: $new_domain": "",
"Import file $IMPORT_FILE not found": "", "Import file $IMPORT_FILE not found": "",
"Security settings exported to $EXPORT_FILE": "" "Security settings exported to $EXPORT_FILE": ""
} }

View File

@ -33,6 +33,8 @@ PROJECT_NAME='freedombone'
# languages to translate into # languages to translate into
language=( fr de es ) language=( fr de es )
MY_EMAIL_ADDRESS='bob@robotics.uk.to'
COMMAND_FILES=src/${PROJECT_NAME}* COMMAND_FILES=src/${PROJECT_NAME}*
function install_i18next-conv { function install_i18next-conv {
@ -52,6 +54,7 @@ function install_i18next-conv {
} }
function create_translation_files { function create_translation_files {
create_arg=$1
if [ ! -d /tmp/${PROJECT_NAME} ]; then if [ ! -d /tmp/${PROJECT_NAME} ]; then
mkdir -p /tmp/${PROJECT_NAME} mkdir -p /tmp/${PROJECT_NAME}
fi fi
@ -59,7 +62,7 @@ function create_translation_files {
for f in $COMMAND_FILES for f in $COMMAND_FILES
do do
COMMAND_NAME=$(echo $f | awk -F '/' '{print $2}') COMMAND_NAME=$(echo $f | awk -F '/' '{print $2}')
bash --dump-po-strings src/${COMMAND_NAME} | xgettext -L PO -o /tmp/${PROJECT_NAME}/${COMMAND_NAME}.pot - bash --dump-po-strings src/${COMMAND_NAME} | xgettext --msgid-bugs-address=$MY_EMAIL_ADDRESS -L PO -o /tmp/${PROJECT_NAME}/${COMMAND_NAME}.pot -
if [ -f /tmp/${PROJECT_NAME}/${COMMAND_NAME}.pot ]; then if [ -f /tmp/${PROJECT_NAME}/${COMMAND_NAME}.pot ]; then
for lang in "${language[@]}" for lang in "${language[@]}"
do do
@ -67,17 +70,16 @@ function create_translation_files {
mkdir -p locale/${lang} mkdir -p locale/${lang}
fi fi
if [ ! -f locale/${lang}/${COMMAND_NAME}.json ]; then if [[ ! -f locale/${lang}/${COMMAND_NAME}.json || "$create_arg" == "overwrite" ]]; then
# create po file # create po file
echo "Creating ${lang} Translation file for ${COMMAND_NAME}..." echo "Creating ${lang} Translation file for ${COMMAND_NAME}..."
msginit -l ${lang} -i /tmp/${PROJECT_NAME}/${COMMAND_NAME}.pot -o locale/${lang}/${COMMAND_NAME}.po msginit --no-translator -l ${lang} -i /tmp/${PROJECT_NAME}/${COMMAND_NAME}.pot -o locale/${lang}/${COMMAND_NAME}.po
echo 'testing'
# convert po to json # convert po to json
if [ -f /usr/bin/i18next-conv ]; then if [ -f /usr/bin/i18next-conv ]; then
if [ -f locale/${lang}/${COMMAND_NAME}.po ]; then if [ -f locale/${lang}/${COMMAND_NAME}.po ]; then
if [ ! -f locale/${lang}/${COMMAND_NAME}.json ]; then i18next-conv -l ${lang} -s locale/${lang}/${COMMAND_NAME}.po -t locale/${lang}/${COMMAND_NAME}.json
i18next-conv -l ${lang} -s locale/${lang}/${COMMAND_NAME}.po -t locale/${lang}/${COMMAND_NAME}.json
fi
fi fi
fi fi
@ -125,6 +127,12 @@ function uninstall_translations {
done done
} }
if [[ $1 == "translation"* ]]; then
install_i18next-conv
create_translation_files overwrite
exit 0
fi
if [[ $1 == "make" ]]; then if [[ $1 == "make" ]]; then
install_i18next-conv install_i18next-conv
create_translation_files create_translation_files