Giter VIP home page Giter VIP logo

lswgettexttranslationbundle's People

Contributors

azamatjon avatar codeslash avatar ewgra avatar gabrielanca avatar gijsl avatar marc-casoliva avatar mevdschee avatar minras avatar rolphh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lswgettexttranslationbundle's Issues

Command translations?

Hello,

I'm trying to get gettext translations from symfony commands (in twig templates that send mails, for instance). Mails are correctly translated when sent from the main app, but remains in english when sent from a console command.

Looking at this issue, i've found that we should use the following to get that working with symfony's translations:

$this->getContainer()->get('translator')->setLocale('fr');

What should I do with gettextbundle to get that work as expected?

Thank you :)

LC_MESSAGES, windows 7 / 10, Locale, Symfony2.8

I'm stuck on that:

Notice: Use of undefined constant LC_MESSAGES - assumed 'LC_MESSAGES' in C:\xampp\htdocs\symfony2_8project\vendor\leaseweb\gettext-translation-bundle\Lsw\GettextTranslationBundle\Routing\GettextLocaleListener.php on line 56

Warning: setlocale(): Invalid locale category name LC_MESSAGES, must be one of LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, or LC_TIME in C:\xampp\htdocs\symfony2_8project\vendor\leaseweb\gettext-translation-bundle\Lsw\GettextTranslationBundle\Routing\GettextLocaleListener.php on line 56

Fatal error: Uncaught exception 'Symfony\Component\Routing\Exception\InvalidParameterException' with message 'Requested locale 'en_US' could not be set.
Is this locale installed? Hint: Execute 'locale -a' on the Linux command line to list installed locales.'
in C:\xampp\htdocs\symfony2_8project\vendor\leaseweb\gettext-translation-bundle\Lsw\GettextTranslationBundle\Routing\GettextLocaleListener.php:58
Stack trace:
#0 [internal function]: Lsw\GettextTranslationBundle\Routing\GettextLocaleListener->onKernelRequest(Object(Symfony\Component\HttpKernel\Event\GetResponseEvent), 'kernel.request', Object(Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher))
#1 C:\xampp\htdocs\symfony2_8project\vendor\symfony\symfony\src\Symfony\Component\EventDispatcher\EventDispatcher.php(181): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\GetResponseEvent), 'kernel.request', Object(Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher))
#2 C:\xampp\htdocs\symfony_projec in C:\xampp\htdocs\symfony2_8project\vendor\leaseweb\gettext-translation-bundle\Lsw\GettextTranslationBundle\Routing\GettextLocaleListener.php on line 58

Use gettext in Twig error pages

I'm trying to use GettextBundle with my specific Twig error pages (404 mainly).

First of all, using the command "gettext:app:extract" will try to find strings to translate only in "app/Resources/views" directory; but to override Twig error pages, we have to use "app/Resources/TwigBundle/views/" directory.

I've solved that on my side changing a bit AbstractCommand.php:

diff -up vendor/leaseweb/gettext-translation-bundle/Lsw/GettextTranslationBundle/Command/AbstractCommand.php.patch vendor/leaseweb/gettext-translation-bundle/Lsw/GettextTranslationBundle/Command/AbstractCommand.php
--- vendor/leaseweb/gettext-translation-bundle/Lsw/GettextTranslationBundle/Command/AbstractCommand.php.patch   2014-03-05 10:48:57.298092011 +0100
+++ vendor/leaseweb/gettext-translation-bundle/Lsw/GettextTranslationBundle/Command/AbstractCommand.php 2014-03-05 11:33:46.031956078 +0100
@@ -97,7 +97,12 @@ abstract class AbstractCommand extends C
             mkdir($dir, 0755, true);
         }

-        $templates = $this->findFilesInFolder($dir . '/../views', 'twig');
+        $templates = array();
+        if ( $name === 'app' ) {
+            $templates = $this->findFilesInFolder($dir . '/../../', 'twig');
+        } else {
+            $templates = $this->findFilesInFolder($dir . '/../views', 'twig');
+        }

         $php  = "<?php\n";
         $twig = $this->getContainer()->get('twig');

This way, I can successfully extract string from all overrided bundles views.

But that does not work as expected... No strings are translated; even those from the main template my 404 view inherits from.
Taking a look in the code, it appears that the problem in GettextLocaleListener.php, in the onKernelRequest method:

      if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
          return;
      }

I do not understand what is that condition for, but if I remove those lines, my 404 page is translated.

Is it a bad idea to remove those lines?
And what about the trick to handle overrided templates?

Thank you.

Twig translations ?

Hello,

I'm trying to use your bundle in my Symfony 2.3 application; string extraction is working fine on the PHP side using "_('My string to translate')" notation, all strings are properly extracted in the po files.

But I can't get Twig messages extracted at all :/ Using --keep-cache argument, the file MyBundle/Resources/gettext/twig.cache.php is created using the Symfony way ($this->env->getExtension('translator')->getTranslator()->trans("Clear", array(), "messages")).

So the question is, have I mised something, or is there any changes in recent Symfony releases that make gettext bundle unhappy?

Thank you :)

Commands not working with Symfony 3.x

Hey,

the commands don't work anymore due to removal of the Dialog helper:

bin/console gettext:bundle:extract

[Symfony\Component\Console\Exception\InvalidArgumentException]
The helper "dialog" is not defined.

"The Dialog Helper was deprecated in Symfony 2.5 and removed in Symfony 3.0. You should now use the Question Helper instead, which is simpler to use."

Cheers
Matthias

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.