[new downloader] Added localization tools

This commit is contained in:
Constantin Shalnev 2016-02-11 17:58:33 +03:00 committed by Sergey Yershov
parent 51712def0c
commit 05941957b5
4 changed files with 70 additions and 0 deletions

View file

@ -0,0 +1,30 @@
#!/usr/bin/python
import sys, csv
if len(sys.argv) < 4:
print 'Converting Google Docs translation CSV to strings.txt format'
print 'Translation valid only for page "Small mwm names" in document:'
print 'https://docs.google.com/spreadsheets/d/1dKhThUersOGoUyOCx5OfGMXEjs1LBmTFcIsTc_nGxZc/edit#gid=1022107578'
print 'Usage: {0} <source.csv> <output.txt> <languages.txt>'.format(sys.argv[0])
sys.exit(1)
def GetName(n):
return n[:n.index(' ')]
languages = set()
with open(sys.argv[2], 'w') as o:
with open(sys.argv[1], 'r') as f:
reader = csv.reader(f)
reader.next()
header = reader.next()
for row in reader:
print >> o, '[{0}]'.format(row[0])
for i in range(1, len(header)):
languages.add(GetName(format(header[i])))
print >> o, '{0}{1}'.format(header[i], row[i])
print >> o
with open(sys.argv[3], 'w') as l:
print >> l, " ".join(languages)

View file

@ -0,0 +1,26 @@
#!/bin/bash
set -e -u -x
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
readonly TMP_DIR=$MY_PATH/../../../localization/countries_names-tmp
readonly DATA_DIR=$MY_PATH/../../../localization/countries_names
rm -rf $TMP_DIR
mkdir $TMP_DIR
python $MY_PATH/csv_to_txt.py $DATA_DIR/countries_names.csv $DATA_DIR/countries_names.txt $DATA_DIR/languages.txt
mkdir $TMP_DIR/json
python $MY_PATH/mk_lang_dirs.py $DATA_DIR/languages.txt $TMP_DIR/json/
$MY_PATH/../../twine/twine --format jquery generate-all-string-files $DATA_DIR/countries_names.txt $TMP_DIR/json
readonly OUTPUT_DIR=$MY_PATH/../../../data/countries-strings/
if [ ! -d $OUTPUT_DIR ]; then
mkdir $OUTPUT_DIR
fi
cp -R $TMP_DIR/json/ $OUTPUT_DIR
rm -rf $TMP_DIR

View file

@ -0,0 +1,14 @@
#!/usr/bin/python
import os, sys
if len(sys.argv) < 3:
print 'Creation or resource directories for the languages'
print 'Usage: {0} <languages.txt> <path_to_dir_with_jsons>'.format(sys.argv[0])
sys.exit(1)
with open(sys.argv[1], "r") as langs_file:
for lang in langs_file.read().split():
new_dir = os.path.join(sys.argv[2], lang + ".json")
if not os.path.exists(new_dir):
os.makedirs(new_dir)