Translating Grav

Hi all! Grav is just great but I’m having trouble wrapping my head around translations. I don’t need a multilanguage site, I just want all strings properly translated. I realize I can create alternative twig files in my theme directory and translate stuff but I’m having trouble with dates in the blog skeleton. I’ve read through the manual and can’t seem to get it right. Any help is greatly appreciated!
Also, from what I gather, there should be an option to translate just the string in one file, without having to mess with each twig file seperately. Any help would be greatly appreciated. :slight_smile:
Thanks in advance!

There are different places to translate for different things:

  1. Content - just write your content in your language of choice
  2. Templates - Depends on the theme really, but you need edit the Twig to output any hard-coded strings in your language
  3. Core - There are some core language strings that are in system/languages/

Thnaks! :slight_smile:
Now the only thing missing is the date names. From what I gather these are PHP related and I can’t seem to “force” Grav to display Croatian month names.

Tnx again :slight_smile:

It depends where you are using those. We added month names to the Grav lang file not so long ago: you can post a PR for the Croatian translation and we’ll add it in the next release, and then you can see if the plugin/theme is already using that language string or not.

I’m using blog skeleton and nothing happens when I translate the months in system/hr.yaml.
Also one more question - when I figure out how to pull strings from the language file will it get overwritten during the next update? Or can i make a system/language folder and put my custom yaml file in there?

10x :slight_smile:

you can copy the system language file into /user/languages/hr.yaml or whatever and it wont be overridden.

If you translated the months please submit a PR so we can include it in Grav for everyone.
As for translations where exactly do you get the months names, in the blog posts list / post detail? The theme must specifically lookup that string.

Oh, sure I’ll make a PR, np. :slight_smile:
For now I’ve made a “dirty” fix:
in blog_item.html.twig, this is the part of the code that generates the dates;

<span class="list-blog-date">
         <span>{{|date("d") }}</span>
         <em>{{|date("m") }}</em>

I’ve changed it to display only numbers. How would I go about adding a translation of the shortened date names (Jan / Feb, etc) in this template?

I made the PR. I can see one potential issue. The days of the week are lower case in Croatian (so that’s how I translated them). Of course, if the day of the week is at the beginning of the sentence, it’s upper case - I’m yet to figure out how to use and see where Grav templates put the days of the week but I’m thinking the ideal situation is that this case should be covered. I see lots of open source projects translating Croatian weekdays wrong (uppercase like in English) and while I’m by no means a spelling nazi :slight_smile: this is just bad practice and looks unprofessional when building sites for serious clients.