blob: 99bba8a34030a5316be9c0e7343b90bab5245ccc [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
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}">
Nandana Dutta29276f2020-03-16 20:51:26 +000048 <item quantity="one">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to move this $datalabel to trash?</item>
49 <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 Sharkeyeea49d32019-12-11 17:45:38 -070050</plurals>
51''').substitute(vars()).strip("\n")
52
53 elif verb == "untrash":
54 print Template('''
55<!-- Dialog title asking if user will allow $verb permission to the $data item displayed below this string. [CHAR LIMIT=128] -->
56<plurals name="permission_${verb}_${data}">
Nandana Dutta29276f2020-03-16 20:51:26 +000057 <item quantity="one">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to move this $datalabel out of trash?</item>
58 <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 Sharkeyeea49d32019-12-11 17:45:38 -070059</plurals>
60''').substitute(vars()).strip("\n")
61
62 else:
63 print Template('''
64<!-- Dialog title asking if user will allow $verb permission to the $data item displayed below this string. [CHAR LIMIT=128] -->
65<plurals name="permission_${verb}_${data}">
Nandana Dutta29276f2020-03-16 20:51:26 +000066 <item quantity="one">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to $verblabel this $datalabel?</item>
67 <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 Sharkeyeea49d32019-12-11 17:45:38 -070068</plurals>
69''').substitute(vars()).strip("\n")
70
Jeff Sharkeyeea49d32019-12-11 17:45:38 -070071print '''
72<!-- ========================= END AUTO-GENERATED BY gen_strings.py ========================= -->
73'''