Skip to content

Commit

Permalink
Add tooling for managing the translations of the app description
Browse files Browse the repository at this point in the history
  • Loading branch information
hellais committed Mar 17, 2017
1 parent 0cd705b commit f26405b
Show file tree
Hide file tree
Showing 4 changed files with 275 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .tx/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[main]
host = https://www.transifex.com

#[ooniprobe.stringsxml]
#file_filter = res/values-<lang>/strings.xml
#source_file = res/values/strings.xml
#source_lang = en
#type = ANDROID

[ooniprobe.description]
file_filter = description/<lang>.xlf
source_file = description/source.xlf
source_lang = en
type = XLIFF
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,49 @@ If you wish to test the apk inside of an emulator this can be done with
```

The app should then be installed inside of the emulator `Nexus_5_API_23_marshmallow_6.0`.

## Managing translations

To manage translations ensure you have installed the [transifex command line
tools](https://docs.transifex.com/client/installing-the-client).

### Pushing source text

To push the source of the translation run:

```
tx push -s
```

### Pulling translations

To pull in translations run:

```
tx pull
```

or

```
tx pull -l [lang_code]
```

to pull only a specific language


### Generating descriptions for market

To generate translated descriptions for the markets run:

```
python scripts/gen-descriptions.py [lang_code]
```

Where `lang_code` is the language code for the description you want to
generate.

This will print to standard output the translated text that you can then copy
and paste into the market descriptions.

If a string is not translated it will print the source for the text.
100 changes: 100 additions & 0 deletions description/source.xlf
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.2">
<file datatype="plaintext" original="source.xlf" source-language="en">
<header>
<note from="developer">Google places strick character limits on the various text fields in Google Play. The title is 30 characters, the short description is 80 characters, and the rest of the strings, which all go together in the description, are limited to 4000 characters.</note>
</header>
<body>
<trans-unit id="title" size-unit="char" maxwidth="30">
<source>ooniprobe</source>
<note from="developer">This is limited by Google to 30 characters</note>
</trans-unit>
<trans-unit id="shortdescription" size-unit="char" maxwidth="80">
<source>Measure Internet Censorship, Speed &#038; Performance</source>
<note from="developer">This is limited by Google to 80 characters</note>
</trans-unit>
<trans-unit id="intro">
<source>Interested in collecting evidence of Internet censorship? Curious about the speed and performance of the network that you are using?
</source>
</trans-unit>
<trans-unit id="intro2">
<source>By running the tests in this app, you will examine the following:</source>
</trans-unit>
<trans-unit id="intro-bullet-1">
<source>• Blocking of websites</source>
</trans-unit>
<trans-unit id="intro-bullet-2">
<source>• Presence of systems that could be responsible for censorship and/or surveillance</source>
</trans-unit>
<trans-unit id="intro-bullet-3">
<source>• Speed and performance of your network</source>
</trans-unit>
<trans-unit id="intro3">
<source>These tests have been developed by the Open Observatory of Network Interference (OONI), a free software project (under The Tor Project) that aims to uncover Internet censorship around the world.</source>
</trans-unit>
<trans-unit id="intro4">
<source>Since 2012, OONI has collected millions of network measurements across more than 190 countries, shedding light on multiple cases of network interference. By running these tests, you will help increase transparency around Internet censorship and network interference around the world.</source>
</trans-unit>
<trans-unit id="evidence-title">
<source>Collecting evidence of internet censorship</source>
</trans-unit>
<trans-unit id="evidence-description">
<source>OONI's web connectivity test is designed to examine whether websites are blocked and if so, how. This test, in particular, attempts to determine whether access to sites is blocked through DNS tampering, TCP/IP blocking, or by a transparent HTTP proxy. By knowing how access to sites is interfered with, you can more easily evaluate how to circumvent that specific type of censorship. As OONI is committed to transparency through the publication of all network measurement data, you can use it as evidence of any censorship events that you come across.</source>
</trans-unit>
<trans-unit id="systems-title">
<source>Detecting systems responsible for censorship and surveillance</source>
</trans-unit>
<trans-unit id="systems-description">
<source>Various types of proxy technologies are used in networks for implementing censorship, surveillance, and traffic manipulation. OONI's HTTP invalid request line test is designed to uncover the presence of such systems within tested networks. However, it's important to point out that not all systems that you might find are necessarily responsible for censorship and/or surveillance! Many proxy technologies, for example, are used in networks for caching purposes.</source>
</trans-unit>
<trans-unit id="speed-title">
<source>Measuring the speed and performance of your network</source>
</trans-unit>
<trans-unit id="speed-description">
<source>Sometimes the network that we are using doesn't work as well as we'd like it to. OONI's implementation of the Network Diagnostic Test (NDT) attempts to measure the speed of your network by connecting to mLab servers near you and by subsequently uploading and downloading random data. In doing so, NDT collects low level TCP/IP information that can help characterize the speed and performance of your network. Such information can also be useful in examining cases of throttling.</source>
</trans-unit>
<trans-unit id="opendata-title">
<source>Open data</source>
</trans-unit>
<trans-unit id="opendata-description">
<source>OONI publishes all network measurement data that it collects and processes because open data allows third parties to conduct independent studies, to verify OONI findings and/or to answer other research questions. Such data also helps increase transparency around Internet censorship and various forms of network interference. All data is published on OONI Explorer: https://explorer.ooni.torproject.org/</source>
</trans-unit>
<trans-unit id="freesoftware-title">
<source>Free software</source>
</trans-unit>
<trans-unit id="freesoftware-description">
<source>All OONI tests, as well as its NDT implementation, are based on free and open source software. You can find the source code through the following link: https://github.com/thetorproject/ooniprobe-ios</source>
</trans-unit>

<trans-unit id="social-links">
<source>Follow us on Twitter: https://twitter.com/OpenObservatory</source>
</trans-unit>

<trans-unit id="disclaimer">
<source>Please note: Running ooniprobe might be against the terms of service of your ISP or legally questionable in your country. By running ooniprobe you will connect to web services which may be banned, and use web censorship circumvention methods such as Tor. The OONI project will publish data submitted by probes, possibly including your IP address or other identifying information. In addition, your use of ooniprobe will be clear to anyone who has access to your computer, and to anyone who can monitor your Internet connection (such as your employer, ISP or government).</source>
</trans-unit>

<trans-unit id="screenshot1">
<source>Detect internet censorship and test your network's speed and performance</source>
</trans-unit>
<trans-unit id="screenshot2">
<source>Undercover evidence of internet censorship and lear how to circumvent it</source>
</trans-unit>
<trans-unit id="screenshot3">
<source>Run a sophisticated network speed and diagnostics test</source>
</trans-unit>
<trans-unit id="screenshot4">
<source>Easily discover which websites are blocked on your network</source>
</trans-unit>
<trans-unit id="screenshot5">
<source>Testing your network is fun with a friendly octopus!</source>
</trans-unit>
<trans-unit id="feature-graphic">
<source>The Open Observatory og Network Interference is a global observation network for detecting censorship, surveillance and treffic manipulation on the internet.</source>
</trans-unit>
<trans-unit id="keywords">
<source>network,speedtest,measurement,net,wifi,networking,scan,bandwidth,bench,dns,mobile,ooni,research,tool</source>
</trans-unit>
</body>
</file>
</xliff>
115 changes: 115 additions & 0 deletions scripts/gen-descriptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import os
import sys
import xml.dom.minidom as md

title_tmpl = u"{title}"
short_description_tmpl = u"{shortdescription}"

full_description_tmpl = u"""
{intro}
{intro2}
{intro-bullet-1}
{intro-bullet-2}
{intro-bullet-3}
{intro3}
{intro4}
<b>{evidence-title}</b>
{evidence-description}
<b>{systems-title}</b>
{systems-description}
<b>{speed-title}</b>
{speed-description}
<b>{opendata-title}</b>
{opendata-description}
<b>{freesoftware-title}</b>
{freesoftware-description}
{social-links}
{disclaimer}
"""
screenshots_tmpl = u"""
# Screnshot 1
{screenshot1}
# Screnshot 2
{screenshot2}
# Screnshot 3
{screenshot3}
# Screnshot 4
{screenshot4}
# Screnshot 5
{screenshot5}
# Feature Graphic
{feature-graphic}
"""
keywords_tmpl = u"{keywords}"

def get_ids(lang_code='source'):
ids = {}
dom = md.parse('description/{lang_code}.xlf'.format(lang_code=lang_code))
units = dom.getElementsByTagName('trans-unit')
for unit in units:
unit_id = unit.getAttribute('id')
target = unit.getElementsByTagName('target')
if len(target) == 0:
target = unit.getElementsByTagName('source')
assert len(target) == 1
target = target[0]
assert len(target.childNodes) == 1
value = target.childNodes[0].nodeValue
if unit_id in ids and ids[unit_id] != value:
raise Exception("Duplicate ID")
ids[unit_id] = value
return ids

def print_frmt(name, value):
title = "%s (%d chars)" % (name, len(value))
print(title)
print("-"*len(title))
print(value)
print("\n\n")

def print_tmpls(lang_code='source'):
ids = get_ids(lang_code)

title = title_tmpl.format(**ids)
print_frmt("Title", title)

short_description = short_description_tmpl.format(**ids)
print_frmt("Short description", short_description)

full_description = full_description_tmpl.format(**ids)
print_frmt("Full description", full_description)

screenshots = screenshots_tmpl.format(**ids)
print_frmt("Screenshots", screenshots)

keywords = keywords_tmpl.format(**ids)
print_frmt("Keywords", keywords)

if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: %s [lang_code]" % sys.argv[0])
sys.exit(1)
if not os.path.exists(os.path.join("description/source.xlf")):
print("ERROR")
print("This script must be run from the root of the repository")
sys.exit(1)

target = sys.argv[1]
if target == 'en':
target = 'source'
print_tmpls(target)

0 comments on commit f26405b

Please sign in to comment.