1

I am trying to add a glossary by CSV. I put the CSV on my google storage. I got this Error:

google.api_core.exceptions.InvalidArgument: 400 Failed to parse content of input file. Error: Not enough valid languages in CSV file. Must have terms for at least two different languages. num_valid_languages_in_csv = 0

my CSV is super simple. I made sure I save in utf-8. I also added # -*- coding: utf-8 -*- on top of my code.

Liz, 栗子
Tom, 汤姆
Nancy,楠西

The code is copied from the document.

Mort
  • 3,379
  • 1
  • 25
  • 40
liz li
  • 15
  • 2

2 Answers2

1

I also encounter your error when using the CSV you provided. This is because the CSV file used does not have a header.

enter image description here

To fix this just add a header on your CSV file. Make sure you match the headers with your language code defined in your code.

test_glossary_1.csv:

en,zh
Liz, 栗子
Tom, 汤姆
Nancy,楠西

Create a glossary using the CSV with headers: enter image description here

Check glossary if created: enter image description here

Ricco D
  • 6,873
  • 1
  • 8
  • 18
  • 1
    Thank you Ricco! I also tried to add the launguages on the headers, which didn't work. I used zh-CN. I changed to zh, it worked. Thank you so much! – liz li Jun 24 '21 at 02:38
  • This is a good answer. Really weird that Google Translate's docs specified otherwise. https://cloud.google.com/translate/docs/advanced/glossary#translate_v3_translate_text_with_glossary-python – Thomas Bui May 18 '23 at 20:30
0

Suppose the link

https://storage.googleapis.com/vcc_translation/glossory_01.csv

Now, to make this work, re-write the same as follows:

gs://vcc_translation/glossory_01.csv

Where:

  • gs:// added from your side
  • vcc_translation is the storage bucket
Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
Satnam
  • 1