Git Product home page Git Product logo

Comments (24)

vojtasvoboda avatar vojtasvoboda commented on May 30, 2024 1

@qroft New file should have path /plugins/vojtasvoboda/twigextensions/lang/es/lang.php and then websites should be switched to es locale.

from oc-twigextensions-plugin.

vojtasvoboda avatar vojtasvoboda commented on May 30, 2024

Thanks @ribsousa, good point. I tried to follow the Twig documentation:

To get a translatable output, give a Symfony\Component\Translation\TranslatorInterface as constructor argument. The returned string is formatted as diff.ago.XXX or diff.in.XXX where XXX can be any valid unit: second, minute, hour, day, month, year.

But it returns string like diff.ago.minute instead of 5 minutes ago, so I have to figure out how to translate this strings. Because when I create plugin's translations, they will be prefixed with vojtasvoboda.twigextensions :-(

from oc-twigextensions-plugin.

ribsousa avatar ribsousa commented on May 30, 2024

Hello, take a look at this! I think it's the way to get the translation

http://stackoverflow.com/questions/34568838/twig-date-time-diff-translation/34569701

https://github.com/KnpLabs/KnpTimeBundle/blob/master/Resources/translations/time.en.xliff

from oc-twigextensions-plugin.

vojtasvoboda avatar vojtasvoboda commented on May 30, 2024

Hello @ribsousa,

this KnpTimeBundle is bundle created for Symfony and using Symfony Translator. For this plugin it will be better to use October Translator and have all translations stored at /lang folder.

Check my feature/time_diff_trans branch with translations testing version. Can you please test it?

Translate string are stored at /lang/en/lang.php and they are taken from https://github.com/KnpLabs/KnpTimeBundle/blob/master/Resources/translations/time.en.xliff

from oc-twigextensions-plugin.

ribsousa avatar ribsousa commented on May 30, 2024

How to install it via composer?

from oc-twigextensions-plugin.

vojtasvoboda avatar vojtasvoboda commented on May 30, 2024

Go to the /plugins/vojtasvoboda/ directory and run git clone [email protected]:vojtasvoboda/oc-twigextensions-plugin.git -b feature/time_diff_trans twigextensions

from oc-twigextensions-plugin.

ribsousa avatar ribsousa commented on May 30, 2024

from oc-twigextensions-plugin.

vojtasvoboda avatar vojtasvoboda commented on May 30, 2024

Just download it to /plugins/vojtasvoboda/twigextensions/ folder. Nothing more.

from oc-twigextensions-plugin.

ribsousa avatar ribsousa commented on May 30, 2024

from oc-twigextensions-plugin.

vojtasvoboda avatar vojtasvoboda commented on May 30, 2024

I'm sorry, you have to run composer install at /plugins/vojtasvoboda/twigextensions/

from oc-twigextensions-plugin.

ribsousa avatar ribsousa commented on May 30, 2024

from oc-twigextensions-plugin.

vojtasvoboda avatar vojtasvoboda commented on May 30, 2024

Can you send me your translation file please? I can see you don't use english nor czech translations. I want to add it to repository for others, thanks.

from oc-twigextensions-plugin.

ribsousa avatar ribsousa commented on May 30, 2024

from oc-twigextensions-plugin.

ribsousa avatar ribsousa commented on May 30, 2024

There is a problem with filter!
example:

Post published on Dec 08, 2016

{{ post.published_at | time_diff }}

return: 1 day ago

from oc-twigextensions-plugin.

vojtasvoboda avatar vojtasvoboda commented on May 30, 2024

I have tried

{{ '2016-12-08 12:00' | time_diff }}

and it prints

1 month ago

My timezone is set to UTC.

from oc-twigextensions-plugin.

vojtasvoboda avatar vojtasvoboda commented on May 30, 2024

Fixed by #16

from oc-twigextensions-plugin.

ribsousa avatar ribsousa commented on May 30, 2024

{{ '2016-12-08 12:00' | time_diff }}

Here also print

1 month ago

But the date of the post "8-12-2016 14:31"

{{ post.published_at | time_diff }}

en print: 30 days ago
pt-br print: 1 dias atrás

My timezone is set to America/Brasilia

from oc-twigextensions-plugin.

ribsousa avatar ribsousa commented on May 30, 2024

It's working right now printing correctly!

from oc-twigextensions-plugin.

vojtasvoboda avatar vojtasvoboda commented on May 30, 2024

Update is now ready at the October Market. Can you send me please that pt-br locale file by pull-request? Thanks

from oc-twigextensions-plugin.

vojtasvoboda avatar vojtasvoboda commented on May 30, 2024

@ribsousa: I would like to ask you, can you give me review to the Twig plugin please? It really helps me :-) Thanks!

http://octobercms.com/plugin/vojtasvoboda-twigextensions

from oc-twigextensions-plugin.

ribsousa avatar ribsousa commented on May 30, 2024

from oc-twigextensions-plugin.

sarpaykent avatar sarpaykent commented on May 30, 2024

Hey sorry for the bump, but can't find feature/time_diff_trans branch. I'm little confused about how to give a Symfony\Component\Translation\TranslatorInterface as the constructor argument.

from oc-twigextensions-plugin.

vojtasvoboda avatar vojtasvoboda commented on May 30, 2024

@HackHers Time_diff_trans branch was merged in this pull request: #16

from oc-twigextensions-plugin.

qroft avatar qroft commented on May 30, 2024

I am also having some trouble with this as i am unsure if i have to create the LANG folder in the root or simply just add my language into the plugins folder at twigextenstions/lang !?

What i did:
i downloaded the EN language folder and edited its language into spanish.
Then i uploaded it to the plugins lang folder into a folder "es" for spanish.
Did not work.
So i renamed it to "es_es" - did not work.
So i renamed it to "es-ES" - did also not work.

I know that translations are working, as i am using the localizeddate tag somewhere else and there it works perfectly.

from oc-twigextensions-plugin.

Related Issues (20)

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.