blob: 23b3315df665f6a26cf4effef519198f85eea6c9 [file] [log] [blame]
Jeff Sharkeyeea49d32019-12-11 17:45:38 -07001#!/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"""
18Helper script to generate tedious strings.xml permutations
19"""
20
21from string import Template
22
23verbs = ["write","trash","untrash","delete"]
24datas = [("audio","audio file"),("video","video"),("image","photo"),("generic","item")]
25
26print '''
27<!-- ========================= BEGIN AUTO-GENERATED BY gen_strings.py ========================= -->'''
28
29for verb in verbs:
30 verblabel = verb
31 if verb == "write":
Nandana Dutta29276f2020-03-16 20:51:26 +000032 verblabel = "modify"
Jeff Sharkeyeea49d32019-12-11 17:45:38 -070033
Jeff Sharkeyeea49d32019-12-11 17:45:38 -070034 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] -->
varun23f852d2021-11-16 10:00:43 +000041<string name="permission_${verb}_${data}"> {count, plural,
42 =1 {Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to move this $datalabel to trash?}
43 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?}
44}</string>
Jeff Sharkeyeea49d32019-12-11 17:45:38 -070045''').substitute(vars()).strip("\n")
Ivan Chiang9911b9e2021-02-22 10:12:15 +080046 print Template('''
47<!-- Progress dialog message after user allows $verb permission to the $data item [CHAR LIMIT=128] -->
varun23f852d2021-11-16 10:00:43 +000048<string name="permission_progress_${verb}_${data}"> {count, plural,
49 =1 {Moving $datalabel to trash&#8230;}
50 other {Moving <xliff:g id="count" example="42">^1</xliff:g> ${datalabel}s to trash&#8230;}
51}</string>
Ivan Chiang9911b9e2021-02-22 10:12:15 +080052''').substitute(vars()).strip("\n")
Jeff Sharkeyeea49d32019-12-11 17:45:38 -070053
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] -->
varun23f852d2021-11-16 10:00:43 +000057<string name="permission_${verb}_${data}"> {count, plural,
58 =1 {Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to move this $datalabel out of trash?}
59 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?}
60}</string>
Jeff Sharkeyeea49d32019-12-11 17:45:38 -070061''').substitute(vars()).strip("\n")
Ivan Chiang9911b9e2021-02-22 10:12:15 +080062 print Template('''
63<!-- Progress dialog message after user allows $verb permission to the $data item [CHAR LIMIT=128] -->
varun23f852d2021-11-16 10:00:43 +000064<string name="permission_progress_${verb}_${data}"> {count, plural,
65 =1 {Moving $datalabel out of trash&#8230;}
66 other {Moving <xliff:g id="count" example="42">^1</xliff:g> ${datalabel}s out of trash&#8230;}
67}</string>
Ivan Chiang9911b9e2021-02-22 10:12:15 +080068''').substitute(vars()).strip("\n")
Jeff Sharkeyeea49d32019-12-11 17:45:38 -070069
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] -->
varun23f852d2021-11-16 10:00:43 +000073<string name="permission_${verb}_${data}"> {count, plural,
74 =1 {Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to $verblabel this $datalabel?}
75 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?}
76}</string>
Jeff Sharkeyeea49d32019-12-11 17:45:38 -070077''').substitute(vars()).strip("\n")
Ivan Chiang9911b9e2021-02-22 10:12:15 +080078 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] -->
varun23f852d2021-11-16 10:00:43 +000084<string name="permission_progress_${verb}_${data}"> {count, plural,
85 =1 {$actionLabel $datalabel&#8230;}
86 other {$actionLabel <xliff:g id="count" example="42">^1</xliff:g> ${datalabel}s&#8230;}
87}</string>
Ivan Chiang9911b9e2021-02-22 10:12:15 +080088''').substitute(vars()).strip("\n")
Jeff Sharkeyeea49d32019-12-11 17:45:38 -070089
Jeff Sharkeyeea49d32019-12-11 17:45:38 -070090print '''
91<!-- ========================= END AUTO-GENERATED BY gen_strings.py ========================= -->
92'''