How to enable auto translation for post, comment, reply and message in ShaunSocial

shaunSocial is multiple language support that allow you translate it into your desired language and can enable multiple language each time for your member to switch. For content that shared by member like post, comment, reply or message, you can allow member to translate them using popular translation service providers like google……

Follow below steps to enable the auto translation:

Step 1: Configure translation provider in admincp -> Site settings -> Manage content translate provider. Currently, platform only support Google, you can customize to add more providers if you want.

Step 2: Setup API key for Google Cloud Translation API

To obtain an API key for the Google Cloud Translation API, follow these steps:

  • Access Google Cloud Console: Navigate to the Google Cloud Console and either sign in or create a new account.
  • Create a New Project: If you don’t already have one, create a new Google Cloud project. Provide a suitable name for the project.
  • Enable Cloud Translation API:
    • Within your project, navigate to “APIs & Services” > “Dashboard.”
    • Click “+ ENABLE APIS AND SERVICES.”
    • Search for “Cloud Translation API” in the API Library.
    • Select the “Cloud Translation API” and click “Enable.”
  • Create API Key:
    • Go to “APIs & Services” > “Credentials.”
    • Click “CREATE CREDENTIALS” and select “API Key” from the dropdown. 
    • Google Cloud will generate a new API key.
  • Restrict API Key (Recommended): For security, restrict the usage of your API key.
    • Click “Restrict Key” on the generated API key.
    • Choose the appropriate restrictions, such as “HTTP referrers” (for web applications) and specify the permitted URLs, or “IP addresses” (for server-side applications).
    • You can also restrict the API key to specific APIs, like the Cloud Translation API.
  • Copy the API Key: Once generated and optionally restricted, copy the API key. This key is used to authenticate your requests to the Cloud Translation API.

After you have API key, click on “Edit” to open popup to fill in your API key

Google has free tier for this service, to stay within the free tier (500,000 characters per month), check screenshot below for the best per-minute, month… limit that you should configure for you “”Google Cloud Translation API” api key to avoid being charged. If your site has big traffics, you should increase your limit and should set cost alert to void over charge from google for this service.

API call fee optimization for auto translation: to save API call fee, we are doing caching, if user has translated a post, comment, reply or message into a language and then click on “See translation” again, the system will get the previous translation result to display. If user edits, the system will call API again. If 2 or more people post the same content, API will only be called once and used for both.

Step 3: Enable auto translate at admincp -> site settings -> General configuration -> auto translate settings

Then, you can see the “See translation” below the message, post, comment or reply like the below screenshot

Powered by BetterDocs