phiil/googlesheets-translation-bundle

This bundle enables you to deploy your translation within seconds and the best part: Manage them in Googlesheets, probably the easiest way.

5.4.0 2022-07-08 09:47 UTC

This package is auto-updated.

Last update: 2024-04-08 13:50:10 UTC


README

Build Status

SymfonyGoogleSheetsTranslationBundle

Introduction

Translation management can be rather... pesky. This bundle allows you to use a single Googlesheet and push your translations to your symfony site within seconds.

Features:

  • Use as many languages as you want: this bundle sets you no limits, from just one locale (use case: you just want to keep texts out of your lovely source code) to even thirteen locales (because you just learned them on Dualingo)
  • Decide which sheet page you want to use for your translations: Only the first sheet page of your GoogleSheet should be used for translations? No problem, you need one more setting. Although this is possible, we recommend to use the default mode which automatically includes all the sheets and merges them into one (translations-wise - this bundle does not edit your GoogleSheet).
  • One command to push it all...: This bundle also provides you with one command which enables you to reload & push your translations in all available languages within seconds.

Requirements

  • Symfony ^5.2 (an older version for Symfony Version 4.4 is also available)
  • PHP ^7.4|^8.0

Installation

Run composer require phiil/googlesheets-translation-bundle

Usage

Video Guide

Want to watch a video instead of reading the guide? Today you're lucky! Watch the video on YouTube: Watch the video

Text Guide

The first thing you need is a Googlesheet, go ahead and create on sheets.google.com. My demo translations sheet is available at this link. I'd suggest that you just duplicate that one into your account / apply this structure - feel free to change the head => add as many locales as you want!

Better customization & configuration possibilities for the GoogleSheet are in the works - for now, just try to stick as close as possible to the structure.

Now, you need to publish it to the web. What first sounded very weird to me (should I really publish my translations publicly to the web?!), isn't really that dangerous. The chances of someone finding your translations is really low and on top of that no one can use it to attack you / do harm to your site.

Step-by-step tutorial:

  1. Go to File > Publish to the web: Publish Step 1
  2. A window should pop up, just press 'Publish' (assuming that you want to publish the whole sheet): Publish Step 2
  3. Now, you need to extract the ID of your sheet. Back to the URL window (CMD + L / CTRL + L for hot key lovers), copy the part which is marked in the following image: Publish Step 3.
  4. Finally we can hop back in Symfony. In config/services.yaml insert it like the following:
parameters:
    ...
    googlesheets_translations.sheet.publicId: '1D2qOEgEKgMy7qh0B-PQMzdil8AoE5NvYMsNuusqM-IA'
    ...

I went ahead and already pasted in the ID from above.

  1. (Optional) Configure which sheet pages you want to add. If you want to only push a single sheet page, you have to add the following parameter:
parameters:
    ...
    googlesheets_translations.sheet.mode: 'all' # that's the default value
    # or...
    googlesheets_translations.sheet.mode: 1     # if you only want to use the first sheet page for your translations
    ...

My final config (config/services.yaml):

parameters:
    googlesheets_translations.sheet.mode: 'all'
    googlesheets_translations.sheet.publicId: '1D2qOEgEKgMy7qh0B-PQMzdil8AoE5NvYMsNuusqM-IA'
  1. Push your translations with the built-in command: phiil:translation:reload (in my case, I have to execute php bin/console phiil:translation:reload). Have a look at the output of my console: Publish Step 7

Congratulations, you're all set!

Problems? Issues?

Just post them here on Github or contact me via email: philipp@riddle.com. Feel free to contribute!