Giter VIP home page Giter VIP logo

grav-plugin-translator's Introduction

TRANSLATOR PLUGIN

Screenshot

The TRANSLATOR Plugin is an extension for Grav CMS.

Installation

Installing the Mde plugin can be done in one of three ways: The GPM (Grav Package Manager) installation method lets you quickly install the plugin with a simple terminal command, the manual method lets you do so via a zip file, and the admin method lets you do so via the Admin Plugin.

GPM Installation (Preferred)

To install the plugin via the GPM, through your system's terminal (also called the command line), navigate to the root of your Grav-installation, and enter:

bin/gpm install translator

This will install the Mde plugin into your /user/plugins directory within Grav. Its files can be found under /your/site/grav/user/plugins/translator.

Manual Installation

To install the plugin manually, download the zip-version of this repository and unzip it under /your/site/grav/user/plugins. Then rename the folder to mde. You can find these files on GitHub or via GetGrav.org.

You should now have all the plugin files under

/your/site/grav/user/plugins/translator

NOTE: This plugin requires the Email Plugin for Grav if you are not using the Slack notifications.

Admin Plugin

If you use the Admin Plugin, you can install the plugin directly by browsing the Plugins-menu and clicking on the Add button.

Configuration

Before configuring this plugin, you should copy the user/plugins/translator/translator.yaml to user/config/plugins/translator.yaml and only edit that copy.

Here is the default configuration and an explanation of available options:

enabled: true
base_route: '/translator'                   # The plugin will operate under this route for all functionality.
fields:                                     # Which fields the plugin allows for translation, every other field is ignored
  - text
  - textarea
  - editor
  - ckeditor
  - markdown
slack:
  enabled: false                            # Enable slack notifications
  webhook: ''                               # The webhook URL - generate your own via slack developer app
  channel: '#general'                       # The channel in which to send the message
style:
  color: '#39CCCC'                          # Teal
  logo:
    user/plugins/translator/images/grav-logo.png:
      name: grav-logo.png
      type: image/png
      size: 14215
      path: user/plugins/translator/images/grav-logo.png
g_translate:
  type: 'json'
  key: 'user-data://mykeyfile.json'         # the location for the json key. supports streams
  lang_remap:                               # the lang remap utility
    pt-BR: pt
    pt-br: pt
    pt-PT: pt
    pt-pt: pt
    br: pt
    my: ms

Google TRANSLATOR

The plugin has a built in support for google translator. This enables you to get quick translations done which can then later be refined. This can help save money where you only need to hire translators to fix the translations rather than complete them from scratch.

Google Translate Language List

The document above shows the list of languages supported by Google. The remap lets you use any language code your grav site and make it match to a google code.TRANSLATOR

Example: "pt-PT" as a language code will not work for google. so we remap it by doing

g_translate:
  lang_remap:
    pt-PT: pt

Note that if you use the Admin Plugin, a file with your configuration named translator.yaml will be saved in the user/config/plugins/-folder once the configuration is saved in the Admin.

SETUP

The plugin has a few simple requirements.

1. For best use of the plugin, blueprints are recommended.

The plugin uses blueprints to determine which fields should appear or not in the translation area. By default, all text, textarea, editor, fields will automatically be enabled. However, you can enable or disable specific types by adding a translator: true or translator: false key to a field. For example:

Lets say we have the following field:

header.id:
    type: text
    label: My Personal ID

This is a field that we dont want to allow for translation, so we can make the plugin skip this field by adding translator: false.

header.id:
    type: text
    label: My Personal ID
    translator: false

2. For a translator to be allowed access into the translator area they require 2 things added to their user account:

Example File: user/accounts/username.yaml

access:
  site:
    translator: 'true'

Any admin with super: true access will also be able to enter the translators area. However, before you can edit any language, you must first tell the plugin which language each user is allowed to translate. This can be done by adding the following:

Example File: user/accounts/username.yaml

translator:
  - de
  - en
  - es
  - sv

You can add as many languages as you want (as long as you have already enabled them in your multi-lang site).

You may also enable ALL enabled languages to be given access by simply adding: - super.

Example File: user/accounts/admin.yaml

translator:
  - super

You are now ready to start translating!

HOW TO ENABLE SLACK NOTIFICATIONS

Screenshot

Go to SLACK API and sign in your with Slack account. Make sure you are on the correct workspace too!

Hit the Create New App button - Fill in the details, you can pick any name you wish. Screenshot

Now you will need to enable 2 features: Enable Incoming Webhooks and Interactive Components Screenshot

Incoming Webhooks

  1. Click Add New Webhook to Workspace button at the bottom of the page. Select the channel you wish to send messages to. Your end result should be something like this:

Screenshot

Now copy the webhook url and the channel to the plugin configurations as shown above:

File: user/configs/plugins/translator.yaml

slack:
  enabled: true
  webhook: 'https://hooks.slack.com/services/...'
  channel: '#test'

Interactive Components

  1. Click Interactive Components on the sidebar menu and turn Interactivity to on

  2. Add the Request URL as follows:

https://yourwebsite.com/translator/api/slackendpoint

NOTE: Replace yourwebsite.com with the domain you are using the plugin on, and replace the /translator ONLY if you have modified the default base_route variable

Screenshot

Now you can enable Slack notifications in your plugin for approving and denying translator submitted pages.

Enjoy

grav-plugin-translator's People

Contributors

ricardo118 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

grav-plugin-translator's Issues

How to use translation after follow instruction ?

Maybe could assist with grav-plugin-translator https://github.com/ricardo118/grav-plugin-translator 1 , I have followed an instruction when a - super permission in user/accounts/admin.yaml file. After that on instruction mentioned You are now ready to start translating!
But I cannot find what next should I do, and where to go to translate pages? some url links should to work, or something should to appear in admin panel? Because there is nothing, maybe someone can assist with this?
Thanks in advance

Uncaught Error: Undefined class constant 'Monolog\Utils::DEFAULT_JSON_FLAGS'

Hello,

I've recently installed this plugin and all appeared find until the admin section stopped working with the 500 error message. Upon checking the logs i found the following entry:
[error] 361#361: *1 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Undefined class constant 'Monolog\Utils::DEFAULT_JSON_FLAGS' in /app/grav-admin/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php:194

I'm not sure if this is a misconfiguration on my end or an issue between the plugin and the platform. I was not able to find any info online apart from a forum post ( https://discourse.getgrav.org/t/undefined-class-constant-monolog-utils-default-json-flags/17299 ) where running the commands wouldn't report any extra information or fix the issue. I've then noticed a line suggesting it might had to do with translator plugin which upon deactivating it brought the admin section up.

Unable to save translation if the page does not already exist in translated language

I am getting errors making the plugin unusable. I can log in and select a page to translate, but am unable to save or submit the page.

I am using the latest version of Grav and PHP 7.4.1.

The error message is below:

Fatal error: Uncaught Error: Undefined class constant 'Monolog\Utils::DEFAULT_JSON_FLAGS' in C:\Users\amcbride\Web\grav-translator-test\vendor\monolog\monolog\src\Monolog\Handler\AbstractHandler.php:194 Stack trace: #0 C:\Users\amcbride\Web\grav-translator-test\vendor\monolog\monolog\src\Monolog\Handler\AbstractHandler.php(113): Monolog\Handler\AbstractHandler->getDefaultFormatter() #1 C:\Users\amcbride\Web\grav-translator-test\vendor\monolog\monolog\src\Monolog\Handler\AbstractProcessingHandler.php(37): Monolog\Handler\AbstractHandler->getFormatter() #2 C:\Users\amcbride\Web\grav-translator-test\vendor\monolog\monolog\src\Monolog\Logger.php(344): Monolog\Handler\AbstractProcessingHandler->handle(Array) #3 C:\Users\amcbride\Web\grav-translator-test\vendor\monolog\monolog\src\Monolog\Logger.php(470): Monolog\Logger->addRecord(500, 'Process could n...', Array) #4 C:\Users\amcbride\Web\grav-translator-test\system\src\Grav\Common\Errors\Errors.php(73): Monolog\Logger->addCritical('Process could n...') #5 C:\Users\amcbride\Web in C:\Users\amcbride\Web\grav-translator-test\vendor\monolog\monolog\src\Monolog\Handler\AbstractHandler.php on line 194

try to install

I try to install the plugins for an automatic translation from English to French thanks to google translation, and nothing works I did the installation correctly via the administration, after I put the translation in the control panel of the site my site appears well monsite.com/fr
But I do not see the translation in French?
When I go to the files I can't find the translated documents on the ftp ? how does your plugins work ?

Not handling urls properly when grav is in a subdirectory

Apologies for so many issues in a row!

This is another URL problem. When on the editing page, the plugin sends requests to the wrong URL, presumably because my installation is in a sub-directory.

Sends request to:

http://localhost/translator/edit/task:translator.keep.alive

Should be one of these (I'm not sure which):

http://localhost/path/to/grav/translator/edit/task:translator.keep.alive
http://localhost/path/to/grav/en/translator/edit/task:translator.keep.alive

There seems to be a similar problem with the emails send for approving / rejecting changes.

Incorrect redirect on login

Using the default settings, I log in to the plugin at the url .../en/translator

When I log in I am redirected to .../en/en/translator

Of course this gives a 404 error. The login is successful though because if I manually correct the url I do appear to be logged in.

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.