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.

Plugins

Extend plugin languages

first-time plugins

Solved by pamtbaau View solution

Started by Karmalakas 6 years ago · 3 replies · 878 views
6 years ago

Hi,

Trying to extend a plugin languages. Wouldn't want to edit languages.yaml in a plugin folder directly. Any instrunctions how do I do that?

Thanks

5 years ago Solution

@Karmalakas, To add an extra translation for a plugin, you can do the following. Also see the docs about Translation Overrides.

Let's add 'Italian to the plugin:

  • Lookup the string from the plugin you want to override. Eg from plugin 'Test' look in file user/plugins/test/languages.yaml:
    YAML
    en:
    PLUGIN_TEST:
      TEXT_VARIABLE: Text Variable
      TEXT_VARIABLE_HELP: Text to add to the top of a page
    
  • Create file user/languages/it.yaml
  • Copy the following into the new file:
    YAML
    PLUGIN_TEST:
    TEXT_VARIABLE: <Translation in Italian>
    TEXT_VARIABLE_HELP: <Translation in Italian>
    
  • Add language it to user/config/system.yaml:
    YAML
    languages:
    supported: [en, it]
    
  • If plugin Test has the snippet {{ 'PLUGIN_TEST.TEXT_VARIABLE' | t }} in a template , it will be translated into Italian when you browse to the Italian version of the page.
👍 1
5 years ago

OK, so this works for front-end, but not Admin. I translated Login plugin to LT. Everything is in user/languages/lt.yaml

YAML
PLUGIN_LOGIN:
  USERNAME: "Vartotojo vardas"
  EMAIL: "El. paštas"
  USERNAME_EMAIL: "Vartotojo vardas/El. paštas"
  <...>

I also went to my profile (top left of Admin) and changed the language, but still can't see any changes. And actually none of Admin strings are translated - whole Admin is still in English. What am I missing?

5 years ago

It seems I just had to re-login to Admin

Suggested topics

Topic Participants Replies Views Activity
Plugins · by Rene, 1 week ago
2 42 1 week ago
Plugins · by Xavier, 4 weeks ago
2 53 4 weeks ago
Plugins · by Luka Prinčič, 7 years ago
3 1179 1 month ago
Plugins · by Sebastian van de Meer, 1 month ago
1 47 1 month ago
Plugins · by PIERROT Alain, 2 months ago
3 71 2 months ago