Dates in other languages

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.

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

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 :slight_smile:

is rendered*

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

<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.

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 :slight_smile:

That would be great thanks!

And where exactly do I run this command:

composer require twig/extensions ~1.1.0

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

-bash: composer: command not found
---

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

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.

You can try this:

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:

"twig/twig": "~1.16",

after add:

"twig/extensions": "~1.1.0",

then run:

bin/composer.phar update
---

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

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.

mmm… and add a vendor folder on user folder?

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.

Well, that’s to hard for me :slight_smile:

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:

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

That’s it. My date can stay english… :slight_smile:

Big thx for help guys.

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 :slight_smile:

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

Thank you!