Create Collectionsįirst, create a collection named “translations” in cloud firestore which then creates a document with contain a field named input with a type string and named translated with a type map. This converts those strings into specified languages and then writes all these changes to the original document. Behind the scenes, this extension uses the Cloud function, which listens to changes in your specified Cloud Firestore collection and passes the string to the Google Cloud Translate API. When you add or update any documents in Firestore, it will automatically translate that into multiple languages which you have specified. Should existing documents in the Firestore collection be translated as well? If you’ve added new languages since a document was translated, this will also fill those in.Īfter configuring the extension, click on the install button and wait for 3 to 5 minutes to finish the installation setup. If you don’t specify it, the extension will use the languages specified in the LANGUAGES parameter. What is the field name that contains the languages you want to translate into? This field is optional. Here you have to specify the field name where you want to store the translated string after the translations. This is the input field name that contains the string that you want to translate. Specify the collection from where you want to translate new strings Input field name The languages are identified using ISO-639-1 codes in a comma-separated list, for example: en, es, de, fr.įor these codes, visit the list of supported languages. Specify the target languages you want to translate new strings. Target languages for translations as a comma-separated list Specify the location where you want to deploy the functions created for this extension. Configure Extension Cloud Functions location To add an extension, please click on the extension tab on the Firebase console and select the extension from the marketplace. You can install the Translate text extension via Firebase CLI, or if you prefer to use a command line like me, run the firebase ext:install command by passing your project id into Firebase CLI. Run the below command in your command line firebase ext:install firebase/firestore-translate-text -project=projectId_or_alias Set up a new project directory or navigate to an existing one To install and manage extensions, you can also use the Firebase CLI: Install Translate Text Extension Option 1: Using the Firebase CLI Most Firebase services offer a free tier for low-volume use. You will only be charged for the resources you use. To install this extension, your Firebase project must be on the Blaze (pay-as-you-go) plan. Getting startedīefore starting, first, we need to: Create a Cloud Firestore Database Upgrade Firebase with Blaze plan The Translate text extension is straightforward to use to translate text in your Cloud Firestore Database without any extra lines of code. Firebase Extensions are prebuilt solutions that can be easily added to your application without the need to research, write or debug the code.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |