Forum Discussion

Luis_Caston's avatar
Luis_Caston
Helper III
2 years ago
Solved

Translate columns with google translate API

Dear all,   I need your support please. I've reading a lot about this topic and I've created this pbix file: Google translate    I'm working on the M code inside but I donĀ“t know what I'm doing ...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Luis_Caston ,

    Please update the codes for the query '' as below and check if it can return the expected result:

    let
        fnTranslate =
            (original as text) as text =>
                let
                    Source = Json.Document(
                        Web.Contents("https://translate.googleapis.com/translate_a/single?client=gtx&sl=es&tl=tr&dt=t&q=" & original)
                    ),
                    Translation = Source{0}{0}{0}
                in
                    Translation,
    
        Source = CabeceraSalidas,
        ChangeDataType = Table.TransformColumnTypes(Source,{{"PaisDestino", type text}}),
        Result = Table.AddColumn(
            ChangeDataType,
            "TranslatedColumn",
            each fnTranslate([PaisDestino]),
            type text
        )
    in
        Result

    In addition, you can refer the following link to get it.

    Solved: Translate other languages column data into english... - Microsoft Fabric Community

    You could call the Google Translate API to make the translation.  By creating a custom column and then using Web.Contents to pass the Chinese text to Google Translate, it will return the English translation.

    https://cloud.google.com/translate/docs/reference/rest


    Best Regards