Jeff Sharkey | eea49d3 | 2019-12-11 17:45:38 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # |
| 3 | # Copyright (C) 2019 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | """ |
| 18 | Helper script to generate tedious strings.xml permutations |
| 19 | """ |
| 20 | |
| 21 | from string import Template |
| 22 | |
| 23 | verbs = ["write","trash","untrash","delete"] |
| 24 | datas = [("audio","audio file"),("video","video"),("image","photo"),("generic","item")] |
| 25 | |
| 26 | print ''' |
| 27 | <!-- ========================= BEGIN AUTO-GENERATED BY gen_strings.py ========================= -->''' |
| 28 | |
| 29 | for verb in verbs: |
| 30 | verblabel = verb |
| 31 | if verb == "write": |
| 32 | verblabel = "change" |
| 33 | |
| 34 | verblabelcaps = verblabel[0].upper() + verblabel[1:] |
| 35 | if verb == "trash": |
| 36 | verblabelcaps = "Move to trash" |
| 37 | if verb == "untrash": |
| 38 | verblabelcaps = "Move out of trash" |
| 39 | |
| 40 | print ''' |
| 41 | <!-- ========================= %s STRINGS ========================= --> |
| 42 | ''' % (verb.upper()) |
| 43 | for data, datalabel in datas: |
| 44 | if verb == "trash": |
| 45 | print Template(''' |
| 46 | <!-- Dialog title asking if user will allow $verb permission to the $data item displayed below this string. [CHAR LIMIT=128] --> |
| 47 | <plurals name="permission_${verb}_${data}"> |
| 48 | <item quantity="one">Let <xliff:g id="app_name" example="Gmail">^1</xliff:g> move this $datalabel to trash?</item> |
| 49 | <item quantity="other">Let <xliff:g id="app_name" example="Gmail">^1</xliff:g> move <xliff:g id="count" example="42">^2</xliff:g> ${datalabel}s to trash?</item> |
| 50 | </plurals> |
| 51 | ''').substitute(vars()).strip("\n") |
| 52 | print Template(''' |
| 53 | <!-- Dialog body text explaining that this $data item will be permanently deleted after the shown duration. [CHAR LIMIT=128] --> |
| 54 | <plurals name="permission_${verb}_${data}_info"> |
| 55 | <item quantity="one">This $datalabel will be permanently deleted after <xliff:g id="duration" example="42">^3</xliff:g> days</item> |
| 56 | <item quantity="other">These ${datalabel}s will be permanently deleted after <xliff:g id="duration" example="42">^3</xliff:g> days</item> |
| 57 | </plurals> |
| 58 | ''').substitute(vars()).strip("\n") |
| 59 | |
| 60 | elif verb == "untrash": |
| 61 | print Template(''' |
| 62 | <!-- Dialog title asking if user will allow $verb permission to the $data item displayed below this string. [CHAR LIMIT=128] --> |
| 63 | <plurals name="permission_${verb}_${data}"> |
| 64 | <item quantity="one">Let <xliff:g id="app_name" example="Gmail">^1</xliff:g> move this $datalabel out of trash?</item> |
| 65 | <item quantity="other">Let <xliff:g id="app_name" example="Gmail">^1</xliff:g> move <xliff:g id="count" example="42">^2</xliff:g> ${datalabel}s out of trash?</item> |
| 66 | </plurals> |
| 67 | ''').substitute(vars()).strip("\n") |
| 68 | |
| 69 | else: |
| 70 | print Template(''' |
| 71 | <!-- Dialog title asking if user will allow $verb permission to the $data item displayed below this string. [CHAR LIMIT=128] --> |
| 72 | <plurals name="permission_${verb}_${data}"> |
| 73 | <item quantity="one">Let <xliff:g id="app_name" example="Gmail">^1</xliff:g> $verblabel this $datalabel?</item> |
| 74 | <item quantity="other">Let <xliff:g id="app_name" example="Gmail">^1</xliff:g> $verblabel <xliff:g id="count" example="42">^2</xliff:g> ${datalabel}s?</item> |
| 75 | </plurals> |
| 76 | ''').substitute(vars()).strip("\n") |
| 77 | |
| 78 | |
| 79 | print Template(''' |
| 80 | <!-- Positive dialog button confirming that $verb permission should be granted. [CHAR LIMIT=32] --> |
| 81 | <string name="permission_${verb}_grant">${verblabelcaps}</string> |
| 82 | <!-- Negative dialog button confirming that $verb permission should not be granted. [CHAR LIMIT=32] --> |
| 83 | <string name="permission_${verb}_deny">Cancel</string> |
| 84 | ''').substitute(vars()).strip("\n") |
| 85 | |
| 86 | print ''' |
| 87 | <!-- ========================= END AUTO-GENERATED BY gen_strings.py ========================= --> |
| 88 | ''' |