Plugins internationalization

Hi everyone!

I’ve a question about the possibility to translate strings in any plugin. I’m not sure if:

  1. there is a way to translate the strings witouth to edit the plugins files
  2. in case the files should be edited, what method should i use? I mean i tried changing de string by l::get method but nothing is showing.

I appreciate any help.

Thank you so much!

You mean when using an existing plugin?

Yep!

I’m using the revisions plugin but my interface is set in french and spanish, so i would like to translate the plugin’s strings that appear in the panel.

Is this possible?

It can be done, but it’s a bit of work and you would have to modify the plugin directly. I think there are two options: defining the translations in the config.php, or add the translations to the plugin via a translation function.

Hi Texnixe,

Is there any doc to learn how to do both things?

I tried to use l::get as in the rest of the templates strings, but didn’t work. Are you talking about another translation function?

Thanks!

You may want to have a look at my logger plugin. I provides a helper function in helpers.php: https://github.com/texnixe/kirby-logger/blob/master/lib/helpers.php and a translation file https://github.com/texnixe/kirby-logger/blob/master/lib/translations.php. Instead of using the translation file, you can also fall back to settings in your config.php, see the readme.

In https://github.com/texnixe/kirby-logger/blob/master/views/index.php you can see how this function is used.

2 Likes

@texnixe great plugin. did same thing once but way simple. what i found useful is to store a githash of the content file too so it can be used to track changes using autogit plugin.

// http://stackoverflow.com/questions/552659/how-to-assign-a-git-sha1s-to-a-file-without-git
$githash = sha1("blob ". 
  f::size($page->content($lang)->root()).
  "\0".
  $page->content($lang)->raw());