Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Archive

Dates in other languages

Started by Muut Archive 11 years ago · 19 replies · 621 views
11 years ago

Where can I find months and week days so I can change them to other languages? I'm using My Gravistic Blog skeleton. Managed to manualy change values like "Next Post", "Previous Post", "Simple Search" etc.

11 years ago

I think is hardcoded inside plugin/theme, you need to change directly on files.

11 years ago

Thx for your reply. Which files do you mean? Maybe I didn't explain it clear enough. Each blog element has its automatic date taken from *.md file (it's for example "12/01/2015", and system renders it into "01 JAN"). Or in Archieves Plugin, this date is rendering into "January 2015". This is where I want my language :)

11 years ago

the 01/JAN bit is rendered in the partials/blog_item.html.twig file:

TWIG
<span class="list-blog-date">
  <span>{{ page.date|date("d") }}</span>
  <em>{{ page.date|date("M") }}</em>
</span>

However, it's my understanding that you would need to use PHP's strftime() function in order to get dates formatted in other languages. To get support for this in Twig, you would need to load the Intl extension:

http://twig.sensiolabs.org/doc/extensions/intl.html

We are currently not doing this in Grav, so you would have to do it with a plugin. We do have intentions of adding multilang support in Grav, and we planned on looking into this intl extension at that point, but if you can't wait, you should be able to do it with a plugin as I mentioned.

11 years ago

Big thx! Will give it a try. Once you're rdy for multilang, put down my username. I would gladly help with Polish and Russian translations, if needed :)

11 years ago

And where exactly do I run this command:

BASH
composer require twig/extensions ~1.1.0

When I'm running it in ~/webroot on my server (via bash), I'm getting this:

TXT

-bash: composer: command not found
---
11 years ago

You not have installed or not in path composer, before this install or add composer to your $PATH :)

11 years ago

I'm totaly new to Grav and haven't been forced to use SSH either, so... how can I install/add composer to my $PATH (I'm quite an enduser)? In ~/webroot folder there are files called "composer.json" and "composer.lock" if this is what you mean.

11 years ago

You can try this:

TXT
bin/composer.phar require twig/extensions ~1.1.0

but i think you need to update the composer configuration file and add this line to:

TXT
"twig/twig": "~1.16",

after add:

TXT
"twig/extensions": "~1.1.0",

then run:

TXT

bin/composer.phar update
---
11 years ago

but if you edit composer.json file, anytime you update Grav you need to add this... waiting @rhukster to give more info about this :)

11 years ago

You can add this, but it will get overwritten with any Grav updates. Unfortunately there's no simple way to have multiple vendor folders (Grav + User) with Composer. I was hesitant about adding the Twig Extensions until we sorted out our multilang solution, but it may become part of the Grav standard installation just not enabled.

11 years ago

mmm... and add a vendor folder on user folder?

11 years ago

well you could create your own composer.json in user/ folder, and then it would create a 'vendor/` folder you there. Then you would just have to add that class loader during init. We could actually look for that file, and include it if found in Grav, but you could also write a super simple plugin that did it too.

11 years ago

Well, that's to hard for me :)

I'm getting an error when I try to update composer.phar as u said, also getting an error when I try to install Extensions library (http://twig.sensiolabs.org/doc/extensions/intl.html). Even if I managed to do that, still have no idea where do I add this line:

PHP
$twig->addExtension(new Twig_Extensions_Extension_Intl());

That's it. My date can stay english... :)

Big thx for help guys.

11 years ago

Rhukster, my last question will be: where (what file, which line) do I add this:

$twig->addExtension(new Twig_Extensions_Extension_Intl());

?

Thank you in advance :)

11 years ago

It would need to be done in a plugin. Look at the SmartyPants plugin for an example.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1318 9 years ago
Archive · by Muut Archive, 9 years ago
2 915 9 years ago
Archive · by Muut Archive, 9 years ago
2 4024 9 years ago
Archive · by Muut Archive, 9 years ago
1 2900 9 years ago
Archive · by Muut Archive, 9 years ago
3 1082 9 years ago