You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can a Google Sheet be added as a translation resource?
The usecase and the process would be like this:
create a Google Sheet where the first column contains keys and subsequent columns would contain language IDs
share the sheet with everyone with a link
extract the DocID and SheetID values: DocID would sit, in the shared URL, between spreadsheets/d/ and /edit while the sheet ID would be the #gid= parameter from the URL when we pen the sheet in browser (if it's the first sheet, the sheet ID is - 0)
we define the docID and sheetID variables
Apart from reducing complexity of sharing a translation resource, we can also use the Google's automated translation in sheets this way.
An example code (utilizing the http package) that extracts CSV from a shared Google sheet would be something like:
import'dart:convert';
import'dart:io';
import'package:http/http.dart'as http;
Future<void> downloadCsvFromGoogleSheet(String documentId, String sheetId) async {
// Set the API endpoint for the Google Sheets APIvar endpoint ='https://docs.google.com/spreadsheets/d/$documentId/export?format=csv&id=$documentId&gid=$sheetId';
// Send a request to the API to get the CSV datavar response =await http.get(endpoint);
// Check if the request was successfulif (response.statusCode ==200) {
// Write the response content (the CSV data) to a local filevar file =File('$sheetId.csv');
await file.writeAsString(utf8.decode(response.bodyBytes));
print('CSV data successfully saved to $sheetId.csv');
} else {
print('Request failed with status code ${response.statusCode}');
}
}
// Example usage:voidmain() {
var documentId ='your_document_id_here';
var sheetId ='your_sheet_id_here';
downloadCsvFromGoogleSheet(documentId, sheetId);
}
I could also try to do a PR with this addition.
The text was updated successfully, but these errors were encountered:
Can a Google Sheet be added as a translation resource?
The usecase and the process would be like this:
spreadsheets/d/
and/edit
while the sheet ID would be the#gid=
parameter from the URL when we pen the sheet in browser (if it's the first sheet, the sheet ID is -0
)Apart from reducing complexity of sharing a translation resource, we can also use the Google's automated translation in sheets this way.
An example code (utilizing the
http
package) that extracts CSV from a shared Google sheet would be something like:I could also try to do a PR with this addition.
The text was updated successfully, but these errors were encountered: