Code Monkey home page Code Monkey logo

twig-translation's Introduction

twig-translation's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar odan avatar twebt avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

twig-translation's Issues

Problems with bin/parse-twig.php

I modified the bin/parse-twig.php suggested in https://github.com/odan/twig-translation#parsing-twig-files slightly to fit into my app (https://github.com/vaizard/glued-skeleton/blob/master/glued/Core/Bin/parse-twig.php). Upon running the script, I'm getting

root@gdev:/var/www/html/glued-skeleton# php glued/Core/Bin/parse-twig.php 
PHP Notice:  Undefined index: SERVER_NAME in /var/www/html/glued-skeleton/glued/settings.php on line 109
PHP Notice:  Undefined index: SERVER_NAME in /var/www/html/glued-skeleton/glued/settings.php on line 110
PHP Notice:  Undefined index: SERVER_NAME in /var/www/html/glued-skeleton/glued/settings.php on line 111
Parsing: Calendar/Views/browse.twig
Parsing: Calendar/Views/manage.twig
Parsing: Core/Views/accounts.read.twig
PHP Fatal error:  Uncaught Twig\Error\SyntaxError: Unknown "url_for" function. in /var/www/html/glued-skeleton/glued/Core/Views/accounts.read.twig:17
Stack trace:
#0 /var/www/html/glued-skeleton/vendor/twig/twig/src/ExpressionParser.php(451): Twig\ExpressionParser->getFunctionNodeClass()
#1 /var/www/html/glued-skeleton/vendor/twig/twig/src/ExpressionParser.php(235): Twig\ExpressionParser->getFunctionNode()
#2 /var/www/html/glued-skeleton/vendor/twig/twig/src/ExpressionParser.php(175): Twig\ExpressionParser->parsePrimaryExpression()
#3 /var/www/html/glued-skeleton/vendor/twig/twig/src/ExpressionParser.php(70): Twig\ExpressionParser->getPrimary()
#4 /var/www/html/glued-skeleton/vendor/twig/twig/src/Parser.php(142): Twig\ExpressionParser->parseExpression()
#5 /var/www/html/glued-skeleton/vendor/twig/twig/src/TokenParser/BlockTokenParser.php(45): Twig\Parser->subparse()
#6 /var/www/html/glued-skeleton/vendor/twig/twig/src/Parser.php(185): Twig\TokenParser\BlockTokenParser->parse()
#7 /var/www/html/glued-skeleton/vendor/twig/twig/s in /var/www/html/glued-skeleton/glued/Core/Views/accounts.read.twig on line 17

I'm not sure why I get the Unknown "url_for" function error. It seems that the slimphp/Twig-View somehow doesn't get loaded, even though I'm getting $twig from the container, so I should be 1:1 with the rest of the app. I'm really at loss how to fix this. Got any ideas you could kindly suggest?

Thanks, P.

Im stuck ... ConfigCacheFactory' not found

Hi Odan,

any idea on this ?

`
Type: Error
Code: 0
Message: Class 'Symfony\Component\Config\ConfigCacheFactory' not found
File: ...\vendor\symfony\translation\Translator.php
Line: 461
Trace

#0 ..\vendor\symfony\translation\Translator.php(287): Symfony\Component\Translation\Translator->getConfigCacheFactory()
#1 ..\vendor\symfony\translation\Translator.php(261): Symfony\Component\Translation\Translator->initializeCacheCatalogue('fr_FR')
#2 ..\vendor\symfony\translation\Translator.php(240): Symfony\Component\Translation\Translator->loadCatalogue('fr_FR')
#3 ..\vendor\symfony\translation\Translator.php(206): Symfony\Component\Translation\Translator->getCatalogue('fr_FR')
#4 ..\vendor\odan\twig-translation\src\TwigTranslationExtension.php(66): Symfony\Component\Translation\Translator->trans('Welcome', Array)
#5 ..\tmp\twig\fd\fd9eef701efe2a41a295486cca34e1a74fd5a02c9924a43be694b595671751e5.php(51): Odan\Twig\TwigTranslationExtension->__('Welcome')`

TwigCompiler

When I import and use your TwigCompiler, this line $this->cachePath = str_replace('\\', '/', trim($cachePath, '\/'));
removes leading '/', I'm assuming to make the ensure a relative path. But my path is an absolute path and this breaks the ability to create the dir, if needed.

When I used this in my project, before you updated this, I had to remove the str_replace and simply use $this->cachePath = trim($cachePath);

When I look at your Slim4-Skeleton it appears that you are also using an absolute path, so I am not sure how it works there, either.

I am probably missing something that you have configured in your project that I do not have in mine.

Any help would be appreciated.

Thanks again for the quick update.

I suppose that a right trim would do the trick also .

Translation file not read?

I made a project based on the slim4 skeleton, leaving out a number of things for I don't need them now. I did leave in the twig-translation. For some reason, it doesn't seem to get my translation text.

In my en_US_messages.po file I have:
msgid "strCurrentTime" msgstr "Current time"

In my twig template I have:
{{ __('strCurrentTime') }}

My settings locale is set to
en-US

Now when I load the page, I see 'strCurrentTime', and not the message string. Even if I change the settings locale (not the browser) to 'fr_FR' it will not get the value from the 'po' file. If I empty the locale-cache directory, new files are made, but I don't see something recognizable in these files related to the string. If I place echo commands in the 'translate.php' file, I get response the result on my page, but never a translated value.

Any tips?

Update for Twig 3

Now that twig-extensions is deprecated and not available for Twig 3, how can this be updated to work with Twig 3? I can't even find 'trans' or i18n extension as part of the 'Core Extensions'.

Or, is this something that will have to be created from scratch, without using Twig's Core Extensions?

I'm not asking you to rewrite this, only asking your opinion. I am considering using your class for compiling the templates along with PHP-I18N in a project of mine.

Thanks for all you do. I am learning alot, at least I hope I am, from reading and using your projects and tutorials.

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.