summaryrefslogtreecommitdiff
path: root/gen_strings.py
blob: a3d98be506c99010f24a97e1db6a171aeab85775 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env python
#
# Copyright (C) 2019 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Helper script to generate tedious strings.xml permutations
"""

from string import Template

verbs = ["write","trash","untrash","delete"]
datas = [("audio","audio file"),("video","video"),("image","photo"),("generic","item")]

print '''
<!-- ========================= BEGIN AUTO-GENERATED BY gen_strings.py ========================= -->'''

for verb in verbs:
    verblabel = verb
    if verb == "write":
        verblabel = "modify"

    print '''
<!-- ========================= %s STRINGS ========================= -->
''' % (verb.upper())
    for data, datalabel in datas:
        if verb == "trash":
            print Template('''
<!-- Dialog title asking if user will allow $verb permission to the $data item displayed below this string. [CHAR LIMIT=128] -->
<plurals name="permission_${verb}_${data}">
    <item quantity="one">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to move this $datalabel to trash?</item>
    <item quantity="other">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to move <xliff:g id="count" example="42">^2</xliff:g> ${datalabel}s to trash?</item>
</plurals>
''').substitute(vars()).strip("\n")
            print Template('''
<!-- Progress dialog message after user allows $verb permission to the $data item [CHAR LIMIT=128] -->
<plurals name="permission_progress_${verb}_${data}">
    <item quantity="one">Moving $datalabel to trash&#8230;</item>
    <item quantity="other">Moving <xliff:g id="count" example="42">^1</xliff:g> ${datalabel}s to trash&#8230;</item>
</plurals>
''').substitute(vars()).strip("\n")

        elif verb == "untrash":
            print Template('''
<!-- Dialog title asking if user will allow $verb permission to the $data item displayed below this string. [CHAR LIMIT=128] -->
<plurals name="permission_${verb}_${data}">
    <item quantity="one">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to move this $datalabel out of trash?</item>
    <item quantity="other">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to move <xliff:g id="count" example="42">^2</xliff:g> ${datalabel}s out of trash?</item>
</plurals>
''').substitute(vars()).strip("\n")
            print Template('''
<!-- Progress dialog message after user allows $verb permission to the $data item [CHAR LIMIT=128] -->
<plurals name="permission_progress_${verb}_${data}">
    <item quantity="one">Moving $datalabel out of trash&#8230;</item>
    <item quantity="other">Moving <xliff:g id="count" example="42">^1</xliff:g> ${datalabel}s out of trash&#8230;</item>
</plurals>
''').substitute(vars()).strip("\n")

        else:
            print Template('''
<!-- Dialog title asking if user will allow $verb permission to the $data item displayed below this string. [CHAR LIMIT=128] -->
<plurals name="permission_${verb}_${data}">
    <item quantity="one">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to $verblabel this $datalabel?</item>
    <item quantity="other">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to $verblabel <xliff:g id="count" example="42">^2</xliff:g> ${datalabel}s?</item>
</plurals>
''').substitute(vars()).strip("\n")
            if verb == "write":
                actionLabel = "Modifying"
            else:
                actionLabel = "Deleting"
            print Template('''
<!-- Progress dialog message after user allows $verb permission to the $data item [CHAR LIMIT=128] -->
<plurals name="permission_progress_${verb}_${data}">
    <item quantity="one">$actionLabel $datalabel&#8230;</item>
    <item quantity="other">$actionLabel <xliff:g id="count" example="42">^1</xliff:g> ${datalabel}s&#8230;</item>
</plurals>
''').substitute(vars()).strip("\n")

print '''
<!-- ========================= END AUTO-GENERATED BY gen_strings.py ========================= -->
'''