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": |
Nandana Dutt | a29276f | 2020-03-16 20:51:26 +0000 | [diff] [blame] | 32 | verblabel = "modify" |
Jeff Sharkey | eea49d3 | 2019-12-11 17:45:38 -0700 | [diff] [blame] | 33 | |
Jeff Sharkey | eea49d3 | 2019-12-11 17:45:38 -0700 | [diff] [blame] | 34 | print ''' |
| 35 | <!-- ========================= %s STRINGS ========================= --> |
| 36 | ''' % (verb.upper()) |
| 37 | for data, datalabel in datas: |
| 38 | if verb == "trash": |
| 39 | print Template(''' |
| 40 | <!-- Dialog title asking if user will allow $verb permission to the $data item displayed below this string. [CHAR LIMIT=128] --> |
| 41 | <plurals name="permission_${verb}_${data}"> |
Nandana Dutt | a29276f | 2020-03-16 20:51:26 +0000 | [diff] [blame] | 42 | <item quantity="one">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to move this $datalabel to trash?</item> |
| 43 | <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> |
Jeff Sharkey | eea49d3 | 2019-12-11 17:45:38 -0700 | [diff] [blame] | 44 | </plurals> |
| 45 | ''').substitute(vars()).strip("\n") |
Ivan Chiang | 9911b9e | 2021-02-22 10:12:15 +0800 | [diff] [blame] | 46 | print Template(''' |
| 47 | <!-- Progress dialog message after user allows $verb permission to the $data item [CHAR LIMIT=128] --> |
| 48 | <plurals name="permission_progress_${verb}_${data}"> |
| 49 | <item quantity="one">Moving $datalabel to trash…</item> |
| 50 | <item quantity="other">Moving <xliff:g id="count" example="42">^1</xliff:g> ${datalabel}s to trash…</item> |
| 51 | </plurals> |
| 52 | ''').substitute(vars()).strip("\n") |
Jeff Sharkey | eea49d3 | 2019-12-11 17:45:38 -0700 | [diff] [blame] | 53 | |
| 54 | elif verb == "untrash": |
| 55 | print Template(''' |
| 56 | <!-- Dialog title asking if user will allow $verb permission to the $data item displayed below this string. [CHAR LIMIT=128] --> |
| 57 | <plurals name="permission_${verb}_${data}"> |
Nandana Dutt | a29276f | 2020-03-16 20:51:26 +0000 | [diff] [blame] | 58 | <item quantity="one">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to move this $datalabel out of trash?</item> |
| 59 | <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> |
Jeff Sharkey | eea49d3 | 2019-12-11 17:45:38 -0700 | [diff] [blame] | 60 | </plurals> |
| 61 | ''').substitute(vars()).strip("\n") |
Ivan Chiang | 9911b9e | 2021-02-22 10:12:15 +0800 | [diff] [blame] | 62 | print Template(''' |
| 63 | <!-- Progress dialog message after user allows $verb permission to the $data item [CHAR LIMIT=128] --> |
| 64 | <plurals name="permission_progress_${verb}_${data}"> |
| 65 | <item quantity="one">Moving $datalabel out of trash…</item> |
| 66 | <item quantity="other">Moving <xliff:g id="count" example="42">^1</xliff:g> ${datalabel}s out of trash…</item> |
| 67 | </plurals> |
| 68 | ''').substitute(vars()).strip("\n") |
Jeff Sharkey | eea49d3 | 2019-12-11 17:45:38 -0700 | [diff] [blame] | 69 | |
| 70 | else: |
| 71 | print Template(''' |
| 72 | <!-- Dialog title asking if user will allow $verb permission to the $data item displayed below this string. [CHAR LIMIT=128] --> |
| 73 | <plurals name="permission_${verb}_${data}"> |
Nandana Dutt | a29276f | 2020-03-16 20:51:26 +0000 | [diff] [blame] | 74 | <item quantity="one">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to $verblabel this $datalabel?</item> |
| 75 | <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> |
Jeff Sharkey | eea49d3 | 2019-12-11 17:45:38 -0700 | [diff] [blame] | 76 | </plurals> |
| 77 | ''').substitute(vars()).strip("\n") |
Ivan Chiang | 9911b9e | 2021-02-22 10:12:15 +0800 | [diff] [blame] | 78 | if verb == "write": |
| 79 | actionLabel = "Modifying" |
| 80 | else: |
| 81 | actionLabel = "Deleting" |
| 82 | print Template(''' |
| 83 | <!-- Progress dialog message after user allows $verb permission to the $data item [CHAR LIMIT=128] --> |
| 84 | <plurals name="permission_progress_${verb}_${data}"> |
| 85 | <item quantity="one">$actionLabel $datalabel…</item> |
| 86 | <item quantity="other">$actionLabel <xliff:g id="count" example="42">^1</xliff:g> ${datalabel}s…</item> |
| 87 | </plurals> |
| 88 | ''').substitute(vars()).strip("\n") |
Jeff Sharkey | eea49d3 | 2019-12-11 17:45:38 -0700 | [diff] [blame] | 89 | |
Jeff Sharkey | eea49d3 | 2019-12-11 17:45:38 -0700 | [diff] [blame] | 90 | print ''' |
| 91 | <!-- ========================= END AUTO-GENERATED BY gen_strings.py ========================= --> |
| 92 | ''' |