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

Translating Grav

Started by Muut Archive 10 years ago · 8 replies · 573 views
10 years ago

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. :)
Thanks in advance!

10 years ago

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/

10 years ago

Thnaks! :)
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 :)

10 years ago

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

10 years ago

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

10 years ago

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.

10 years ago

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

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

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?

10 years ago

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 :) this is just bad practice and looks unprofessional when building sites for serious clients.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1352 9 years ago
Archive · by Muut Archive, 9 years ago
2 935 9 years ago
Archive · by Muut Archive, 9 years ago
2 4064 9 years ago
Archive · by Muut Archive, 9 years ago
1 2950 9 years ago
Archive · by Muut Archive, 9 years ago
3 1119 9 years ago