-
Notifications
You must be signed in to change notification settings - Fork 374
/
extension.yaml
176 lines (154 loc) · 5.98 KB
/
extension.yaml
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# Copyright 2019 Google LLC
#
# 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
#
# https://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.
name: firestore-translate-text
version: 0.1.18
specVersion: v1beta
tags: [ai]
displayName: Translate Text in Firestore
description:
Translates strings written to a Cloud Firestore collection into multiple
languages (uses Cloud Translation API).
license: Apache-2.0
sourceUrl: https://github.com/firebase/extensions/tree/master/firestore-translate-text
releaseNotesUrl: https://github.com/firebase/extensions/blob/master/firestore-translate-text/CHANGELOG.md
author:
authorName: Firebase
url: https://firebase.google.com
contributors:
- authorName: Chris Bianca
email: chris@csfrequency.com
url: https://github.com/chrisbianca
- authorName: Invertase
email: oss@invertase.io
url: https://github.com/invertase
billingRequired: true
apis:
- apiName: translate.googleapis.com
reason:
To use Google Translate to translate strings into your specified target
languages.
roles:
- role: datastore.user
reason: Allows the extension to write translated strings to Cloud Firestore.
resources:
- name: fstranslate
type: firebaseextensions.v1beta.function
description:
Listens for writes of new strings to your specified Cloud Firestore
collection, translates the strings, then writes the translated strings
back to the same document.
properties:
runtime: nodejs18
eventTrigger:
eventType: providers/cloud.firestore/eventTypes/document.write
resource: projects/${param:PROJECT_ID}/databases/(default)/documents/${param:COLLECTION_PATH}/{messageId}
- name: fstranslatebackfill
type: firebaseextensions.v1beta.function
description:
Searches your specified Cloud Firestore collection for existing documents,
translates the strings into any missing languages, then writes the
translated strings back to the same document.
properties:
runtime: nodejs18
availableMemoryMb: 1024
timeout: 540s
taskQueueTrigger: {}
params:
- param: LANGUAGES
label: Target languages for translations, as a comma-separated list
description: >
Into which target languages do you want to translate new strings? The
languages are identified using ISO-639-1 codes in a comma-separated list,
for example: en,es,de,fr. For these codes, visit the [supported languages
list](https://cloud.google.com/translate/docs/languages).
example: en,es,de,fr
validationRegex: "^[a-zA-Z,-]*[a-zA-Z-]{2,}$"
validationErrorMessage:
Languages must be a comma-separated list of ISO-639-1 language codes.
default: en,es,de,fr
required: true
- param: COLLECTION_PATH
label: Collection path
description: >
What is the path to the collection that contains the strings that you want
to translate?
example: translations
validationRegex: "^[^/]+(/[^/]+/[^/]+)*$"
validationErrorMessage: Must be a valid Cloud Firestore Collection
default: translations
required: true
- param: INPUT_FIELD_NAME
label: Input field name
description: >
What is the name of the field that contains the string that you want to
translate?
example: input
default: input
required: true
- param: OUTPUT_FIELD_NAME
label: Translations output field name
description: >
What is the name of the field where you want to store your translations?
example: translated
default: translated
required: true
- param: LANGUAGES_FIELD_NAME
label: Languages field name
description: >
What is the name of the field that contains the languages that you want to
translate into? This field is optional. If you don't specify it, the
extension will use the languages specified in the LANGUAGES parameter.
example: languages
default: languages
required: false
# - param: DO_BACKFILL
# label: Translate existing documents?
# description: >
# Should existing documents in the Firestore collection be translated as
# well? If you've added new languages since a document was translated, this
# will fill those in as well.
# type: select
# required: true
# options:
# - label: Yes
# value: true
# - label: No
# value: false
events:
- type: firebase.extensions.firestore-translate-text.v1.onStart
description:
Occurs when a trigger has been called within the Extension, and will
include data such as the context of the trigger request.
- type: firebase.extensions.firestore-translate-text.v1.onSuccess
description:
Occurs when image resizing completes successfully. The event will contain
further details about specific formats and sizes.
- type: firebase.extensions.firestore-translate-text.v1.onError
description:
Occurs when an issue has been experienced in the Extension. This will
include any error data that has been included within the Error Exception.
- type: firebase.extensions.firestore-translate-text.v1.onCompletion
description:
Occurs when the function is settled. Provides no customized data other
than the context.
# lifecycleEvents:
# onInstall:
# function: fstranslatebackfill
# processingMessage: "Translating existing documents in ${COLLECTION_PATH}"
# onUpdate:
# function: fstranslatebackfill
# processingMessage: "Translating existing documents in ${COLLECTION_PATH}"
# onConfigure:
# function: fstranslatebackfill
# processingMessage: "Translating existing documents in ${COLLECTION_PATH}"