Closed ribsousa closed 7 years ago
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
:-(
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
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
How to install it via composer?
Go to the /plugins/vojtasvoboda/
directory and run git clone git@github.com:vojtasvoboda/oc-twigextensions-plugin.git -b feature/time_diff_trans twigextensions
I need to run some command to install, or just download?
2017-01-07 17:14 GMT-02:00 Vojta Svoboda notifications@github.com:
Go to the /plugins/vojtasvoboda/ directory and run git clone git@github.com:vojtasvoboda/oc-twigextensions-plugin.git -b feature/time_diff_trans twigextensions
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/vojtasvoboda/oc-twigextensions-plugin/issues/8#issuecomment-271103650, or mute the thread https://github.com/notifications/unsubscribe-auth/ACn5_qfaJwrMOCNowT5Ho34imFPau9EAks5rP-QlgaJpZM4Jjwj4 .
Just download it to /plugins/vojtasvoboda/twigextensions/
folder. Nothing more.
Not work!
2017-01-07 18:03 GMT-02:00 Vojta Svoboda notifications@github.com:
Just download it to /plugins/vojtasvoboda/twigextensions/ folder. Nothing more.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/vojtasvoboda/oc-twigextensions-plugin/issues/8#issuecomment-271106576, or mute the thread https://github.com/notifications/unsubscribe-auth/ACn5_mfjTl3aBM4kr7fpSRPJRU2j3-CKks5rP--XgaJpZM4Jjwj4 .
I'm sorry, you have to run composer install
at /plugins/vojtasvoboda/twigextensions/
Its, work! see http://gleebe.org/pt-br/blog
2017-01-07 18:07 GMT-02:00 Vojta Svoboda notifications@github.com:
I'm sorry, you have to run composer install at /plugins/vojtasvoboda/ twigextensions/
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/vojtasvoboda/oc-twigextensions-plugin/issues/8#issuecomment-271106819, or mute the thread https://github.com/notifications/unsubscribe-auth/ACn5_lTRHFB2orER53UqEBitKD2Jq0Qiks5rP_CcgaJpZM4Jjwj4 .
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.
Ok! I use Portuguese from Brazil (pt-br)
2017-01-08 7:13 GMT-02:00 Vojta Svoboda notifications@github.com:
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.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/vojtasvoboda/oc-twigextensions-plugin/issues/8#issuecomment-271139538, or mute the thread https://github.com/notifications/unsubscribe-auth/ACn5_mfmoqWzTf3AWyAlehrchQrCVX6pks5rQKidgaJpZM4Jjwj4 .
There is a problem with filter! example:
Post published on Dec 08, 2016
{{ post.published_at | time_diff }}
return: 1 day ago
I have tried
{{ '2016-12-08 12:00' | time_diff }}
and it prints
1 month ago
My timezone is set to UTC.
Fixed by #16
{{ '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
It's working right now printing correctly!
Update is now ready at the October Market. Can you send me please that pt-br
locale file by pull-request? Thanks
@ribsousa: I would like to ask you, can you give me review to the Twig plugin please? It really helps me :-) Thanks!
Review ok!
Thanks!
2017-01-09 12:18 GMT-02:00 Vojta Svoboda notifications@github.com:
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
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/vojtasvoboda/oc-twigextensions-plugin/issues/8#issuecomment-271294924, or mute the thread https://github.com/notifications/unsubscribe-auth/ACn5_h5SInC0H8J5PUy-EKXV2LccQ6qLks5rQkGggaJpZM4Jjwj4 .
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.
@HACKHERS Time_diff_trans branch was merged in this pull request: https://github.com/vojtasvoboda/oc-twigextensions-plugin/pull/16
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.
@qroft New file should have path /plugins/vojtasvoboda/twigextensions/lang/es/lang.php
and then websites should be switched to es
locale.
How to get a translated output to