Giter VIP home page Giter VIP logo

silex-web-translator's Introduction

Silex Web Translator

Introduction

This Silex Provider allows you to easily manage the translation files for your app via a web-based interface. Current features include:

  • Dashboard for a quick overview of the current status of translations for your app including total translations, total locales and total untranslated strings.

dashboard

  • A simple editor for translation strings, allowing you to quickly see which translation strings are missing for each locale

translation screen 1 translation screen 2

Requirements

  • PHP 5.4+
  • Using YAML files for your translations. They must be formatted as <domain>.<locale>.yml. If you aren't using the domains featured of the Symfony Translation component then make sure you name your translation files messages.<locale>.yml.
  • For all usage of locales in your app use the ISO 639-1 language code, an underscore (_), then the ISO 3166-1 alpha-2 country code (e.g. fr_FR for French/France).
  • Make sure you configure all locales as fallbacks when setting up the TranslationProvider.

Installation

  • Configuration the default Silex TranslationServiceProvider in a similar way:
$app['locale'] = 'en_GB';
$app->register(new Silex\Provider\TranslationServiceProvider(), array(
    'locale_fallbacks' => array('en_GB', 'fr_FR', 'fi_FI'),
));

$app['translator'] = $app->share($app->extend('translator', function($translator, $app) {

    $translator->addLoader('yaml', new Symfony\Component\Translation\Loader\YamlFileLoader());

    $translator->addResource('yaml', __DIR__.'/../translations/messages.en_GB.yml', 'en_GB');
    $translator->addResource('yaml', __DIR__.'/../translations/messages.fr_FR.yml', 'fr_FR');
    $translator->addResource('yaml', __DIR__.'/../translations/messages.fi_FI.yml', 'fi_FI');
    $translator->addResource('yaml', __DIR__.'/../translations/rules.en_GB.yml', 'en_GB', 'rules');

    return $translator;
}));
  • Make sure you are using and have registered the following service providers:
$app->register(new Silex\Provider\ServiceControllerServiceProvider());
$app->register(new Silex\Provider\UrlGeneratorServiceProvider());
$app->register(new Silex\Provider\FormServiceProvider());
$app->register(new Silex\Provider\ValidatorServiceProvider());
$app->register(new Silex\Provider\TwigServiceProvider());
  • Register the service provider and configure the options
$app['webtranslator.options'] = array(
    'translator_file_path' => __DIR__ . '/../translations/'
);
$app->register(new DC\WebTranslator\Provider\WebTranslatorServiceProvider());
  • Mount the controller provider
$app->mount('/webtranslator', new DC\WebTranslator\Controller\WebTranslatorControllerProvider());

FAQ

How to protect the interface with user authentication?

  • You can protect the route you mount the controller on, as you would any other route, using the Symfony security component.

Known issues

  • If you import nested YML files with pretty new line (pipe) syntax, it will replace new lines with \r\n

Thanks/Credits

silex-web-translator's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

edoz77

silex-web-translator's Issues

Move any inline CSS/JS into their own files

I haven't yet investigated how to achieve this. The problem being what URL would be used inside the <script> and <link> tags as different applications are mounted at different URLs. In theory this might be solved using a configuration option which would basically hardcode the path to where these images might be. The assets would end up in the vendor/ directory which should never be accessible at a public URL.

Template not defined

Hi, I am triying to install this bundle but i'm getting this error all time when I acces to /webtranslator

"Template "@webtranslator/index.twig" is not defined."

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.