Skip to content

Instantly share code, notes, and snippets.

@ikr
Last active December 21, 2015 12:19
Show Gist options
  • Save ikr/6304717 to your computer and use it in GitHub Desktop.
Save ikr/6304717 to your computer and use it in GitHub Desktop.
#!/bin/bash
for locale in de_ch en_us fr_fr it_it es_es nl_nl
do
curl -s "http://127.0.0.1:5984/translations_$locale/_design/main/_view/empty_namespace"\
| json rows | json -a value | sed 's/}$/}\n,/' | head -n -1\
| (echo '['; cat -; echo ']') | json -e 'namespace = ["default"]' | (echo '{"docs":'; cat -; echo '}')\
| curl -f -H 'Content-Type: application/json' -d @- -X POST "http://127.0.0.1:5984/translations_$locale/_bulk_docs"
done
@ikr
Copy link
Author

ikr commented Aug 22, 2013

What's done with json -a value | sed 's/}$/}\n,/' | head -n -1 here, should theoretically be a json -ag value. But, somehow, it doesn't work :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment