Giter VIP home page Giter VIP logo

Comments (13)

robguthrie avatar robguthrie commented on July 30, 2024 1

https://github.com/googleapis/google-cloud-ruby is the starting point to learn how to configure a google cloud account and generate a translation credentials json file.

To enable google translate, you just need a TRANSLATE_CREDENTIALS environment variable, with the content of that json file as a string. Once this is present the translation features will show up when they can be used.

The json file looks like what you can see on this page: https://cloud.google.com/iam/docs/creating-managing-service-account-keys

I hope that's enough to help you on your way, please let me know how you get on.

from loomio-deploy.

eternaltyro avatar eternaltyro commented on July 30, 2024

Thanks. I'm using loomio-deploy for my deployment and I'm assuming that the environment variable should be set for the loomio-app container. Is my assumption right?

from loomio-deploy.

robguthrie avatar robguthrie commented on July 30, 2024

from loomio-deploy.

eternaltyro avatar eternaltyro commented on July 30, 2024

I recommend that you set all ENV's in the "env" file in the loomio-deploy directory.

I did. That hasn't enabled translations yet. I 'escaped' all double-quotes and removed spaces from the json string. Does this seem alright to you?

2021-10-05_18-47

Only loomio-app has the .env file referred to in the compose file.

from loomio-deploy.

robguthrie avatar robguthrie commented on July 30, 2024

yes, that looks right. That should work. If you write a comment in another language it should bring up the translate button. it might need to be a sentence or two long

from loomio-deploy.

eternaltyro avatar eternaltyro commented on July 30, 2024

Hmmm, that doesn't work for some reason. No requests are being made to the API either:

image

What could I be doing wrong? Is there a specific way service accounts need to be configured? I can see that the service account has owner permission to the Google Cloud project and Translation API is enabled.

Anything to do on the app?

from loomio-deploy.

eternaltyro avatar eternaltyro commented on July 30, 2024

docker-compose config does not list the TRANSLATE_CREDENTIALS variable

from loomio-deploy.

eternaltyro avatar eternaltyro commented on July 30, 2024

I think docker compose can only have one of env_file and environment. I could be wrong though.

I set TRANSLATE_CREDENTIALS in the environment key and it seems to have worked partially. I see the google translate icon but clicking on it does nothing.

from loomio-deploy.

robguthrie avatar robguthrie commented on July 30, 2024

from loomio-deploy.

eternaltyro avatar eternaltyro commented on July 30, 2024

You need to remove the containers, not just stop them, for new environment variables to be taken in. So docker-compose down and up are required, not just stop and start.

Yes, I've been doing this. But it still doesn't take the envvars in the .env file.

If the translate button is appearing, then the ENV is detected and the in-app language detection is working, the problem is with your credentials and google translate is not translating for you. Have a look at your logs with docker-compose logs -f and see if there is anything in there.

Yes, you are correct. I have a problem with the way the JSON string is placed in the environment variable. I'm not sure how to make docker-compose read the contents of a file as value to an ENVVAR. Even though the string I sent was a valid JSON, there are issues with serializing it.

So the way I see it, there are three options that I can try

Option 1. Use one of the multi-line formats like so

TRANSLATE_CREDENTIALS: |
 {
  "JSON": "STRING",
  ...
}

or

TRANSlATE_CREDENTIALS: >
 {
  "JSON": "STRING",
  ...
}

Option 2: Mount the JSON file as a volume and refer to it
Option 3: Pass it as a secret with value defined from file.

from loomio-deploy.

eternaltyro avatar eternaltyro commented on July 30, 2024

Alright, the pipe style did the trick. Translation works now!

image

from loomio-deploy.

eternaltyro avatar eternaltyro commented on July 30, 2024

Can we add this to the documentation too, please?

from loomio-deploy.

robguthrie avatar robguthrie commented on July 30, 2024

from loomio-deploy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.